r/GraphicsProgramming • • Aug 11 '26

Video Editing millions of voxels in a single CPU thread (C++/Vulkan)

579 Upvotes

The dynamic ellipses you see when I drag my mouse are just ray-marched ellipse SDFs that I render as voxels by clamping the ray to the nearest voxel position when it's getting close to the surface. So not a single voxel is stored in memory during this phase.

The storing happens when I release the click. The voxels end up actually committed to the world terrain when the dragging ends, which is still very fast due to the data structure I'm using : a sparse 64-tree , an octree with 64 children per node (so a tetrahexacontree I guess ?) and only non-empty nodes are represented in memory. Which implies:

- Voxels are stored in a single buffer of tree nodes

- I'm not actually storing millions of individual voxels, the inside of the ellipses is probably just few KB of tree leaves.

That buffer containing all the nodes is allocated via virtual memory, I first reserve something like 6 GB of virtual addresses via VirtualAlloc / mmap, and commit addresses progressively to physical memory with VirtualAlloc / mprotect only when I need it.

To achieve that real-time performance, the storing algorithm is quite straightforward :

Starting from the root node of the 64-tree, I evaluate a coverage test between the ellipse and the AABB of the node :
- If fully covered, the node becomes a voxel leaf
- If partially covered, recurse into children and repeat
- otherwise, do nothing and stop

Then I upload the whole thing to the GPU unapologetically (will change eventually).

Everything is rendered with a single real time path tracing compute shader written in Slang. Which means that sharing light data between the SDFs, the voxel world and any data structure is quite simple as long as the rendering of these structures is ray-based (ray-marching, ray-tracing, you get it).

GCC and -O3 are doing a lot of heavy lifting though, in debug mode these ellipses would generate a 0.5s lag spike when releasing the click.

Conversely the unique Slang shader is faster when compiled to spirv with -O0 rather than -O3 somehow lol.


r/GraphicsProgramming • • May 12 '26

My first software ray tracer :D

Post image
579 Upvotes

This was my way of preparing for my upcoming linear algebra class this semester xD

I followed the first part of Gabriel Gambetta's book "Computer Graphics From Scratch" and implemented it using C++ and SDL2. Here's my implementation if anyone wants to check it out.

The renderer itself is very rudimentary and can only trace spheres. Not sure if I want to extend its functionality as I mainly made it so I could learn the math behind software rendering. Still, I'm quite proud of the results (even though the code is not very optimized).

Looking to learn OpenGL next since I've gotten quite interested in graphics programming


r/GraphicsProgramming • • Jun 27 '26

Video Highly realistic cat rendering on WebGPU

576 Upvotes

Really pushing the limits of my GPU.


r/GraphicsProgramming • • Jun 13 '26

My first graphics in C++ and OpenGL

575 Upvotes

Just wanted to be part of the club, I'm a Unity gamedev and wanted to learn the basics of OpenGL creating a rotating pyramid


r/GraphicsProgramming • • Jan 19 '26

268 Million Spheres

572 Upvotes

Working on scaling my renderer for larger scenes.
I've reworked the tracing phase to be more efficient.
This is 268 million unique spheres stress test, no instancing and not procedural.
No signed distance fields yet, that is up next!


r/GraphicsProgramming • • Jan 24 '26

Video Real-time ray-tracing on the terminal using unicode blocks (▗▐ ▖▀▟▌▙)

571 Upvotes

r/GraphicsProgramming • • Aug 31 '26

Source Code Built a path tracer in C++ & CUDA from scratch

Thumbnail
gallery
564 Upvotes

spent the last 4-5 week building Hypertracer, a CPU + CUDA path tracer with progressive sampling further implmneted GPU acceleration, and a real-time fly-camera viewer
built the renderer and viewer from scratch, with 6 scenes currently implemented and 1920×1080 can be rendered at 3000 samples

along with Ray Tracing in One Weekend, The Next Week, and The Rest of Your Life, all three books i completed
it was seriously so much fun :D

main resources i followed:
ray tracing : https://raytracing.github.io, https://pbr-book.org
repo: https://github.com/whoashish115/hypertracer

give it a star ⭐


r/GraphicsProgramming • • Jun 02 '26

