First something completely else; I recently got back from No More Sweden 2010, the annual meet-up for Nordic indie developers. This year was less jamming and more awesome presentations & hanging out (discussing game development, indie gossip, etc :) ). Big thanks to Daniel Kaplan and Jens Bergensten for organizing it!
A couple of days ago I stumbled upon legendary demo coder Iñigo Quílez’ site. There I found an article, ‘Rendering Worlds With Two Triangles’, describing the idea of optimizing ray marching (ray tracing done in discrete steps — perfect for scenes where intersections can’t be found analytically) by using distance fields. A distance field supplies the minimum distance to any surface in a scene from any point. A ray can therefore do a look up in the distance field at its position and step at least the returned distance in its direction before a new look up is necessary. The difficulty of course lies in defining a distance field that matches the geometry we want to render. Quílez proposed going the other way around, defining a distance field as a means to model a scene. This pretty much blew my mind!
I decided to implement my own version in Söder Engine (DX10). As opposed to Quílez I wanted to make a scene that was rendered in real time so my screenshots are probably not as exciting as his :) Feel free to download the application and write a better scene though! It’s all defined in the shaders, which can be reloaded by pressing F1.
This method has some amazing properties. For instance, fake (empirical) ambient occlusion and subsurface scattering was a piece of cake to add :)



4 Comments
Very nice and well written source also. Specially compared to all size optimized frameworks out there that use distance fields.
Thanks Joakim! I just checked out Plane9 – lovely stuff!
Lookin’ good! What do you need DistanceToAABB for? Is that axis-aligned bounding box?
Ah, just a box, got it :)
One Trackback
[...] addition: This link covers ray marching for some less fractalian uses. “Hypertexture” by Ken Perlin gives [...]