Skip to content

Material Textures

App: apps/material_textures/

Demonstrates script-assigned PBR material textures (engine PLM-021 / ADR 0055). A UV-mapped cube is built entirely from Wren with Graphics.newMesh, then its full six-map PBR material set is assigned from script and drawn with a reference shader that samples all six maps with derivative-reconstructed normal mapping.

Terminal window
% ./plume3d material_textures

You should see a slowly turning cube: the checker base color, normal-map bumps catching a point light, a metallic-vs-dielectric split and a rough-to-smooth gradient (the metallic / roughness maps), darkened grout in the crevices (ambient occlusion), and thin emissive accent lines that glow independent of the light.

  • Builds a UV cube ([x,y,z, nx,ny,nz, r,g,b,a, u,v] vertices) with Graphics.newMesh(...) and adds a point light so the material response is lit.

  • Assigns all six Mesh material maps from script:

    cube.setBaseColorTexture(Texture.load("textures/checker.png"))
    cube.setMetallicTexture(Texture.load("textures/metallic.png"))
    cube.setRoughnessTexture(Texture.load("textures/roughness.png"))
    cube.setNormalTexture(Texture.load("textures/normal.png"))
    cube.setAoTexture(Texture.load("textures/ao.png"))
    cube.setEmissiveTexture(Texture.load("textures/emissive.png"))
  • Draws the cube with a Y-rotation model matrix via Graphics.drawMesh(cube, shader, model).

The engine binds the six maps as a per-material descriptor set (set 1, bindings 1..6) behind every draw; an unassigned map falls back to a no-op default. See the shader binding contract — the reference shader keeps to the set-1 samplers + lighting and never touches the set-0 shadow array, so it compiles on macOS/MoltenVK without shadow mapping enabled.