Super cheap Crepuscular rays

563 Upvotes

Super simple way to add crepuscular rays

Create a small R8 texture. In my case 64x64 was enough

  1. Fill this texture by reading the depth buffer around where the sun is on the screen. Write 1.0 if you read the depth clear color else 0.0. If pixel offscreen write a 1. Only write in the disc of where the sun would be. (This is the left texture above)

  2. Do a radial blur on this texture. Optionally blend this with the previous frames texture to improve temporal stability. I use 15% of the current frame but this increases bases on camera translation. If the camera is moving fast then it is 100%. (This is the right texture)

  3. In your final post fx shader get the vector from the pixel being shaded to the sunpos and sample the sun blur texture in the circle around the centre. Weight the value read by the length of this vector. Then colorize and add on

For the blur I tried a single 24 tap blur. 2 blurs of 5 taps each and a single blur using texturegrad with anisoX16. They all came to the same perf numbers which are completely dominated by barrier transitions anyway.

Performance

Generation (final rez is irrelevant)
5070 Laptop is 0.001ms
Intel iGPU is 0.012ms

Application to postFX (@ 2560x1440)
5070 Laptop + 0.011ms
Intel iGPU + 0.04ms

Note: I think this is the method that the original crysis used.


r/GraphicsProgramming • • Jan 08 '26

First triangle with a transparent window after moving from unity to C++ and Vulkan

Post image
557 Upvotes

It took way longer than expected, but finally I have something to be proud of


r/GraphicsProgramming • • Jun 03 '19

I built a Cornell Box to display my Utah Teapot

Post image
548 Upvotes

r/GraphicsProgramming • • Jun 10 '25

I'm working on 3D engine for Raspberry Pi Pico 2

543 Upvotes

Hi. It's my first so complex projekt. Engine is for demoscene purposes.

  1. Models are stored in code. I prepared python script to make C code out of obj files

  2. Models can have texture or diffuse color

  3. Curretly I have only point light, but I can change intensity and color

  4. I have texture mapping

  5. Lately I changed flat shading to gouraud

  6. Rotation is using quaternions. They also use lookup tables for sin and cos, but some values seem to be incorrect, but should be easy to fix.

  7. All arithmetics are fixed point numbers based

  8. I implemented zbuffer

  9. To play audio I stream wav file from sd card. It's still not perfect, because card reader are on the same board as display.

Everything is written in C. When I fix major issues, I want to implement high mapa and directional lighting.


r/GraphicsProgramming • • Aug 22 '26

Source Code Real-time fluid & rigid body simulation implemented in WebGPU

535 Upvotes

Hello, I released a real-time fluid & rigid body simulation in WebGPU using Position Based Dynamics (PBD)!

Code & Demo: https://github.com/matsuoka-601/Particles4All

To render the fluid, I use screen-space fluid rendering, which does not require constructing any mesh. Fluid particles are splatted as ellipsoids using anisotropic kernel presented in a paper "Reconstructing Surfaces of Particle-Based Fluids Using Anisotropic Kernels".

The physics is based on a paper "Unified Particle Physics for Real-Time Applications". The most significant feature of this paper is that it treats both fluids and rigid bodies as collections of particles, and performs the simulations using a unified solver.

(Note 1: You will need a very beefy GPU to run the "large" scene in the video (the performance is not very optimized yet, sorry). But "small" scene will run on integrated GPUs.)

(Note 2: I'm getting some reports that the demo does not run on MacBook. I'm currently trying to fix it.)


r/GraphicsProgramming • • May 13 '26

My created my first triangle in OpenGL

Post image
529 Upvotes

Pretty proud of myself :)


r/GraphicsProgramming • • Sep 18 '24

Finally got this working!

Post image
529 Upvotes

r/GraphicsProgramming • • Mar 03 '25

Video Spacetime curvature due to a black hole

523 Upvotes

A visualization of spacetime curvature near a Schwarzchild blackhole. There's still some optimization issue but I am happy with the result.

Shader code: https://www.shadertoy.com/view/3ffSzB


r/GraphicsProgramming • • May 01 '25

🪄🔮✨ Magical Orb 🪄🔮✨

521 Upvotes

r/GraphicsProgramming • • Sep 22 '22

