// This is a sphere
length(p) - size;
There are no polygons, just surfaces described with math. You can do operations with them, like addition, subtraction, deformation quite easily, which is also much more complex with polygon based 3D models.https://iquilezles.untergrund.net/www/articles/distfunctions...
The problem that classic primitive raytracing has had was that it never scaled well for complex primitives since you needed to solve the equations that could have many intersection points for a ray.
A plane (and triangle) has 0 or 1 intersection point, this is quite trivial to solve.
Insert the ray equation ( x'=x0+dxt, y'=y0+dyt, z'=z0+dzt) into the plane equation ( Ax+By+Cz = D) and solve for [t] that is the intersection distance as seen from the ray origin [x0,y0,z0] in delta units.
A sphere has 0, 1 or 2 intersections. You again insert a ray equation into a sphere equations and after solving you end up with a classic second degree equation with a square root.
A donut can have 0, 1, 2, 3 or 4 intersections.
All these are fairly trivial shapes, but you see how the code complexity goes up very quickly even here with more intersection cases to handle even for these fairly simple shapes.
Raytracing was used with triangle-meshes (with acceleration structures) in offline renderers since it still allowed for better lighting models with free-er ray sampling than normal rendering (and now RTX has put this ability in hardware for triangle soups)
Now, for something simple as a sphere and plane, raytracing is faster than raymarching.
The difference however is that since distance field raymarching only relies on a single value (the distance to the nearest surface) and SDF functions are trivially composable there really isn't any bounds on how complex shapes you can render with the technique, as long as the combination and core distance functions are at least somewhat conservatively "correct" in producing a single distance value (raymarching is can be forgiving for inaccuracies as long as they don't over-shoot).
So while raymarching isn't really super-fast, it's fast enough that most GPU's eats them up, since it can all be run in parallel without almost any data bandwidth. (and the fact that raymarching often converges on "big" surfaces within a few iterations only needing more iteration in areas like borders that only take a small bit of the screen estate)
Other than that you can actually re-use many simpler SDF's to work as bounding spheres,etc. For example I did a kind of skinned character rendering that kinda started turning expensive and a simple way to accelerate it was to first do a sphere calculation that bounded it, if the sphere calc was producing a large enough value it was output directly instead of the "detail" value of the actual character. Now for a GPU that isn't ideal if one of the "threads" enters the character, but I think most GPU's do triangles one-tile-at-a-time so these threads will most of the time have converging calculations within each tile.
Out of computer graphics, I have used them a lot for modeling the evolution of curves and surfaces in a topologically-oblivious way. The terminology is slightly different (they go by silly names like "implicit snakes"), but it is the same thing. If you have ever used an "adaptive select" or "intelligent scissors" tool of a drawing program, it was probably implemented using this technique.
For a nonstandard use of the idea, see font rendering on the GPU with signed distance field textures:
https://aras-p.info/blog/2017/02/15/Font-Rendering-is-Gettin...
from other replies I think the point here is there are no "vertices", i.e. no mesh geometry
I don't use this a work - it's just an approach that I've had some success with at home. On my machine, complex fragment shaders are always slow - so maybe this kind of sdf-based approach works in realtime for other people.
Can someone help me understand why SDF-only techniques are valuable (aside from being interesting in their own right)?
I know very little gfx but so far I mostly saw SDFs used for accomplishing stuff in fragment shader that would otherwise be done with geometry, kind of as a workaround for limitation of shadertoy environment