Materials
Materials control how geometry appears when rendered by a renderTOP.
Material Types
- constantMAT — flat color, no lighting. Simplest, cheapest. Good for debug, UI, flat graphics
- phongMAT — classic diffuse+specular lighting. Maps for diffuse, specular, normal, bump, emit
- pbrMAT — physically based rendering. Metallic/roughness workflow, environment maps. Requires environmentlightCOMP with map TOP (see PBR Setup below)
- pointspriteMAT — renders points as camera-facing quads with configurable size. Essential for particle rendering
- glslMAT — custom GLSL vertex/pixel shaders. Full control. Load
td-glsl-shadersskill for shader code - lineMAT — renders line primitives (proximityPOP/linePOP graphs, edges). Per-line color, pixel or world width
- wirePOP — wireframe rendering via material wireframe toggle
When to Use What
- Flat particles/points → pointspriteMAT (set
pointsize, optionalcolormaptexture) - Lit geometry → pbrMAT (default choice) or phongMAT
- Unlit solid color → constantMAT
- Custom shading → glslMAT
- Debug/wireframe → constantMAT with
wireframe=true
pointspriteMAT
Renders each point as a camera-facing square. Without this, points render as single pixels.
pointsize— sprite size in pixels (default 1)colormap— optional TOP texture mapped onto each spritealpha— global opacity multiplierblending— enable for transparencysizingmodel—constant/attenuateorattrib. Attenuate scales with distance
Placement
- Inside geometryCOMP — reference as
./mat_name. Material lives with its geometry - Sibling level — reference by name only (
mat_name). Shared across geometryCOMPs - Naming:
mattype_purpose(e.g.pointsprite_particle,pbr_surface,constant_debug) - Always use
get_helpbefore setting parameters — par names vary between MAT types
PBR Setup
pbrMAT renders completely black without an environment light:
- Create
environmentlightCOMPinside the geometryCOMP (or sibling) - Create
moviefileinTOPwithfile=app.samplesFolder + '/Map/CloudyOcean_2Kx1K_8bit.tif' - Set environmentlightCOMP
envmapto the moviefileinTOP - POP geometry using pbrMAT also needs
normalPOPwithtang=alwayscompute— PBR lighting requires tangent vectors
glslMAT Setup
From scratch — creating a glslMAT auto-docks three DATs: <name>_vertex, <name>_pixel, <name>_info.
- Delete
_pixeldocked DAT - Rename
_vertex→<name>_shader(stays docked to MAT) - Write combined shader with
#ifdef TD_VERTEX_SHADER/#ifdef TD_PIXEL_SHADERguards - Set both
vdatandpdatto the renamed DAT - Keep
_infodocked for compile error visibility - Assign via
./mat_namewhen inside a geometryCOMP
From pbrMAT/phongMAT — pulse outputshader on the existing material. This creates a glslMAT with all built-in uniforms and shader code pre-populated in separate vertex/pixel DATs. Better starting point when extending PBR-style materials — modify the generated shaders instead of writing from scratch.
Layout follows the GLSL DAT sandwich pattern (see td-node-layout skill). Load td-glsl-shaders skill for shader code, uniforms, and templates.
Pitfalls
- Points invisible — using constantMAT/pbrMAT for point-only geometry. Use pointspriteMAT
- Wrong path prefix —
./means child, no prefix means sibling. Match placement to reference - Blending off — transparent materials need
blending=trueon the MAT - pbrMAT renders black — missing environmentlightCOMP with an environment map TOP. Always include one
- PBR on POPs missing tangents — normalPOP
tangmust bealwayscompute, otherwise lighting fails - pbrMAT
metallicdefaults to 1 — must explicitly setmetallic=0for non-metallic surfaces, otherwise geometry looks like chrome - pbrMAT reads vertex Tex, not point Tex — glslPOP writes point attributes, but pbrMAT samples
basecolormapfrom vertex Tex coords. UseattributeconvertPOP(convertop=pointtovert) to convert. Seetd-pop-familyskill - glslMAT on POPs:
Cd/Nsilent failure — referencingCdorNas vertex attributes silently kills rendering (geometry vanishes, no errors). UseTDPointColor()for vertex color, derive normals viadFdx/dFdy(worldPos)in fragment shader - lineMAT per-line color —
linecoloratt='Color'reads per-primitiveColor(RGBA incl alpha). Without it, lines use flatcolorr/g/b - lineMAT width vanishes under normalized camera —
widthaffectedbyfov=ONscales width with orthowidth; normalizing the cam (orthowidth 1920→1.0) makes lines sub-pixel/invisible. Fixed-resolution output:widthaffectedbyfov=OFF+ pixel widths


