3 ms·
Another technique related to voxels is the "Signed Distance Field" (using a data Field or procedural Function). Signed Distance Function: https://en.wikipedia.
by DonHopkins 8y ago
Another technique related to voxels is the "Signed Distance Field" (using a data Field or procedural Function).
Signed Distance Function:
https://en.wikipedia.org/wiki/Signed_distance_function https://en.wikipedia.org/wiki/Signed_distance_function
2D Signed Distance Fields are used for rendering fonts and other shapes defined by a texture whose signed pixels (-128..128) specify how far each is from the border (+ is outside, 0 is on the border, - is inside). They scale beautifully because you can smoothly interpolate between samples.
Drawing Text with Signed Distance Fields in Mapbox GL:
https://blog.mapbox.com/drawing-text-with-signed-distance-fields-in-mapbox-gl-b0933af6f817 https://blog.mapbox.com/drawing-text-with-signed-distance-fi...
TextMesh Pro - Font Asset Creation Process:
https://www.youtube.com/watch?v=eXhfygRgIVY https://www.youtube.com/watch?v=eXhfygRgIVY
You can convert them to piecewise outline contours (like an iso-map slicing at many different elevations) with the Marching Squares algorithm, but it's much more efficient to render them directly pixel-by-pixel with a shader.
Marching Squares:
https://en.wikipedia.org/wiki/Marching_squares https://en.wikipedia.org/wiki/Marching_squares
Signed Distance Fields are excellent for shaders efficiently antialiasing and drawing effects like outlines, drop shadows, embossed and beveled edges, glows, multi texture mapping, bump mapping, etc). The shader can quickly determine exactly how far away each pixel is from the outline, and blend the appropriate effects together for that pixel, so you get precise anti-aliasing, outlines, drop shadows, etc, practically for free! (And literally for free, now that Unity gives TextMesh Pro away for free.)
TextMesh Pro - Unite 14 Demo:
https://www.youtube.com/watch?v=q3ROZmdu65o https://www.youtube.com/watch?v=q3ROZmdu65o
3D Signed Distance Fields are used for rendering volumes with the Marching Cubes and Tetrahedra algorithms (which are nice for users continuously carving and sculpting with tools, like Astroneer).
Astroneer:
https://astroneer.space/ https://astroneer.space/
Astroneer - Digging to the Center of the Planet:
https://www.youtube.com/watch?v=C3zxBhPzxYU https://www.youtube.com/watch?v=C3zxBhPzxYU
That also scales and handles different levels of detail nicely because you can interpolate between samples -- it creates smooth polygon meshes with interpolated normals, not harsh cubes with pointy corners like Minecraft.
Marching Cubes:
https://en.wikipedia.org/wiki/Marching_cubes https://en.wikipedia.org/wiki/Marching_cubes
Marching Tetrahedra:
https://en.wikipedia.org/wiki/Marching_tetrahedra https://en.wikipedia.org/wiki/Marching_tetrahedra
Fast Marching Method:
https://en.wikipedia.org/wiki/Fast_marching_method https://en.wikipedia.org/wiki/Fast_marching_method
Fast Sweeping Method:
https://en.wikipedia.org/wiki/Fast_sweeping_method https://en.wikipedia.org/wiki/Fast_sweeping_method
Level-Set Method:
https://en.wikipedia.org/wiki/Level-set_method https://en.wikipedia.org/wiki/Level-set_method
Shaders can't render 3D Signed Distance Fields as directly and efficiently as 2D (unless you're rendering to 3D volumetric textures). But you can still implement Marching Cubes on the GPU, using compute shaders (or abusing 2D shaders).
Marching Cubes on the GPU for Unity3D:
https://github.com/Scrawk/Marching-Cubes-On-The-GPU https://github.com/Scrawk/Marching-Cubes-On-The-GPU