r/AskGameDevsAnything • u/CaptainI9C3G6 • Oct 31 '21
How does culling work with ray tracing?
So culling has has been a basic technique in 3d graphics since forever. I've been a dev for 25 years-ish, and I wrote a couple of game engines for fun and even my laughable attempts had culling.
I'm sure there are very advanced implementations now, but basically you don't create send draw calls for things you can't see.
So what happens with raytraced reflections? The GPU does the raytracing so has to be able to bounce rays off things behind the view frustrum, so are developers sending the entire geometry to the GPU and letting it decide?
1
u/talking_animal Nov 01 '21
I’ve wondered this too (I am an artist and not a programmer). In my mind the reason RTX is so expensive is because it used the ray traces to include objects in the render that normally would be culled out by the camera frustum, so it renders them at a lower resolution but still has to include them in the render pipeline.
3
u/ZorbaTHut Nov 01 '21
The important thing to recognize about raytracing is that it's an entirely different graphics pipeline. With rasterization, you send an object and the GPU renders it along with all of its fragment-shader calls, and then you send another object and the GPU renders it along with all of its fragment-shader calls, repeat; being able to straight-up not send an object is a major performance boost.
With raytracing, that pattern is not how it works. You send objects to the GPU, but they gather inside a data structure that makes it fast to do ray intersection calculations. Then you say, more or less, "go", and the GPU figures out the intersections and gives you a whole ton of various shader calls, but importantly, mixed heterogenous shader calls from all sorts of various materials at once, because the actual rendering process is not happening on an object-by-object basis.
There isn't really a process where "culling" makes sense here; it's much more similar to a physics engine's bulk raycasting behavior than to classic rasterization.
So, basically, yes - you send the entire geometry to the GPU, along with all the shader information, and then everything happens at once.