Every night

Post image
519 Upvotes

r/GraphicsProgramming • • Jun 08 '26

Made Minecraft in the Terminal (only java, no extra libs)

Thumbnail
gallery
517 Upvotes

I created a version of Minecraft that runs entirely in command in the terminal.
The entire project is entirely contained in one file, with over 1500 lines of code.
Made with java, no extra libraries.
Supports textures, randomly generated trees, water, and terrain, and block placing/mining.
This is inspired by the Minecraft.c repo.

Github: https://github.com/DaRealNeonCoder/MinecraftInTerminal


r/GraphicsProgramming • • Jun 06 '26

my engine 1 month in, i only have 1 month left

513 Upvotes

r/GraphicsProgramming • • Aug 20 '25

Streamed scene loading

509 Upvotes

I was bored to see a loading bar so I decided to actually make the scene loading streamed so you can see everything being loaded in, I personally find it satisfying


r/GraphicsProgramming • • Jan 02 '25 Galaxy Brain

Want to get started in Graphics Programming? Start Here!

503 Upvotes

First of all, credit goes to u/CorySama and u/Better_Pirate_7823 for most of this, I am mostly just copy-pasting from them.
If all goes well, we can Sticky this for everyone to see.

Courtesy of u/CorySama:
The main thing you need to know is https://fgiesen.wordpress.com/2016/02/05/smart/

Additionally, don't think you have to know everything all the time: https://alextardif.com/LearningGraphics.html

OpenGL is a good API to start with. There's a lot to learn regardless of which API you use. Once you can do an animated character in a scene with lighting, shadows, particles and basic full-screen post processing, you'll know how to proceed forward on your own from there.

https://learnopengl.com/
https://raytracing.github.io/
https://gamemath.com/book/
https://www.gameenginebook.com/
https://realtimerendering.com/
https://google.github.io/filament/Filament.md.html
https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-graphics-pipeline-2011-index/
https://developer.nvidia.com/nsight-graphics
https://renderdoc.org/

And courtesy of u/Better_Pirate_7823:
I think this these videos from Branch Education are a good starting point of how things work.

Then learning how to write software rasterizer, renderer, ray tracer etc. is a good next step.

You might find reading about the graphics pipeline/architecture interesting as well.

Youtube Channels:

  1. Acerola: https://www.youtube.com/@Acerola_t

  2. Sebastian Lague: https://www.youtube.com/@SebastianLague

  3. Freya Holmer: https://www.youtube.com/@acegikmo

  4. Cem Yuksel: https://m.youtube.com/playlist?list=PLplnkTzzqsZS3R5DjmCQsqupu43oS9CFN


r/GraphicsProgramming • • Oct 18 '26

Progress on Software Rendered game in C

502 Upvotes

This is some progress of a free game i have been working. This is fully software rendered on the CPU and OpenGL is only used to render the image. I use multiple threads to render the game at full 1080p. Using SIMD instructions helps a lot to get a decent frame rate. But i am still kinda dissapointed by the performance, i think Michael Abrash's binning technique would improve it, but right now, it is decent. I am getting around 70-140 frames with I5-12400.


r/GraphicsProgramming • • Jul 07 '26

Video My spectral raymarcher rendering a diamond icosahedron

501 Upvotes

Feel free to mess with it here: https://www.shadertoy.com/view/sXjXDd

The super neat thing is that it uses bayer ordered dithering to work all the way down to 1 sample per pixel (1spp) while still simulating 256 different wavelengths of light. This makes it extremely performant.


r/GraphicsProgramming • • Aug 16 '26

Made improvements to my path tracer

Thumbnail
gallery
497 Upvotes
  • Made the project much easier to open up and use for new users (Unity is still required though)

  • Added scene to automatically load objects from Khronos' site, which helps me get assets into the project

  • Fixed issues with lighting that was really darkening most of the scenes, including improved tone mapping and fixes to light clamping that was hiding a lot of caustic details and HDR

  • Fixed issues with inner surface reflections not working

  • Added directional lighting support

  • Added parallax mapping support

  • Added support for Unity terrains, multi-texture splatting with normal map support

Repository located here: https://github.com/nfoste82/GPURayTracing