5 ms·
Do you know how this ray marching compares to normal ray tracing time complexity wise, with regards to the amount of geometry?
by bryal 6y ago
Do you know how this ray marching compares to normal ray tracing time complexity wise, with regards to the amount of geometry?
- dahart 6y agoOh, that's a super good, but very difficult question to answer in general. SDF ray marching is quite commonly used in the demo scene and on ShaderToy without an acceleration structure (or "BVH" - Bounding Volume Hierarchy), while ray tracing usually has one. It's common for SDF ray marching scenes to have a very limited number of procedural hand-coded primitives, while ray tracing usually has a lot of simple primitives like triangles and spheres that come out of some modeling tool. The Godot engine, however, has a BVH, so their SDF complexity will depend on that. In it's inner loop, SDF ray marching does a point query against the BVH, while ray tracing does a line query. Both will end up traversing along the line (ray) through the BVH. I'd guess that, attempting to compare apples to apples, ray marching has a slightly higher complexity in practice than ray tracing since it takes multiple iterations to reach a surface, where ray tracing (usually) gets there in one step. But there are multiple factors that can offset this complexity difference, because there are some amazing tricks you can play with ray marching to reduce the number of rays, and because ray marching often better utilizes a GPU.
- bryal 6y ago> SDF ray marching does a point query against the BVH Aah, alright. I've written a ray tracer that uses an (L)BVH before, so I'm familiar with how it works for ray tracing. What I couldn't figure out was how you'd use an acceleration structure for ray marching. Now that you spelled it out though, I suddenly think I get exactly how it would work. > ... ray marching has a slightly higher complexity in practice than ray tracing since it takes multiple iterations ... Great reply, thanks! It made a lot of sense. > ... there are some amazing tricks you can play with ray marching to reduce the number of rays, and because ray marching often better utilizes a GPU. Interesting. Now I'm gettin quite interested in exploring ray marching more.
- dahart 6y agoIt's worth exploring ray marching. I still need to learn more about how Godot is using ray marching, but FWIW there is a lot to learn on ShaderToy and IQ's articles about the basic techniques. https://www.iquilezles.org/www/index.htm https://www.iquilezles.org/www/index.htm https://www.shadertoy.com/view/Xds3zN https://www.shadertoy.com/view/Xds3zN The Media Molecule team did a pretty amazing job integrating ray marching into a game pipeline and presented it at Siggraph http://advances.realtimerendering.com/s2015/AlexEvans_SIGGRAPH-2015-sml.pdf http://advances.realtimerendering.com/s2015/AlexEvans_SIGGRA...