Standard Text Rasterization
— Raster all glyphs to texture with
antialiasing at all required sizes
— Render quads with texture coordinates
pointing into the atlas
Has to render glyph for every size! This
makes pinch-zooming and text in 3D
worlds slow or blurry.
Slide 6
Slide 6 text
Signed Distance Fields (SDFs)
— The distance to the nearest point on the object's boundary
— Negative on the inside of the object
Slide 7
Slide 7 text
Rendering Text with SDFs
— Apply a smooth step function in a shader
— Can add outline/glow to text by modifying mapping
— Same texture can look good at a variety of sizes
Slide 8
Slide 8 text
Text in 3D worlds
— Size of text on screen can change rapidly, poor fit for glyph atlases
— Detailed in a 2007 paper by Chris Green at Valve
Slide 9
Slide 9 text
Problem: Rounded Corners
— If text is rendered much bigger than SDF texture, corners get rounded
— Solution: fancy tricks with multiple distance fields
— The msdfgen project on Github can do this for you
Slide 10
Slide 10 text
3D SDFs
Slide 11
Slide 11 text
Ray Marching Distance Fields
— Allows you to quickly ray trace distance
fields
— Fast enough to run in real time on a
GPU fragment shader
— Step as far as the distance field tells
you is safe
— Can compute normals using numerical
slope
Slide 12
Slide 12 text
No content
Slide 13
Slide 13 text
ClayBook: What did you just see?
— World stored as a signed distance field in 586MB 3D SDF texture
— Fluid simulation done on GPU produces SDF every frame
— Shape morphing done simply by linearly interpolating distance fields
— Tracing cones through distance field for antialiasing and soft shadows
— Use distance field information to approximate ambient occlusion
Slide 14
Slide 14 text
Modeling
— Can use functions to calculate distance
field as required
— Inigo Quilez has a handy page with
tons of these formulas
— Unlike a 3D texture, doesn't take tons
of space and can be evaluated
accurately at any point
Slide 15
Slide 15 text
Constructive Solid Geometry
— Really easy to combine primitives into
models
— Just use math: min, max
Slide 16
Slide 16 text
SDF only fanciness
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
3D Fractals!
— People have figured out how to use
derivatives of Mandelbrot-style
iteration fractals as distance
estimators.
— Most famous are the Mandelbulb and
Mandelbox