Uploaded July 2021 | Updated September 2026, 1 week ago
I wrote this real time OpenCL raytracer in one week from scratch and without any external libraries.
Timestamps
0:00 Intro
0:02 1 Sphere
0:29 64 Spheres
1:34 Triangles - reflection
2:23 Triangles - reflection+refraction
4:10 How it works
4:39 Outro
This project was first inspired by this awesome video from the YouTuber NamePointer: youtu.be/lKIytgt3KXM
It is surprisingly easy: From the camera, shoot a ray through every pixel. Reflect the ray off the first surfaces in its way, reflect the reflection 2 more times. Finaly when the reflected ray hits the skybox, mix all the colors to paint the original pixel with.
The GPU does this for all 2 Million pixels on the screen in parallel.
I implemented:
- ray-sphere intersection
- ray-triangle intersection (Möller-Trumbore algorithm)
- reflection as well as refraction with Snell's law
- hybrid rasterize-raytrace approach: First rasterize triangles and instead of the pixel color save their IDs in the bitmap. Then the raytrace kernel looks up the ID to immediately get the first intersecting triangle. This way the first intersection and reflection are basically free, so the shiny Stanford bunny with 70k triangles runs at 200+fps.
Because I wrote the raytracer in OpenCL, it runs on any OpenCL capable device (GPUs, CPUs, even my Samsung phone). No proprietary RTX hardware required.
Music: Unfound - Promenade
I wrote this real time OpenCL raytracer in one week from scratch and without any external libraries.
Timestamps
0:00 Intro
0:02 1 Sphere
0:29 64 Spheres
1:34 Triangles - reflection
2:23 Triangles - reflection+refraction
4:10 How it works
4:39 Outro
This project was first inspired by this awesome video from the YouTuber NamePointer: youtu.be/lKIytgt3KXM
It is surprisingly easy: From the camera, shoot a ray through every pixel. Reflect the ray off the first surfaces in its way, reflect the reflection 2 more times. Finaly when the reflected ray hits the skybox, mix all the colors to paint the original pixel with.
The GPU does this for all 2 Million pixels on the screen in parallel.
I implemented:
- ray-sphere intersection
- ray-triangle intersection (Möller-Trumbore algorithm)
- reflection as well as refraction with Snell's law
- hybrid rasterize-raytrace approach: First rasterize triangles and instead of the pixel color save their IDs in the bitmap. Then the raytrace kernel looks up the ID to immediately get the first intersecting triangle. This way the first intersection and reflection are basically free, so the shiny Stanford bunny with 70k triangles runs at 200+fps.
Because I wrote the raytracer in OpenCL, it runs on any OpenCL capable device (GPUs, CPUs, even my Samsung phone). No proprietary RTX hardware required.
Music: Unfound - Promenade

![PhysX3D [GRAVITY SIMULATION] Sonnensystem
Hier zu sehen ist unser Sonnensystem mit allen größeren Monden und Asteroiden mit einem Durchmesser über 160km. Die Daten aller Objekte stammen aus der JPL-Datenbank:
http://ssd.jpl.nasa.gov/horizons.cgi
Das ganze Programm inklusive der Grafikausgabe ist in Java ausschließlich unter Verwendung der Standardbibliotheken geschrieben.
Auch wenn es so aussieht, als würden sich die Planeten auf Keplerbahnen bewegen, richten sich die Bahnen nach den Planeten. Denn die Berechnung im Hintergrund ist das n-Körper-Problem; jedes Objekt beeinflusst jedes andere.
Ich habe das Bildflackern (zu sehen im letzten Video) behoben, indem alles zunächst auf ein BufferedImage gezeichnet wird, das dann auf den Bildschirm geworfen wird. Dadurch ist die Bildrate auch noch wesentlich flüssiger.
Mehr Informationen auf: http://www.projectphysx.de
Song: CMA - Youre Not Alone PhysX3D [GRAVITY SIMULATION] Sonnensystem](https://i.ytimg.com/vi/f0hyr041gKU/mqdefault.jpg)






![PhysX3D [GRAVITY SIMULATION] 5k body galaxy simulated in real time
PhysX3D got upgrades. I changed the square root implementation to the fast inverse square root algorithm provided by the aparapi Kernel. With this, y=1/sqrt(x) is calculated as fast as a multuplication, resulting in 7.2x overall performance increase compared to the old square root implementation.
GPU acceleration is now about 50x faster than CPU multithreading.
A galaxy containing 5k bodies is simulated on a 1.54Tflops notebook GPU (Nvidia GeForce GTX 960M). The GPU achieves 124 calculation steps per second using Runge Kutta 4th order integration in 3D space. Everything was simulated in real time.
In other words, the GPU calculates roughly 3.5 billion particle interactions every second.
More information at: http://www.projectphysx.de
Music: Puddle of Infinity - Open Sea Morning PhysX3D [GRAVITY SIMULATION] 5k body galaxy simulated in real time](https://i.ytimg.com/vi/j4kejlWBVwA/mqdefault.jpg)
![PhysX3D [GRAVITY SIMULATION] Euler vs. RK4 / Sonnensystem im Jahr 3016
Das Einschrittverfahren Runge-Kutta-4 (RK4) ist um Größenordnungen genauer als das einfachere eulersche Polygonzugverfahren. RK4 erlaubt es, auch bei einer hohen Körperanzahl die Simulationsgeschwindigkeit ohne ohne größere Rechenfehler sehr weit hoch zu schrauben.
Mehr Informationen auf: http://www.projectphysx.de
Musik:
Hans Zimmer - Stay (Interstellar Soundtrack)
Hans Zimmer - Day One(Interstellar Soundtrack) PhysX3D [GRAVITY SIMULATION] Euler vs. RK4 / Sonnensystem im Jahr 3016](https://i.ytimg.com/vi/jr-3WIY9Fmo/mqdefault.jpg)
![SoundFFT [AUDIO SPECTRUM ANALYZER] Music Demo
SoundFFT is a fast and accurate spectrum analyzer for live audio signals. It performs a fast Fourier transform (FFT) on the live input signal coming from the computers main microphone. The highest peak is being detected and its center is being calculated to further increase resolution.
Java can only input an audio signal from an audio source like a microphone. So in order to get the audio stream from the computers main speakers, you have to use some kind of workaround. I found the software Virtual Audio Cable to fulfill exactly this purpose.
This demo shows how SoundFFT works with Music.
Interestingly, the laws of physics prevent a more accurate frequency resolution without the spectrum being both more delayed and averaged. The longer the buffer is for the fast Fourier transform, the more accurate the frequency resolution will be and vice versa.
Nevertheless, it is fascinating to be able to see exactly what you hear. Also keep in mind that the human brain automatically Fourier transforms the incoming sound (what you hear is the pitch and not the wave) without you having to waste a single thought about it.
Free download and more information at http://www.projectphysx.de
Music: DROELOE feat. Belle Doron - In Time SoundFFT [AUDIO SPECTRUM ANALYZER] Music Demo](https://i.ytimg.com/vi/jwZk7DbF3P8/mqdefault.jpg)