First-person 3D pong ray-traced on CPU in real time.

Overview

ray ten

Run in browser

ray-ten.mp4

Reimagining of a 1986 ZX Spectrum game room ten made with ray tracing. Completely ignoring GPUs when rendering 3D graphics is extremely inefficient, but ray-ten is quite efficient at being inefficient, thanks to portable-simd, rayon and cutting all the corners. I use macroquad for displaying the render and window controls because its WASM integration just works.

So what do I do?

Use the arrow keys to move the paddle trying not to miss the ball.

I'm on a phone and I have no physical keyboard.

You can also click/touch borders to move the paddle.

Why ray tracing tho?

Because modern graphics pipelines are boring and reflections are nice, even in low-res.

Couldn't you just use fragment shaders to the same effect? That would be infinitely more efficient.

That's true, I believe I could, maybe I'll try it next.

What's 'rps'?

That's rays-per-second, a handy way to gauge ray tracing throughput. Works like ersatz CPU benchmark unless fps are capped.

So what's the results then?

Platform Native single core Native multicore Firefox WASM Chrome WASM
Ryzen 7 3700X (8 cores) 39M 300M 7M 17M
MediaTek Dimensity 1200 - - 10M 12M

All browser versions are the most recent as of August 07, 2022. WASM modules are compiled with +simd128, optimized with wasm-opt -O4 and run in single core mode. Yes, mobile Firefox is faster than the desktop version.

That multicore difference is huge, can't you use rayon in WASM somehow?

I can, but that would require GitHub Pages to set COOP/COEP headers, and they aren't there yet, see community/community#13309.

You might also like...
Rust-raytracer - 🔭 A simple ray tracer in Rust 🦀
Rust-raytracer - 🔭 A simple ray tracer in Rust 🦀

rust-raytracer An implementation of a very simple raytracer based on Ray Tracing in One Weekend by Peter Shirley in Rust. I used this project to learn

A basic raytracer implementation in Rust based on the Ray Tracing in One Weekend book.
A basic raytracer implementation in Rust based on the Ray Tracing in One Weekend book.

Raytracer A basic raytracer implementation in Rust based on the Ray Tracing in One Weekend book. Live Demo Result How to Run Standalone Binary $ cargo

💫 create beautiful code snippets on ray.so
💫 create beautiful code snippets on ray.so

Rayso✨ [ Generate beautiful screenshot snippets from terminal using ray.so ] Installation 🍀 Source 🍙 $ git clone --depth=1 https://github.com/pwnwri

a prototype crate for creating modular and performant 3D CPU particle systems, inspired by Unity's Shuriken Particle System.

bevy_prototype_particles This is a prototype crate for creating modular and performant 3D CPU particle systems, inspired by Unity's Shuriken Particle

A cpu-based raytracer written in rust.

mini-raytracer A cpu-based raytracer written in rust. This project was written by me to learn about computer graphics, specifically rayracing. Feature

🎆 CPU-driven, batch-rendered particle system for the Bevy game engine.
🎆 CPU-driven, batch-rendered particle system for the Bevy game engine.

Bevy Firework 🎆 Bevy firework is a particle system plugin where particles are simulated on the CPU and use GPU batching for rendering. This allows ea

My first attempt at game programming. This is a simple target shooting game built in macroquad.

sergio My first attempt at game programming. This is a simple target shooting game built in macroquad. Rules Hit a target to increase score by 1 Score

A game made in one week for the Bevy engine's first game jam

¿Quien es el MechaBurro? An entry for the first Bevy game jam following the theme of "Unfair Advantage." It was made in one week using the wonderful B

A plugin-first anime-ish video game

🌷 🌷 Project Flara 🌸 🌸 A plugin-first anime-ish video game Have you ever played an anime mobile video game, and then wondered. Huh, I wish I could

Combine simple building blocks to create smooth cameras: first-person, chase, orbit, look-at, you name it!

?? dolly Combine simple building blocks to create smooth cameras: first-person, chase, orbit, look-at, you name it! Camera rigs made with dolly are en

Tomasz Stachowiak 284 Dec 26, 2022
Dark Forest, the world's first decentralized real-time strategy game.

darkforest-rs Dark Forest, the world's first decentralized real-time strategy game.

null 44 Oct 9, 2022
My first Real-Time 3D Game Engine learning project written in Rust.

EyeEngine-Rust FOA, sry for my poor English. What is Eye Engine? Eye Engine is my first Real-Time 3D Game Engine learning project. There are two editi

F-seeeye 4 Jan 5, 2022
Rushes are new ephemeral projects at Hive Helsinki. Wordle is the first in this series with 48 hours time window

Rushes are new ephemeral projects at Hive Helsinki. Wordle is the first in this series with 48 hours time window

Jiri Novotny 1 Feb 24, 2022
A first-time implementation of Conway's Game of Life in Rust: Adventure and Commentary

A Commentary on Life This project documents the process and final result of my first-ever attempt at implementing Conway's Game of Life. I'll be using

Avery R. 2 Feb 25, 2022
Rust SDK for working with RIS-Live real-time BGP data stream.

ris-live-rs Provides parsing functions for RIS-Live real-time BGP message stream JSON data. The main parsing function, parse_ris_live_message converts

BGPKIT 10 Oct 11, 2022
A real-time raytracing engine, with extra Bevy integration

strolle Strolle (from strålspårning) is a real-time raytracing engine written entirely in Rust, running on CPU & GPU: It comes integrated with Bevy, b

Patryk Wychowaniec 72 Jan 1, 2023
Non-Linear Ray Casting

linon Non-Linear Ray Casting References E. Gröller, “Nonlinear Ray Tracing: Visualizing Strange Worlds,” The Visual Computer, vol. 11, no. 5, pp. 263–

Niklas Korz 13 Dec 1, 2022
Implementation of the great book Ray Tracing in One Weekend in Rust.

Ray Tracing in One Weekend (Rust) Implementation of the great book Ray Tracing in One Weekend in Rust. Fun easy way to pick up and learn Rust (was rou

Stanley Su 6 Dec 29, 2021
Ray Tracer written in Rust

Erena A Ray Tracer written in Rust. Erena is based on the Esena project, which is written in Scala. Here is the current rendered image: See The Ray Tr

Melvic Ybanez 11 Dec 7, 2021