-
-
Notifications
You must be signed in to change notification settings - Fork 26
Labels
Labels deals with displaying text strings in a 3D application. Labels can be used to display information as a 2D overlay on top of the rendered 3D scene, or as 3D strings on 3D surfaces. Strings are displayed as a sequence of bitmapped character images. The vu engine helps by generating a displayable image from string characters.
Labels are created in the vu engine using font TTF files and
the Entity.AddLabel method.
AddLabel is a helper method that associates a normal string shader
with a bitmapped font image and a text font layout file.
For example:
// load the font shader and font TTF file, indicating the font size.
eng.ImportAssets("label.shd", "20:lucon.ttf")
// "fnt:lucon20" - font mapping asset generated from 20:lucon.ttf
// "tex:color:lucon20" - texture atlas asset generated from 20:lucon.ttf
// create the model
scene2D := eng.AddScene(vu.Scene2D)
name = scene2D.AddLabel("name", 0, "shd:label", "fnt:lucon20", "tex:color:lucon20")
^ ^ ^ ^
| | | └ font texture atlas.
| | └ bitmap font file.
| └ label shader
└ the label string.The string in this case is being displayed as part of a 2D scene so the z position is always 0.
Signed distance fields help to display 3D strings, like lettering on walls. Signed distance fields is a Shader based algorithm combined with specially generated font bit-mapped Texture Atlas. SDF mitigates the effects of pixelization when 3D fonts are viewed close-up.
Dealing with SDF strings instead of regular strings means:
- Using a a SDF aware shader.
- Creating and using corresponding SDF bitmapped font texture atlases.
FUTURE: have vu generate SDF fonts from true type font files.