Example 48 - PBR material package (mk_pbr_material).
← All examples48_pbr
A grid of spheres shaded by the opt-in PBR package, with switchable material presets (SPACE cycles). The package is OFF by default; this example is only built with -DMODKIT_ENABLE_PBR=ON (--pbr). Preset 0 is the metallic (columns) x roughness (rows) calibration chart on a neutral base. The rest are named materials -- gold, copper, plastics, rubber, ... -- using the standard measured LINEAR metal F0 reflectances; each ramps roughness across all 36 spheres (top-left mirror-smooth -> bottom-right rough). One geometry + one material are reused; the base color is set per preset and u_pbrParams (metallic, roughness, dielectricF0, occlusionStrength) is overridden per cell via mk_material_set_vec4. With no IBL environment set, PBR uses analytic lighting only (mk_set_light) -- metals look dim/dark because a metal is "lit" by its reflections and there is no environment yet; image-based lighting (the IBL package) is what makes them shine. Controls: SPACE = next material, drag = orbit, scroll = zoom, ESC = quit.

Runs the WebAssembly build on this page. Click the canvas to give it keyboard focus.
- Number
- 48
- Tags
- Requires
MODKIT_ENABLE_PBR- Source
examples/48_pbr/main.c
Build and run
./scripts/build-linux.sh release --target=48_pbr --run