3 ms·
This reminds me of Inigo Quilez's work on rendering soft shadows by using distance fields. The main idea is that you represent a 3D object using not triangles,
by cousin_it 11y ago
This reminds me of Inigo Quilez's work on rendering soft shadows by using distance fields.
The main idea is that you represent a 3D object using not triangles, but a function f(x,y,z) stored on the GPU. The function should return the approximate distance from point (x,y,z) to the object in question, so it's zero on the object's surface and negative on the inside.
It's easy to construct such functions for spheres, boxes, etc. [1] It's also easy to define combinators for moving, adding and subtracting different objects, adding rounded corners, etc.
That representation is well suited for raymarching [2], because the value of f(x,y,z) at your current position along the ray can be safely used as the length of the next raymarching step, so you automatically get larger steps when you're far from the object.
It's also well suited for rendering shadows with penumbras, because the minimum value of f(x,y,z) as you march along the ray gives you the distance between the ray and the object [3]. A slight modification of that trick can give you ambient occlusion as well.
[1] http://iquilezles.org/www/articles/distfunctions/distfunctions.htm http://iquilezles.org/www/articles/distfunctions/distfunctio...
[2] http://iquilezles.org/www/material/nvscene2008/rwwtt.pdf http://iquilezles.org/www/material/nvscene2008/rwwtt.pdf
[3] http://iquilezles.org/www/articles/rmshadows/rmshadows.htm http://iquilezles.org/www/articles/rmshadows/rmshadows.htm