@null3d/engine 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wasm/single/null3d.js +10 -8
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +10 -8
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +96 -24
- package/docs/api/assets.md +99 -29
- package/docs/api/cameras.md +38 -7
- package/docs/api/controls.md +47 -23
- package/docs/api/debug.md +105 -35
- package/docs/api/engine.md +108 -32
- package/docs/api/feature-draws.md +21 -15
- package/docs/api/feature-effects.md +8 -8
- package/docs/api/feature-instances.md +68 -17
- package/docs/api/features.md +68 -37
- package/docs/api/geometry.md +83 -14
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +92 -50
- package/docs/api/input.md +22 -9
- package/docs/api/lights.md +67 -16
- package/docs/api/lines.md +38 -13
- package/docs/api/materials.md +187 -59
- package/docs/api/math.md +6 -6
- package/docs/api/objects.md +40 -15
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +36 -11
- package/docs/api/points.md +18 -8
- package/docs/api/post.md +57 -23
- package/docs/api/quality.md +36 -16
- package/docs/api/raycast.md +57 -24
- package/docs/api/reference/animation.md +1 -2
- package/docs/api/reference/assets.md +7 -4
- package/docs/api/reference/cameras.md +3 -2
- package/docs/api/reference/controls.md +59 -2
- package/docs/api/reference/debug.md +58 -6
- package/docs/api/reference/engine.md +40 -10
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +132 -21
- package/docs/api/reference/grass.md +62 -2
- package/docs/api/reference/impostors.md +120 -16
- package/docs/api/reference/input.md +1 -2
- package/docs/api/reference/lights.md +4 -3
- package/docs/api/reference/lines.md +3 -4
- package/docs/api/reference/materials.md +7 -6
- package/docs/api/reference/math.md +13 -2
- package/docs/api/reference/objects.md +2 -3
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +2 -3
- package/docs/api/reference/post.md +4 -3
- package/docs/api/reference/quality.md +1 -2
- package/docs/api/reference/raycast.md +1 -2
- package/docs/api/reference/render.md +4 -3
- package/docs/api/reference/scene.md +24 -5
- package/docs/api/reference/sketch.md +11 -11
- package/docs/api/reference/sound.md +33 -2
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +2 -3
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +26 -5
- package/docs/api/reference/textures.md +1 -2
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +10 -7
- package/docs/api/reference/vertex-draws.md +2 -3
- package/docs/api/reference/water.md +78 -5
- package/docs/api/reference/wind.md +15 -2
- package/docs/api/render.md +67 -25
- package/docs/api/scene.md +129 -36
- package/docs/api/sketch.md +45 -19
- package/docs/api/sound.md +48 -12
- package/docs/api/splats.md +42 -15
- package/docs/api/sprites.md +8 -6
- package/docs/api/tasks.md +31 -22
- package/docs/api/terrain.md +44 -12
- package/docs/api/textures.md +61 -12
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +18 -10
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +111 -67
- package/docs/api/wind.md +61 -15
- package/docs/cli/null3d.md +90 -15
- package/docs/concepts/architecture.md +69 -23
- package/docs/concepts/assets.md +57 -16
- package/docs/concepts/backends.md +68 -24
- package/docs/concepts/color-management.md +42 -13
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +72 -23
- package/docs/concepts/large-worlds.md +17 -7
- package/docs/concepts/lighting.md +117 -44
- package/docs/concepts/lod.md +128 -33
- package/docs/concepts/materials.md +43 -12
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +77 -14
- package/docs/concepts/quality-preset-tables.md +3 -2
- package/docs/concepts/quality-presets.md +122 -39
- package/docs/concepts/render-graph.md +56 -21
- package/docs/concepts/render-layers.md +9 -5
- package/docs/concepts/shadows.md +96 -25
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +163 -119
- package/docs/data/threejs-mapping.json +301 -340
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +11 -3
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +23 -6
- package/docs/errors/E1308.md +31 -0
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +11 -3
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +53 -29
- package/docs/getting-started/cdn.md +15 -9
- package/docs/getting-started/first-scene.md +20 -12
- package/docs/getting-started/hosting.md +113 -63
- package/docs/getting-started/install.md +39 -24
- package/docs/getting-started/network-use.md +31 -21
- package/docs/getting-started/project-structure.md +20 -8
- package/docs/getting-started/third-party-notices.md +6 -10
- package/docs/guides/accessibility.md +4 -4
- package/docs/guides/add-ons.md +83 -13
- package/docs/guides/agents.md +13 -14
- package/docs/guides/assets-pipeline.md +294 -72
- package/docs/guides/audio.md +17 -15
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +37 -31
- package/docs/guides/content-pages.md +86 -29
- package/docs/guides/custom-passes.md +59 -17
- package/docs/guides/custom-shaders.md +54 -37
- package/docs/guides/debugging.md +31 -41
- package/docs/guides/deploying.md +10 -27
- package/docs/guides/deterministic-simulation.md +23 -16
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +74 -30
- package/docs/guides/multiple-views.md +22 -11
- package/docs/guides/performance.md +188 -37
- package/docs/guides/phones.md +71 -19
- package/docs/guides/physics.md +6 -10
- package/docs/guides/screens.md +41 -29
- package/docs/guides/start-time.md +126 -85
- package/docs/guides/testing.md +137 -98
- package/docs/guides/ui-overlays.md +17 -12
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +14 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -212
- package/docs/porting/react-three-fiber.md +2 -6
- package/docs/porting/threejs-loop-and-threads.md +1 -5
- package/docs/porting/threejs-mapping.md +1248 -234
- package/docs/porting/threejs-materials.md +10 -5
- package/docs/porting/threejs-overview.md +26 -6
- package/docs/porting/threejs-postprocessing.md +2 -6
- package/docs/porting/threejs-shaders.md +16 -14
- package/docs/porting/threejs-unsupported.md +6 -6
- package/docs/porting/verification.md +0 -4
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +9 -6
- package/docs/shaders/surface-functions.md +51 -16
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/debug.d.ts +2 -2
- package/lib/debug/draw.d.ts +2 -2
- package/lib/debug/draw.js +8 -4
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +21 -6
- package/lib/debug/stats-panel.js +80 -13
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +116 -105
- package/lib/errors/engine-error.js +1 -1
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +19 -18
- package/lib/generated/shader-permutations.d.ts +6 -0
- package/lib/generated/shader-permutations.js +6 -0
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/programs.js +1 -1
- package/lib/gpu/webgpu/pipelines.js +13 -13
- package/lib/index.d.ts +1 -1
- package/lib/page/capabilities.d.ts +1 -1
- package/lib/page/engine.d.ts +29 -7
- package/lib/page/engine.js +79 -7
- package/lib/page/label-loop.js +9 -4
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +6 -4
- package/lib/page/switches.js +20 -4
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/fake-call-values.js +2 -2
- package/lib/scene/frame-cameras.d.ts +16 -4
- package/lib/scene/frame-cameras.js +28 -10
- package/lib/scene/gltf.d.ts +1 -1
- package/lib/scene/level-rule.d.ts +6 -5
- package/lib/scene/level-rule.js +2 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/post.d.ts +3 -2
- package/lib/scene/resources.d.ts +15 -9
- package/lib/scene/scene.d.ts +18 -2
- package/lib/scene/scene.js +47 -5
- package/lib/scene/time-of-day.d.ts +10 -5
- package/lib/scene/time-of-day.js +11 -7
- package/lib/shader-artifact.json +1 -1
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/permutation-words.d.ts +8 -0
- package/lib/shared/permutation-words.js +14 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/tier.d.ts +9 -0
- package/lib/shared/tier.js +4 -1
- package/lib/shared/version.d.ts +1 -1
- package/lib/shared/version.js +1 -1
- package/lib/sketch/define-sketch.d.ts +16 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/runner.d.ts +4 -0
- package/lib/sketch/runner.js +5 -0
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/protocol.d.ts +10 -0
- package/lib/workers/render-worker.js +4 -1
- package/lib/workers/sketch-worker.js +4 -1
- package/package.json +1 -1
package/docs/api/materials.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/materials
|
|
3
3
|
title: Materials
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.1"
|
|
6
4
|
summary: "standard, unlit, shader, shadowCatcher; every option."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Materials
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions. `materials.shader` takes no standard texture maps. It takes up to 6 textures of its own.
|
|
12
|
-
|
|
13
9
|
A material sets how the surfaces of the objects that use it look. `materials.standard` makes a lit material, and `materials.unlit` makes one that ignores lights. Create materials in the setup, and share each one between the objects that look alike.
|
|
14
10
|
|
|
15
11
|
```ts
|
|
@@ -64,6 +60,10 @@ Put the catcher a little above the surface it lies on, so its shadows show over
|
|
|
64
60
|
|
|
65
61
|
## Standard values
|
|
66
62
|
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+
Roughness and metalness.
|
|
66
|
+
|
|
67
67
|
| Option | Range | Default | What it does |
|
|
68
68
|
| --- | --- | --- | --- |
|
|
69
69
|
| `color` | A [color](#color) | White | The base color: the color of diffuse light, and of a metal's reflections |
|
|
@@ -73,10 +73,10 @@ Put the catcher a little above the surface it lies on, so its shadows show over
|
|
|
73
73
|
| `roughness` | 0 to 1 | 1 | 0 is a mirror finish with a small, sharp highlight, and 1 is fully matte |
|
|
74
74
|
| `emissive` | An sRGB color | Black | Light that the surface gives off itself, whatever the lights |
|
|
75
75
|
| `emissiveIntensity` | 0 or more | 1 | The factor of the emissive color |
|
|
76
|
-
| `normalScale` | Two numbers | `[1, 1]` | How strongly the normal map bends normals along u and v |
|
|
77
|
-
| `bumpScale` | A number | 1 | How strongly the bump map bends normals. Negative values turn bumps into dents |
|
|
78
|
-
| `displacementScale` | A number | 1 | How far the displacement map's white moves a vertex, in the mesh's units |
|
|
79
|
-
| `displacementBias` | A number | 0 | How far the displacement map moves every vertex, added to its height's share |
|
|
76
|
+
| `normalScale` | Two finite numbers | `[1, 1]` | How strongly the normal map bends normals along u and v |
|
|
77
|
+
| `bumpScale` | A finite number | 1 | How strongly the bump map bends normals. Negative values turn bumps into dents |
|
|
78
|
+
| `displacementScale` | A finite number | 1 | How far the displacement map's white moves a vertex, in the mesh's units |
|
|
79
|
+
| `displacementBias` | A finite number | 0 | How far the displacement map moves every vertex, added to its height's share |
|
|
80
80
|
| `aoMapIntensity` | 0 to 1 | 1 | How much the occlusion map darkens ambient light |
|
|
81
81
|
| `lightMapIntensity` | 0 or more | 1 | The factor of the light map's light |
|
|
82
82
|
| `lightMapOffset` | Two numbers | `[0, 0]` | Where the light map's texture coordinates start. It is fixed when the material is created |
|
|
@@ -96,7 +96,7 @@ Put the catcher a little above the surface it lies on, so its shadows show over
|
|
|
96
96
|
| `subsurfaceColor` | A [color](#color) | White | Each color channel's share of `subsurfaceRadius` |
|
|
97
97
|
| `clearcoat` | 0 to 1 | 0 | How much of a thin, shiny coat covers the surface, as on car paint or varnish. See "Clear coat and sheen" |
|
|
98
98
|
| `clearcoatRoughness` | 0 to 1 | 0 | How rough the coat is |
|
|
99
|
-
| `clearcoatNormalScale` | Two numbers | `[1, 1]` | How strongly the coat normal map bends the coat's normals along u and v |
|
|
99
|
+
| `clearcoatNormalScale` | Two finite numbers | `[1, 1]` | How strongly the coat normal map bends the coat's normals along u and v |
|
|
100
100
|
| `sheenColor` | A [color](#color) | Black | The color of the soft glow of cloth and velvet at grazing angles. Black gives none |
|
|
101
101
|
| `sheenRoughness` | 0 to 1 | 1 | How wide the sheen spreads |
|
|
102
102
|
| `iridescence` | 0 to 1 | 0 | How much a thin film above the surface tints its reflection, as on a soap bubble or a beetle's shell. See "Iridescence and anisotropy" |
|
|
@@ -111,7 +111,9 @@ The next sections explain the specular, transmission, diffuse transmission and l
|
|
|
111
111
|
|
|
112
112
|
## Specular reflection and index of refraction
|
|
113
113
|
|
|
114
|
-
A surface reflects some light like a mirror, blurred by its roughness. This is its specular reflection. A metal's reflection takes its base color. A non-metal's reflection is white, and weak when you look at the surface head on: 4% of the light with the defaults. It grows to all the light at grazing angles.
|
|
114
|
+
A surface reflects some light like a mirror, blurred by its roughness. This is its specular reflection. A metal's reflection takes its base color. A non-metal's reflection is white, and weak when you look at the surface head on: 4% of the light with the defaults. It grows to all the light at grazing angles.
|
|
115
|
+
|
|
116
|
+
Three values change the non-metallic part, as glTF's `KHR_materials_ior` and `KHR_materials_specular` extensions do. The standard material's own lighting and shaders draw them, with the formulas in this table.
|
|
115
117
|
|
|
116
118
|
| Value | Head on | At grazing angles |
|
|
117
119
|
| --- | --- | --- |
|
|
@@ -139,7 +141,7 @@ A surface with `transmission` lets the light behind it through. Use it for glass
|
|
|
139
141
|
| `ior` | How far the light bends where it enters the volume. Glass is 1.5, water 1.33 |
|
|
140
142
|
| `dispersion` | How strongly the light that passes through separates into colors, 0 or more: 20 divided by the Abbe number, as glTF's `KHR_materials_dispersion` gives it. A diamond's 0.36 is weak and rutile's 2.04 is strong. Each color bends by its own index of refraction, so the edges of a prism or a gem show a rainbow. 0 bends every color alike |
|
|
141
143
|
| `thickness` | How deep the volume is. The light leaves it this far along the bent direction, so a thicker volume shows what lies behind it farther away. 0 is a thin wall, such as a window pane, which bends nothing |
|
|
142
|
-
| `thicknessMap` | The thickness, per texel, in green. Its green multiplies `thickness`. It samples the specular color slot's texture array at a layer of its own, so a
|
|
144
|
+
| `thicknessMap` | The thickness, per texel, in green. Its green multiplies `thickness`. It samples the specular color slot's texture array at a layer of its own, so a material with a thickness map takes no specular color map |
|
|
143
145
|
| `roughness` | How much the light from behind blurs: none at 0, and very blurred at 1. An `ior` of 1 blurs nothing |
|
|
144
146
|
| `attenuationColor`, `attenuationDistance` | The color of the volume. White light takes `attenuationColor` after `attenuationDistance` inside it, and a deeper color farther in. The default absorbs nothing |
|
|
145
147
|
|
|
@@ -166,17 +168,26 @@ After the camera's view draws its opaque objects, the engine copies their colors
|
|
|
166
168
|
- `thickness` is in the mesh's own units, and the object's scale multiplies it.
|
|
167
169
|
- Such a surface takes the `opaque`, `mask` or `blend` alpha mode. A mask decides which pixels draw, and the light from behind fills the pixels that remain. `hash` throws E1217.
|
|
168
170
|
- Views other than the camera's, such as [scene passes](render.md#scene-passes) and [reflection passes](render.md#reflection-passes), have no copy. There the surface shows the environment's light along the bent ray.
|
|
169
|
-
- A material with `transmissionMap` or `thicknessMap` may also give the specular maps
|
|
170
|
-
- A layered material keeps the two maps beside a clear coat, a sheen, iridescence or anisotropy,
|
|
171
|
+
- A material with `transmissionMap` or `thicknessMap` may also give the specular maps, except for the pairs in [Texture maps](#texture-maps).
|
|
172
|
+
- A layered material keeps the two maps beside a clear coat, a sheen, iridescence or anisotropy, except for the pairs in [Texture maps](#texture-maps).
|
|
171
173
|
|
|
172
|
-
|
|
174
|
+
Nothing runs until the first surface that lets light through draws. To load its shaders before the first frame, list `'transmission'` in `createEngine`'s `preload` option.
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
<details>
|
|
177
|
+
<summary>Technical details: what transmission costs</summary>
|
|
178
|
+
|
|
179
|
+
Then each frame copies the camera's opaque colors once and makes the blurred copies. The camera's opaque and see-through objects then draw in two render passes instead of one. A material with `dispersion` samples the copy three times, once for each color; a material without it samples the copy once.
|
|
180
|
+
|
|
181
|
+
</details>
|
|
175
182
|
|
|
176
183
|
## Light through thin surfaces
|
|
177
184
|
|
|
178
185
|
A surface with `diffuseTransmission` lets the light that reaches its back through to its front, as glTF's `KHR_materials_diffuse_transmission` describes. A leaf, a petal, a lampshade or an ear then glows where the sun or a lamp shines behind it. The light from behind spreads out evenly, as the diffuse light does, so the surface does not show what lies behind it. For glass and water, which do, use `transmission`.
|
|
179
186
|
|
|
187
|
+

|
|
188
|
+
|
|
189
|
+
Diffuse transmission.
|
|
190
|
+
|
|
180
191
|
| Value | What it does |
|
|
181
192
|
| --- | --- |
|
|
182
193
|
| `diffuseTransmission` | The share of the surface's diffuse light that passes through to the other side. The front keeps the rest, and the specular reflection stays. 0 lets nothing through, and 1 lets all the diffuse light through, as a sheet of paper does |
|
|
@@ -195,11 +206,12 @@ const shade = materials.standard({
|
|
|
195
206
|
});
|
|
196
207
|
```
|
|
197
208
|
|
|
198
|
-
A measured leaf reflects about 7 to 11
|
|
199
|
-
|
|
209
|
+
A measured leaf reflects about 7 to 11 percent of visible light and transmits about 4 to 6
|
|
210
|
+
percent of it, and almost all of that comes out diffuse. The share of its diffuse light that passes
|
|
200
211
|
through therefore sits near a third: 0.25 to 0.45. Its gloss is a dielectric's, with a reflectance
|
|
201
|
-
at normal incidence of about 0.03 to 0.04 and a perceptual roughness of 0.35 to 0.6.
|
|
202
|
-
|
|
212
|
+
at normal incidence of about 0.03 to 0.04 and a perceptual roughness of 0.35 to 0.6.
|
|
213
|
+
|
|
214
|
+
Give a leaf material values from these ranges. Petals and paper are
|
|
203
215
|
thinner than leaves and let more through, so the translucency demo keeps its petals at 0.7 and its
|
|
204
216
|
paper lantern at 0.85; the measured range is for leaves.
|
|
205
217
|
|
|
@@ -212,14 +224,23 @@ Give `diffuseTransmission` when you create the material, even as 0, to change it
|
|
|
212
224
|
- `diffuseTransmissionMap` and `diffuseTransmissionColorMap` vary the two values across the surface. They take the places of the specular maps, which such a material does not take. See "Texture maps".
|
|
213
225
|
- A material with a clear coat, a sheen, iridescence or anisotropy, or with the `weighted` blending, takes no `diffuseTransmission`. Development builds throw E1217 for it. A glTF file's layers win over its diffuse transmission.
|
|
214
226
|
|
|
215
|
-
|
|
227
|
+
Nothing runs while no material has `diffuseTransmission`. To load its shaders before the first frame, list `'translucency'` in `createEngine`'s `preload` option.
|
|
228
|
+
|
|
229
|
+
<details>
|
|
230
|
+
<summary>Technical details: what light through thin surfaces costs</summary>
|
|
231
|
+
|
|
232
|
+
Each pixel of such a surface adds one product per light, and one more reading of the ambient light and the environment, from behind. The sun's shadow lookup runs on both faces of such a surface, where other surfaces skip it on the side away from the sun.
|
|
216
233
|
|
|
217
|
-
|
|
234
|
+
</details>
|
|
218
235
|
|
|
219
236
|
## Light under the surface
|
|
220
237
|
|
|
221
238
|
Light that enters skin, wax or marble leaves it a little way from where it entered, redder the further it went. A material with `subsurfaceRadius` draws that: the subsurface blur spreads the surface's diffuse light over the radius. The edges of its shadows, the light at the side of a nose and the detail of its maps then go soft. Its highlights stay sharp, since only the diffuse light spreads.
|
|
222
239
|
|
|
240
|
+

|
|
241
|
+
|
|
242
|
+
Light under the surface. It shows on High and Ultra.
|
|
243
|
+
|
|
223
244
|
| Value | Meaning |
|
|
224
245
|
| --- | --- |
|
|
225
246
|
| `subsurfaceRadius` | How far light spreads under the surface, in world units taken as meters. Skin takes about 0.01, wax about 0.02, and marble a few millimeters |
|
|
@@ -245,14 +266,23 @@ Give `subsurfaceRadius` when you create the material, even as 0, to change it la
|
|
|
245
266
|
- A blur narrower than a pixel draws nothing, so distant objects cost nothing more.
|
|
246
267
|
- The glTF loader reads the draft `KHR_materials_volume_scatter`: each channel spreads `attenuationDistance` times its `multiscatterColor`. See [Assets](assets.md).
|
|
247
268
|
|
|
248
|
-
|
|
269
|
+
Nothing runs while no material has `subsurfaceRadius` or the quality setting gives it no taps. To load its shaders before the first frame, list `'subsurface'` in `createEngine`'s `preload` option.
|
|
270
|
+
|
|
271
|
+
<details>
|
|
272
|
+
<summary>Technical details: what light under the surface costs</summary>
|
|
249
273
|
|
|
250
|
-
|
|
274
|
+
While it draws, the objects with a radius draw a second time, in a skin pass that shades their diffuse light into a target of their own. Two full-screen steps then blur it across and down. Each reads its taps only at skin pixels whose blur covers a pixel or more, and every other pixel reads one texel. The targets take 36 bytes per pixel of the render size.
|
|
275
|
+
|
|
276
|
+
</details>
|
|
251
277
|
|
|
252
278
|
## Clear coat and sheen
|
|
253
279
|
|
|
254
280
|
Two layers can lie over the standard material's surface, as glTF's `KHR_materials_clearcoat` and `KHR_materials_sheen` extensions describe them:
|
|
255
281
|
|
|
282
|
+

|
|
283
|
+
|
|
284
|
+
Clear coat and sheen.
|
|
285
|
+
|
|
256
286
|
- A **clear coat** is a thin, clear, shiny film, such as the lacquer of car paint, varnish on wood, or water on a stone. It has highlights and a reflection of its own, at its own roughness. Where it reflects light, it dims what lies under it. So a rough red paint under a smooth coat shows a sharp reflection over a soft color.
|
|
257
287
|
- A **sheen** is the soft glow that cloth, velvet and fuzz take at grazing angles, where the light catches the tips of their fibers. Its color tints the glow. Light that the sheen reflects does not reach the surface under it.
|
|
258
288
|
|
|
@@ -291,9 +321,11 @@ Give any of these values, or a layer map, when you create the material, to chang
|
|
|
291
321
|
| `sheenColorMap` | RGB, sRGB | Multiplies `sheenColor` |
|
|
292
322
|
| `sheenRoughnessMap` | A | Multiplies `sheenRoughness` |
|
|
293
323
|
|
|
294
|
-
The layers' maps take the places of the light map and the specular maps. So a material with a clear coat, a sheen, iridescence or anisotropy takes no `lightMap`, `specularIntensityMap` or `specularColorMap`, and no `diffuseTransmission`. Development builds throw E1217 for them, and production builds draw the material without them. Its `specularIntensity` and `specularColor` values still apply.
|
|
324
|
+
The layers' maps take the places of the light map and the specular maps. So a material with a clear coat, a sheen, iridescence or anisotropy takes no `lightMap`, `specularIntensityMap` or `specularColorMap`, and no `diffuseTransmission`. Development builds throw E1217 for them, and production builds draw the material without them. Its `specularIntensity` and `specularColor` values still apply.
|
|
325
|
+
|
|
326
|
+
Give `clearcoatMap` and `clearcoatRoughnessMap` as one texture, with the coat in red and its roughness in green, and `sheenColorMap` and `sheenRoughnessMap` as one texture, with the roughness in alpha. glTF packs them this way, and two textures for a pair throw E1217. An sRGB texture keeps its alpha linear, so one sRGB texture holds the sheen's color and roughness.
|
|
295
327
|
|
|
296
|
-
A material with `transmission` keeps its `transmissionMap` and `thicknessMap` beside the layers,
|
|
328
|
+
A material with `transmission` keeps its `transmissionMap` and `thicknessMap` beside the layers, except for the pairs in [Texture maps](#texture-maps).
|
|
297
329
|
|
|
298
330
|
### How the layers draw
|
|
299
331
|
|
|
@@ -301,14 +333,23 @@ A material with `transmission` keeps its `transmissionMap` and `thicknessMap` be
|
|
|
301
333
|
- The sheen is the Charlie highlight of cloth (Estevez and Kulla), lit by each light, and by the ambient light and the environment. A curve fit of the sheen's reflectance, which needs no lookup table, gives how much light the sheen keeps from the surface under it. At grazing angles the fit gives a little less than the exact value. So the surface under a strong sheen shows slightly brighter there than the extension's reference.
|
|
302
334
|
- Emitted light lies under the coat too, so a coat dims a glowing surface where it reflects.
|
|
303
335
|
|
|
304
|
-
|
|
336
|
+
The layers' shaders load the first time you create a material with layers. To load them before the first frame, list `'coat_sheen'` in `createEngine`'s `preload` option.
|
|
305
337
|
|
|
306
|
-
|
|
338
|
+
<details>
|
|
339
|
+
<summary>Technical details: what the layers cost</summary>
|
|
340
|
+
|
|
341
|
+
A layered material costs each of its pixels, per light, one more highlight for the coat and one for the sheen, and one more environment read for the coat. A layer that a material does not use costs almost nothing. Materials without layers draw with no extra texture and their shaders do not change.
|
|
342
|
+
|
|
343
|
+
</details>
|
|
307
344
|
|
|
308
345
|
## Iridescence and anisotropy
|
|
309
346
|
|
|
310
347
|
Two more effects sit in the same shaders as the clear coat and the sheen, and a material takes them with the same options:
|
|
311
348
|
|
|
349
|
+

|
|
350
|
+
|
|
351
|
+
Iridescence and anisotropy.
|
|
352
|
+
|
|
312
353
|
- **Iridescence** is the color that a thin film adds to a reflection, as on a soap bubble, an oil slick, a beetle's shell or a pearl. The film reflects each wavelength by its own phase, so the color depends on the film's thickness and on the angle you see it from. The engine uses Belcour and Barla's thin-film formulas.
|
|
313
354
|
- **Anisotropy** stretches the surface's highlight along one direction, as the grain of brushed metal spreads it across the grooves instead of around them. The engine uses an anisotropic GGX lobe, after Filament.
|
|
314
355
|
|
|
@@ -343,7 +384,9 @@ Give any of these values, or a map, when you create the material, to change the
|
|
|
343
384
|
| `iridescenceThicknessMap` | G, linear | Mixes `iridescenceThicknessRange` between its two values |
|
|
344
385
|
| `anisotropyMap` | RG direction, B strength, linear | Red and green give the direction in the tangent plane, and blue multiplies `anisotropy` |
|
|
345
386
|
|
|
346
|
-
A material with these maps takes no `lightMap` and no specular maps, since the maps take their places. A material takes the maps of a clear coat and a sheen, or the maps of iridescence and the anisotropy: the coat's and the sheen's maps fill every place. Development builds throw E1217 for a material that asks for both families.
|
|
387
|
+
A material with these maps takes no `lightMap` and no specular maps, since the maps take their places. A material takes the maps of a clear coat and a sheen, or the maps of iridescence and the anisotropy: the coat's and the sheen's maps fill every place. Development builds throw E1217 for a material that asks for both families.
|
|
388
|
+
|
|
389
|
+
Production builds keep the coat's and the sheen's maps and draw the others' values alone. The glTF loader keeps the coat's and the sheen's maps and notes the others. A material with `transmission` keeps its `transmissionMap` and `thicknessMap` beside these maps, except for the pairs in [Texture maps](#texture-maps).
|
|
347
390
|
|
|
348
391
|
A material with `anisotropy` draws with or without a map. The direction that it stretches along comes from the surface's tangent frame. The frame is the mesh's tangents where it has them, else the texture coordinates, else the normal map's coordinates where the material also has a normal map. A material without a map and with no texture coordinates takes any frame square to the surface.
|
|
349
392
|
|
|
@@ -355,14 +398,23 @@ A material with `anisotropy` draws with or without a map. The direction that it
|
|
|
355
398
|
- The reflection of the environment bends away from the normal across the stretched direction. So brushed metal shows a long reflection rather than a dot.
|
|
356
399
|
- Rectangles and tubes of light shade the surface without the stretch.
|
|
357
400
|
|
|
358
|
-
|
|
401
|
+
These effects add nothing to a material without them. To load their shaders before the first frame, list `'coat_sheen'` in `createEngine`'s `preload` option.
|
|
402
|
+
|
|
403
|
+
<details>
|
|
404
|
+
<summary>Technical details: what iridescence and anisotropy cost</summary>
|
|
405
|
+
|
|
406
|
+
They run in the shaders of the layers above the surface, which load the first time you create a material with a clear coat, a sheen, iridescence or anisotropy. A film costs one short series of cosines per pixel, and a stretched lobe costs a few more terms per light.
|
|
359
407
|
|
|
360
|
-
|
|
408
|
+
</details>
|
|
361
409
|
|
|
362
410
|
## Decals
|
|
363
411
|
|
|
364
412
|
A decal material projects a standard material onto every opaque surface inside a box. Use decals for scorch marks, mud, puddles, road paint, moss, cracks and posters. Give the material to a mesh of `geometry.box()`: the object's position, rotation and scale place the box.
|
|
365
413
|
|
|
414
|
+

|
|
415
|
+
|
|
416
|
+
Decals.
|
|
417
|
+
|
|
366
418
|
```ts
|
|
367
419
|
// sketch.ts: a scorch mark on the ground, and cracks on a wall. The maps come from textures.
|
|
368
420
|
const box = geometry.box();
|
|
@@ -385,7 +437,7 @@ A decal takes the standard material's values and maps. They light it as they lig
|
|
|
385
437
|
| `metalnessRoughnessMap`, `metalness`, `roughness` | How the decal reflects light. A puddle is smooth, and scorch is rough |
|
|
386
438
|
| `normalMap`, `normalScale` | Bumps of the decal, such as the edges of a crack or the grain of moss |
|
|
387
439
|
| `aoMap`, `aoMapIntensity`, `emissive`, `emissiveMap`, `emissiveIntensity` | Occlusion and light of the decal's own, such as glowing paint |
|
|
388
|
-
| `angleFade` | The angles from the decal's direction at which it starts to fade and past which it shows nothing, in radians. The default, 60 and 80 degrees, keeps a decal on the ground from smearing up a wall |
|
|
440
|
+
| `angleFade` | The angles from the decal's direction at which it starts to fade and past which it shows nothing, in radians. Two angles from 0 to π, the first no larger than the second. The default, 60 and 80 degrees, keeps a decal on the ground from smearing up a wall |
|
|
389
441
|
| `edgeFade` | The share of the box's depth, from 0 to 1, over which the decal fades toward each end along z. The default is 0.2 |
|
|
390
442
|
|
|
391
443
|
A batch of boxes with one decal material draws in one draw. With `colors: true`, each row's color tints its decal, and the row's alpha fades it, as for bullet holes that fade with time.
|
|
@@ -413,9 +465,14 @@ After the camera's view draws its opaque objects, the decals draw in a pass of t
|
|
|
413
465
|
- Only the camera's view shows decals. [Scene passes](render.md#scene-passes) and [reflection passes](render.md#reflection-passes) show none.
|
|
414
466
|
- A decal casts no shadow. Raycasts and pointer events hit its box, as they hit any mesh. Put decals on a layer of their own, and leave that layer out of the raycast's `layers`.
|
|
415
467
|
|
|
416
|
-
|
|
468
|
+
Nothing runs until the first decal material. To load its shaders before the first frame, list `'decals'` in `createEngine`'s `preload` option.
|
|
469
|
+
|
|
470
|
+
<details>
|
|
471
|
+
<summary>Technical details: what decals cost</summary>
|
|
417
472
|
|
|
418
|
-
|
|
473
|
+
Then each frame culls the decals on the engine's workers and draws them in one render pass, with one draw for each run of decals that share their maps. Each pixel that a decal covers reads five depths and lights the surface once more.
|
|
474
|
+
|
|
475
|
+
</details>
|
|
419
476
|
|
|
420
477
|
## Texture maps
|
|
421
478
|
|
|
@@ -459,11 +516,25 @@ const brick = materials.standard({
|
|
|
459
516
|
|
|
460
517
|
A material with `diffuseTransmission` takes the two diffuse transmission maps in the places of the specular maps, and takes no specular maps. A material without it, or with a clear coat, a sheen, iridescence or anisotropy, takes no diffuse transmission maps. Development builds throw E1217 for either.
|
|
461
518
|
|
|
462
|
-
A material with `transmission` may take `transmissionMap` and `thicknessMap` beside the specular maps
|
|
519
|
+
A material with `transmission` may take `transmissionMap` and `thicknessMap` beside the specular maps or the layers' maps, except for a few pairs that share a texture array. Development builds throw E1217 for those pairs, and for the two maps without `transmission`.
|
|
520
|
+
|
|
521
|
+
<details>
|
|
522
|
+
<summary>Technical details: which maps share a texture array</summary>
|
|
523
|
+
|
|
524
|
+
| Array of the slot | Maps that may fill it | Clashes that throw E1217 |
|
|
525
|
+
| --- | --- | --- |
|
|
526
|
+
| Specular intensity | `specularIntensityMap`, `transmissionMap`, `clearcoatNormalMap`, `iridescenceThicknessMap` | `transmissionMap` with `clearcoatNormalMap` or `iridescenceThicknessMap` |
|
|
527
|
+
| Specular color | `specularColorMap`, `thicknessMap`, `sheenColorMap`, `sheenRoughnessMap`, `anisotropyMap` | `thicknessMap` with `specularColorMap` (sRGB and linear never share an array), or with a sheen map or `anisotropyMap` |
|
|
528
|
+
|
|
529
|
+
Two maps of one slot draw together only when their images have one size and format.
|
|
530
|
+
|
|
531
|
+
</details>
|
|
463
532
|
|
|
464
533
|
The maps of a material are fixed when you create it. A mesh needs texture coordinates to show them, and a mesh without them draws the material without its maps. A map reads the set of coordinates that its texture's `uvSet` names. Light maps usually use the second set, so load them with `uvSet: 1`. A mesh without a second set gives its first set to such a map.
|
|
465
534
|
|
|
466
|
-
A light map adds baked light to the ambient light. A bake often places its light map on each mesh with its own scale and offset, which `lightMapOffset` and `lightMapRepeat` give; the other maps keep their coordinates.
|
|
535
|
+
A light map adds baked light to the ambient light. A bake often places its light map on each mesh with its own scale and offset, which `lightMapOffset` and `lightMapRepeat` give; the other maps keep their coordinates.
|
|
536
|
+
|
|
537
|
+
A directional light map also stores the light's direction at each texel: give its `lightMapDirection` and the material's normal map bends the baked light, so relief faces the light of the bake and turns away from it. `assets.loadLightMap` reads a directional map from a [baked light file](../guides/baked-light-data.md). A material made from a model for Needle's viewer takes that model's light maps with their RGBM decode.
|
|
467
538
|
|
|
468
539
|
A normal map takes its frame from the mesh's tangents when the mesh has them, as `geometry.fromArrays` with `computeTangents` makes them. Otherwise the shader finds the frame from how the positions and the coordinates change between pixels.
|
|
469
540
|
|
|
@@ -475,6 +546,10 @@ On WebGL2, the maps of one material share at most six textures on the GPU. Maps
|
|
|
475
546
|
|
|
476
547
|
Three maps give a surface relief. Each reads heights from its red channel, in the `linear` color space.
|
|
477
548
|
|
|
549
|
+

|
|
550
|
+
|
|
551
|
+
Relief maps.
|
|
552
|
+
|
|
478
553
|
```ts
|
|
479
554
|
// sketch.ts
|
|
480
555
|
const [color, normal, height] = await Promise.all([
|
|
@@ -513,7 +588,9 @@ A page without relief pays nothing for it. The first material with a bump map lo
|
|
|
513
588
|
|
|
514
589
|
## Texture coordinate transform
|
|
515
590
|
|
|
516
|
-
`uvTransform` places every map of a material on the texture coordinates: `offset`, `repeat` and `rotation` in radians. The engine turns the coordinates by `rotation` about their origin, scales them by `repeat`, and then adds `offset`: u' = repeat.u × (u cos r + v sin r) + offset.u, and v' = repeat.v × (v cos r − u sin r) + offset.v. A transform that leaves a value out takes its default. `set` changes the transform at any time.
|
|
591
|
+
`uvTransform` places every map of a material on the texture coordinates: `offset`, `repeat` and `rotation` in radians. The engine turns the coordinates by `rotation` about their origin, scales them by `repeat`, and then adds `offset`: u' = repeat.u × (u cos r + v sin r) + offset.u, and v' = repeat.v × (v cos r − u sin r) + offset.v. A transform that leaves a value out takes its default. `set` changes the transform at any time.
|
|
592
|
+
|
|
593
|
+
`mapUvTransforms` places one map by its option name, such as `emissiveMap`, where it differs from the others. A map without one keeps the transform that `uvTransform` gives it. Two maps that share a slot, as a sheen map and an anisotropy map do, share one transform too. A glTF file keeps a transform for each of its textures, so the loader places each map with its own.
|
|
517
594
|
|
|
518
595
|
## Color
|
|
519
596
|
|
|
@@ -523,7 +600,16 @@ A page without relief pays nothing for it. The first material with a bump map lo
|
|
|
523
600
|
|
|
524
601
|
`set(options)` changes a material's values at any time, and every object that uses the material changes with it. It changes only the options that you pass. The others keep their values, so `set({ roughness: 0.5 })` keeps the color. A standard material's `set` takes every value in the table above, and an unlit material's `set` takes `color`, `opacity`, `alphaCutoff`, `uvTransform` and `mapUvTransforms`.
|
|
525
602
|
|
|
526
|
-
`set` is for setup, and for several values at once.
|
|
603
|
+
`set` is for setup, and for several values at once. Change the values that a frame changes with `setUniform(name, value)`, which allocates nothing: `material.setUniform('roughness', 0.5 + 0.1 * Math.sin(t))`. On a standard material it takes these numbers: `opacity`, `alphaCutoff`, `metalness`, `roughness`, `emissiveIntensity`, `aoMapIntensity`, `lightMapIntensity`, `specularIntensity`, `envIntensity`, `transmission`, `thickness`, `dispersion`, `diffuseTransmission`, `subsurfaceRadius`, `clearcoat`, `clearcoatRoughness`, `sheenRoughness`, `iridescence`, `iridescenceIor`, `anisotropy`, `anisotropyRotation` and, on a decal, `edgeFade`. It also takes these colors: `color`, `emissive`, `specularColor`, `attenuationColor` and `sheenColor`.
|
|
604
|
+
|
|
605
|
+
Give a color in an array that you change in place. Every other value goes through `set`, and `setUniform` throws [E1216](../errors/E1216.md) for it. A custom material's `setUniform` also changes one of its WGSL uniforms, by the name in its `struct Uniforms`. The engine's allocation benchmark checks `setUniform` in every frame and `set` at setup.
|
|
606
|
+
|
|
607
|
+
<details>
|
|
608
|
+
<summary>Technical details: why set can allocate</summary>
|
|
609
|
+
|
|
610
|
+
`set` reads each number from a field of the options object that you pass. The browser boxes such a read when it cannot keep the field's number unboxed. This happens when the object's fields hold other kinds of value too, and when one call site sees objects of more than a few shapes. `setUniform` takes the value itself, so nothing is read from an object.
|
|
611
|
+
|
|
612
|
+
</details>
|
|
527
613
|
|
|
528
614
|
`set` checks every value before it changes any, so a call that throws changes nothing. It converts a color without allocating, and it reads each number by its name. Keep one options object for each material that changes. To change one object alone, give it another material with `mesh.setMaterial(material)`.
|
|
529
615
|
|
|
@@ -555,7 +641,7 @@ These options are fixed when you create the material. Most of them choose the ma
|
|
|
555
641
|
| `subsurfaceRadius` | Standard | None | Given at all, even as 0, spreads the surface's light under it, and `set` can then change its value. See "Light under the surface" |
|
|
556
642
|
| The layer values and maps | Standard | None | Any of them gives the material its layers above the surface, even a coat of 0, and `set` can then change their values. See "Clear coat and sheen" and "Iridescence and anisotropy" |
|
|
557
643
|
| `fog` | Both | true | Takes the scene's fog. With `false`, the material keeps its color at every distance. [Scene](scene.md#fog) sets the fog |
|
|
558
|
-
| `toneMapped` | Both | true | With `false`,
|
|
644
|
+
| `toneMapped` | Both | true | With `false`, the tone curve leaves the color alone, so it shows as the display shows it. The exposure still scales it, so it shows brighter than the same color tone mapped. On the HDR path a blended surface keeps the curve. [Color management](../concepts/color-management.md#materials-that-keep-their-display-color) explains each path |
|
|
559
645
|
| `contactShadows` | Standard | true | Takes the main directional light's contact shadows. With `false`, the surface takes none and keeps the shadow map's shadows. Use it on grass, leaf cards and other thin surfaces that crowd together or sway, where contact shadows make them dark and grainy and flicker as they move. [Shadows](../concepts/shadows.md#grass-and-other-thin-surfaces) explains why |
|
|
560
646
|
| `wireframe` | Both | false | Draws the edges of each triangle as lines one pixel wide, with the material's own shading. See "Wireframe" |
|
|
561
647
|
| `parallax` | Standard | false | With a `displacementMap`, adds parallax occlusion mapping. See "Relief" |
|
|
@@ -565,7 +651,9 @@ A material with `vertexColors` draws a mesh without colors in its base color alo
|
|
|
565
651
|
|
|
566
652
|
### Wireframe
|
|
567
653
|
|
|
568
|
-
A material with `wireframe: true` draws each triangle's three edges as lines. An edge that two triangles share draws twice. The engine keeps an edge list for each mesh from the first wireframe on, which takes twice the GPU memory of the mesh's triangle indices. Its shadows draw lines too.
|
|
654
|
+
A material with `wireframe: true` draws each triangle's three edges as lines. An edge that two triangles share draws twice. The engine keeps an edge list for each mesh from the first wireframe on, which takes twice the GPU memory of the mesh's triangle indices. Its shadows draw lines too.
|
|
655
|
+
|
|
656
|
+
Flat shading and bump maps have no effect, because lines have no faces. Lines are one pixel wide on every GPU path. For wide lines, or for a mesh's outline edges alone, use [Lines](lines.md). The [relief demo](https://github.com/null3d-engine/null3d/tree/main/examples/relief) draws a geodesic frame with `wireframe: true`, and its shadow is a shadow of lines.
|
|
569
657
|
|
|
570
658
|
## Alpha modes
|
|
571
659
|
|
|
@@ -580,7 +668,9 @@ A surface's alpha is its `opacity`, times the alpha of its base color map. With
|
|
|
580
668
|
|
|
581
669
|
A masked surface has hard edges, and it hides what lies behind it as an opaque one does, so its objects draw in any order. Use it for leaves, fences and cut-out shapes. Only masked and hashed materials draw with the shader that drops fragments, so opaque ones keep the GPU's early depth test.
|
|
582
670
|
|
|
583
|
-
A hashed surface draws a share of its points that its alpha sets: half of them at an alpha of 0.5. A hash of each point's place on the mesh picks the points. So the pattern moves with the object and does not crawl as the camera moves. The hash uses integer math, so every GPU draws the same pattern.
|
|
671
|
+
A hashed surface draws a share of its points that its alpha sets: half of them at an alpha of 0.5. A hash of each point's place on the mesh picks the points. So the pattern moves with the object and does not crawl as the camera moves. The hash uses integer math, so every GPU draws the same pattern.
|
|
672
|
+
|
|
673
|
+
Hashed objects draw in any order, as masked ones do. They suit fades and see-through surfaces that cross each other, where blending would need a sort. The pattern is noisy up close. `alphaCutoff` has no effect in this mode.
|
|
584
674
|
|
|
585
675
|
A blended surface lets what lies behind it show through. Blended objects draw after the opaque ones, farthest first, so each one blends over the objects behind it. A call to `mesh.setRenderOrder(order)` draws an object before or after the others, whatever its depth. The rows of an instance batch sort one by one. The page [Materials and pipelines](../concepts/materials.md#the-transparent-pass) explains the sort. It also says where the sort cannot help.
|
|
586
676
|
|
|
@@ -597,9 +687,11 @@ leaves.set({ alphaCutoff: 0.2 });
|
|
|
597
687
|
|
|
598
688
|
A masked surface's cut edges are as smooth as its outer edges, as `alphaToCoverage` is on by default. The alpha fades from nothing at `alphaCutoff` to full over about one pixel. MSAA then draws the surface on that share of each edge pixel's samples. Foliage and fences lose their stair steps, and their objects still draw in any order.
|
|
599
689
|
|
|
600
|
-
This is the best technique for cut-out shapes, so it is the default, as in Filament. For hard cut edges, give `alphaToCoverage: false`. The option needs MSAA, the default anti-aliasing. With FXAA or no anti-aliasing, as on the Low preset, the mask cuts as without it. On WebGPU, where the scene's colors have no alpha channel, the shader sets the covered samples itself, with the same look.
|
|
690
|
+
This is the best technique for cut-out shapes, so it is the default, as in Filament. For hard cut edges, give `alphaToCoverage: false`. The option needs MSAA, the default anti-aliasing. With FXAA or no anti-aliasing, as on the Low preset, the mask cuts as without it. On WebGPU, where the scene's colors have no alpha channel, the shader sets the covered samples itself, with the same look.
|
|
601
691
|
|
|
602
|
-
|
|
692
|
+
The first such material loads the shader builds of alpha to coverage, and the first hashed material those of the hash. To load them before the first frame instead, list `'coverage'` and `'hash'` in `createEngine`'s `preload` option.
|
|
693
|
+
|
|
694
|
+
A [custom material](materials.md#custom-materials) takes both, but only where its WGSL sets or reads the surface's `alpha`. Such a material's shadow caster and motion build run that alpha too, so its shadow and its motion keep the mask's holes. WGSL that never names the alpha throws E1217 for `alphaToCoverage` and for the `hash` mode, and it casts its mesh's whole shape.
|
|
603
695
|
|
|
604
696
|
```ts
|
|
605
697
|
// sketch.ts: grass cards whose cut edges MSAA smooths, and a fence with hard pixel edges.
|
|
@@ -625,7 +717,7 @@ scene.createMesh({ mesh: geometry.plane({ width: 8, height: 6 }), material: hold
|
|
|
625
717
|
|
|
626
718
|
A blended surface with `doubleSided: true` draws in two draws. Its back faces draw first, then its front faces. So the near side of a glass box or a sphere always covers its far side, whatever the order of the mesh's triangles. Neighbors that share the mesh and the material draw together: all their back faces, then all their front faces.
|
|
627
719
|
|
|
628
|
-
`forceSinglePass: true` draws both faces in one draw. The triangles then cover each other in the mesh's order. Use it for flat surfaces, such as leaves and planes of glass, whose two faces never overlap on screen: it saves one draw per object. The second draw costs about as much as the first, so it is the speed setting for scenes with many double-sided blended objects. Solid double-sided materials always draw once.
|
|
720
|
+
`forceSinglePass: true` draws both faces in one draw. The triangles then cover each other in the mesh's order. Use it for flat surfaces, such as leaves and planes of glass, whose two faces never overlap on screen: it saves one draw per object. The second draw costs about as much as the first, so it is the speed setting for scenes with many double-sided blended objects. Solid double-sided materials always draw once. The [depth-only demo](https://github.com/null3d-engine/null3d/tree/main/examples/depth-only) sets it on its double-sided glass panes.
|
|
629
721
|
|
|
630
722
|
```ts
|
|
631
723
|
// sketch.ts: a glass globe that shows its far side, and a flat pane that needs one draw.
|
|
@@ -673,13 +765,20 @@ const glass = materials.standard({ color: '#a8d8ff', opacity: 0.3, roughness: 0.
|
|
|
673
765
|
- Views other than the camera's, such as [scene passes](render.md#scene-passes) and [reflection passes](render.md#reflection-passes), draw weighted surfaces farthest first, as `'normal'` ones. So do WebGL2 devices that cannot draw into 16-bit float targets, and frames before the layer's shaders have loaded.
|
|
674
766
|
- Materials with `transmission`, custom materials and lines do not take the `weighted` blending. They throw E1217.
|
|
675
767
|
|
|
676
|
-
|
|
768
|
+
The layer costs nothing until the first weighted surface draws. To load its shaders before the first frame, list `'weighted'` in `createEngine`'s `preload` option.
|
|
769
|
+
|
|
770
|
+
<details>
|
|
771
|
+
<summary>Technical details: what weighted blending costs</summary>
|
|
677
772
|
|
|
678
|
-
|
|
773
|
+
Each frame then draws the camera's weighted surfaces into two targets of the render size, 10 bytes per pixel together. A full-screen step blends them over the scene. With MSAA, the layer first copies one sample of each pixel's depth. The camera's other blended objects and the weighted layer draw in separate render passes.
|
|
774
|
+
|
|
775
|
+
</details>
|
|
679
776
|
|
|
680
777
|
### Moment transparency
|
|
681
778
|
|
|
682
|
-
The quality setting `momentTransparency` blends the blended surfaces in a second layer that needs no sort. It is nearer an exact back-to-front blend than the weighted blending
|
|
779
|
+
The quality setting `momentTransparency` blends the blended surfaces in a second layer that needs no sort. It is nearer an exact back-to-front blend than the weighted blending in the engine's test of five overlapping glass panes: more than twice nearer when the panes sit within a few meters, and about two and a half times nearer when they spread from 1 to 30 meters.
|
|
780
|
+
|
|
781
|
+
The engine stores four depth moments of each pixel, then draws the surfaces a second time and weights each fragment's color by the light that the moments say survives in front of it. A last step blends the result over the scene. The fit is exact for one surface and for two, and closest to the exact blend of every method the engine has for overlapping glass, foliage and particles.
|
|
683
782
|
|
|
684
783
|
```ts
|
|
685
784
|
// The page turns the layer on when the engine starts, and every blended material draws in it.
|
|
@@ -687,10 +786,10 @@ const engine = await createEngine({ canvas, sketch, momentTransparency: true });
|
|
|
687
786
|
// Or the engine's own switch does: ?moments=on
|
|
688
787
|
```
|
|
689
788
|
|
|
690
|
-
- The setting covers
|
|
789
|
+
- The setting covers standard and unlit materials, and [sprite batches](sprites.md), whose blending is normal or weighted. A surface with another feature that the layer has no shader for, such as `transmission`, a custom material, a line or a masked surface, keeps the transparent pass's sort.
|
|
691
790
|
- The layer draws at one sample per pixel, so MSAA does not smooth its surfaces' edges. SMAA 1x smooths them under the share that the layer covers, and the opaque edges keep MSAA's samples.
|
|
692
791
|
- It costs more than the weighted blending: two draws of the surfaces, 16 bytes per pixel written a frame at the render size, one more full-screen pass, and SMAA's three steps. It is off on every preset, and [Quality presets](../concepts/quality-presets.md#moment-transparency) gives its cost.
|
|
693
|
-
- A page without the setting
|
|
792
|
+
- A page without the setting sorts its blended surfaces in the transparent pass. Views other than the camera's, and devices that cannot draw into 16-bit float targets, draw blended surfaces farthest first, as `'normal'` ones.
|
|
694
793
|
|
|
695
794
|
## Depth bias
|
|
696
795
|
|
|
@@ -712,6 +811,10 @@ const poster = materials.standard({ color: '#e8554e', depthBias: { constant: -4,
|
|
|
712
811
|
|
|
713
812
|
`materials.shader(options)` takes every option of `materials.standard` but the texture maps, and a `wgsl` option: WGSL that the null3D Vite plugin compiled. The WGSL declares a surface function, which starts from the look that the standard options make:
|
|
714
813
|
|
|
814
|
+

|
|
815
|
+
|
|
816
|
+
A custom material that reads row and object values.
|
|
817
|
+
|
|
715
818
|
```ts
|
|
716
819
|
const rings = /* wgsl */ `
|
|
717
820
|
fn surface(input: SurfaceInput) -> Surface {
|
|
@@ -766,22 +869,30 @@ The WGSL can also declare a texture array, `var name: texture_2d_array<f32>;`, a
|
|
|
766
869
|
|
|
767
870
|
A texture samples as white until its image is on the GPU.
|
|
768
871
|
|
|
872
|
+
- A material made with `alphaMode: 'mask'` draws nothing where the surface function's `alpha` is below `alphaCutoff`.
|
|
873
|
+
- Materials made from the same WGSL share one shader. Each one has its own uniforms.
|
|
874
|
+
- A mesh needs texture coordinates to draw with a custom material.
|
|
875
|
+
- WGSL as plain text, which the plugin did not compile, throws E1215. So does a whole shader that is not a [full shader](../guides/custom-shaders.md#full-shaders) of a material.
|
|
876
|
+
- A uniform or a texture that the WGSL does not declare, or a value of the wrong kind, throws E1216.
|
|
877
|
+
|
|
769
878
|
### The scene behind a surface
|
|
770
879
|
|
|
771
880
|
A surface function can read the depth of the opaque scene behind it. This gives water its shallow color near a shore and its deep color farther out, and foam where a rock nearly touches the surface. Call `sceneDistance(uv)` for the distance in front of the camera of the surface behind the point at the screen's place `uv`, or `sceneDepth(uv)` for its depth value. Declare the input in the `sceneInputs` option:
|
|
772
881
|
|
|
773
882
|
```ts
|
|
774
883
|
const water = /* wgsl */ `
|
|
884
|
+
#import null3d::depth::{is_orthographic}
|
|
885
|
+
|
|
775
886
|
struct Uniforms { shallow: vec3f, deep: vec3f, foam: vec3f }
|
|
776
887
|
|
|
777
888
|
/// The distance in front of the camera of a depth value, as sceneDistance converts the copy's.
|
|
778
889
|
fn distance_of(depth: f32) -> f32 {
|
|
779
|
-
let near =
|
|
780
|
-
let far =
|
|
781
|
-
if
|
|
782
|
-
return
|
|
890
|
+
let near = camera.near;
|
|
891
|
+
let far = camera.far;
|
|
892
|
+
if is_orthographic(camera.projection) {
|
|
893
|
+
return far - depth * (far - near);
|
|
783
894
|
}
|
|
784
|
-
return far
|
|
895
|
+
return near * far / (near + depth * (far - near));
|
|
785
896
|
}
|
|
786
897
|
|
|
787
898
|
fn surface(input: SurfaceInput) -> Surface {
|
|
@@ -806,7 +917,7 @@ const sheet = materials.shader({
|
|
|
806
917
|
|
|
807
918
|
- `sceneDepth(uv)` gives the scene's depth with 1 at the camera's near plane and 0 at its far plane, and 0 where nothing drew.
|
|
808
919
|
- `sceneDistance(uv)` gives the distance in front of the camera of that surface, in world units.
|
|
809
|
-
- The water's depth is the gap between the sheet and the surface behind it. Convert the sheet's own depth, `input.fragCoord.z`, to a distance with `
|
|
920
|
+
- The water's depth is the gap between the sheet and the surface behind it. Convert the sheet's own depth, `input.fragCoord.z`, to a distance with `camera.near` and `camera.far`, and subtract it from `sceneDistance(uv)`. A shore that fades over that gap ends softly against the bank instead of on the sheet's edge.
|
|
810
921
|
- `input.fragCoord` counts pixels from the top left of the render target on both GPU paths, so `input.fragCoord.xy / frame.resolution` is the `uv` of the point.
|
|
811
922
|
- The engine copies the opaque scene's depth after the opaque pass and before the transparent pass. A blended surface therefore reads the surfaces behind it.
|
|
812
923
|
- A surface in the opaque pass reads 0, the far plane, because the copy comes later. A surface in a scene pass or a reflection pass reads 0 too, because its view makes no copy.
|
|
@@ -844,19 +955,25 @@ A material with a vertex offset moves its shadows too: its casters draw with the
|
|
|
844
955
|
|
|
845
956
|
An offset that fades out with distance, such as wind, declares `swayDistance`: the distance from the camera out to which the offset moves. The material's WGSL fades its offset to nothing by that distance, and the engine counts a caster of the material as moving only while its bounding sphere reaches within it. A plant past the distance stands still, so a far shadow cascade that only its sway reached keeps the layer it holds. Leave it out for an offset that moves at every distance.
|
|
846
957
|
|
|
847
|
-
A masked custom material cuts its shadow at its cutoff only when its WGSL declares `fn coverage(input: SurfaceInput) -> f32`. The function returns the opacity of the point, and the engine calls it in the material's shadow caster builds, so a card casts the shape of the object it shows rather than its whole quad. A material that declares neither a coverage function nor a surface alpha casts its mesh's whole shape, whatever its mask.
|
|
958
|
+
A masked custom material cuts its shadow at its cutoff only when its WGSL declares `fn coverage(input: SurfaceInput) -> f32`. The function returns the opacity of the point, and the engine calls it in the material's shadow caster builds, so a card casts the shape of the object it shows rather than its whole quad. A material that declares neither a coverage function nor a surface alpha casts its mesh's whole shape, whatever its mask.
|
|
959
|
+
|
|
960
|
+
WGSL that declares a vertex offset, a coverage function or the surface's alpha gets the caster builds; a material with none casts through the engine's own depth template. A flat caster draws both faces, or it casts nothing: the shadow pass culls the front faces of single-sided geometry, so a single-sided quad is culled whole. Give a material whose caster is flat geometry `doubleSided: true`.
|
|
961
|
+
|
|
962
|
+
The caster tests the coverage under the material's `alphaCutoff`, so it needs the `mask` alpha mode: a development build refuses a coverage function on a material that is not masked, because its caster would drop no texel and cast the whole shape.
|
|
848
963
|
|
|
849
964
|
A surface function can move where the sun's shadow lookup reads by setting `s.shadowOffset`, a position in world space relative to the surface. A stand-in card sets it to the surface that its stored depth shows, so its own cast does not fall on it. [Surface functions](../shaders/surface-functions.md#shadows) shows the WGSL.
|
|
850
965
|
|
|
851
966
|
### Mirrors, polished floors and water
|
|
852
967
|
|
|
853
|
-
A custom material can reflect a [reflection pass](render.md#reflection-passes). Its surface function reads the pass's texture where the surface shows on the screen, and sets the surface's `reflection`. The engine lights that color as the light from the mirror direction. The material's Fresnel, metalness and specular values weigh it as they weigh the environment's reflection. [Surface functions](../shaders/surface-functions.md#reflections) shows the WGSL, and [Custom passes](../guides/custom-passes.md#a-water-recipe) a water recipe. Standard materials take no reflection
|
|
854
|
-
|
|
855
|
-
With `alphaMode: 'mask'`, the pixels where the surface function's `alpha` falls below `alphaCutoff` draw nothing. Materials made from the same WGSL share one shader, and each has its own uniforms. A mesh needs texture coordinates to draw with a custom material. WGSL as plain text, which the plugin did not compile, throws E1215. So does a whole shader that is not a [full shader](../guides/custom-shaders.md#full-shaders) of a material. A uniform or a texture that the WGSL does not declare, or a value of the wrong kind, throws E1216. The WGSL can also move the mesh's vertices with a vertex offset. [Surface functions](../shaders/surface-functions.md) describes the WGSL.
|
|
968
|
+
A custom material can reflect a [reflection pass](render.md#reflection-passes). Its surface function reads the pass's texture where the surface shows on the screen, and sets the surface's `reflection`. The engine lights that color as the light from the mirror direction. The material's Fresnel, metalness and specular values weigh it as they weigh the environment's reflection. [Surface functions](../shaders/surface-functions.md#reflections) shows the WGSL, and [Custom passes](../guides/custom-passes.md#a-water-recipe) a water recipe. Standard materials take no reflection: give a polished floor a custom material with the floor's values.
|
|
856
969
|
|
|
857
970
|
## Ranges
|
|
858
971
|
|
|
859
|
-
|
|
972
|
+
When a factory or `set` gets a value that the tables above do not allow, development builds throw an error:
|
|
973
|
+
|
|
974
|
+
- A value outside its range in the Standard values or Decals table throws E1108. So does a number in `uvTransform` or `mapUvTransforms` that is not finite.
|
|
975
|
+
- An `alphaMode` or `blending` that the engine does not know throws E1217. So does the `weighted` blending on a custom material or on a material with `transmission`.
|
|
976
|
+
- A depth bias that is not a finite number throws E1203.
|
|
860
977
|
|
|
861
978
|
## Limits
|
|
862
979
|
|
|
@@ -869,6 +986,17 @@ One engine holds up to 1,024 materials at once. One more throws E1501. A materia
|
|
|
869
986
|
- [Lights](lights.md): what lights a standard material.
|
|
870
987
|
- [Surface functions](../shaders/surface-functions.md): the WGSL of a custom material.
|
|
871
988
|
- [Math helpers](math.md#colors): sRGB and linear colors.
|
|
989
|
+
- [Clear coat and sheen](https://github.com/null3d-engine/null3d/tree/main/examples/coat-and-sheen): candy paint, carbon fiber and velvet in a rainy showroom.
|
|
990
|
+
- [Iridescence and anisotropy](https://github.com/null3d-engine/null3d/tree/main/examples/iridescence-and-anisotropy): a beetle's shell, soap bubbles and an oil slick.
|
|
991
|
+
- [Diffuse transmission](https://github.com/null3d-engine/null3d/tree/main/examples/translucency): broad leaves and coral petals let the low sun through.
|
|
992
|
+
- [Subsurface light](https://github.com/null3d-engine/null3d/tree/main/examples/subsurface): wax, jade and soap glow under the surface.
|
|
993
|
+
- [Decals](https://github.com/null3d-engine/null3d/tree/main/examples/decals): road paint, posters and stains projected onto a street.
|
|
994
|
+
- [Bump, displacement and parallax](https://github.com/null3d-engine/null3d/tree/main/examples/relief): hills and a brick wall whose depth comes from maps made in code.
|
|
995
|
+
- [Weighted blending](https://github.com/null3d-engine/null3d/tree/main/examples/weighted-transparency): eight crossing glass panes and 600 smoke puffs blend in any order.
|
|
996
|
+
- [Custom materials](https://github.com/null3d-engine/null3d/tree/main/examples/shader-inputs): 900 crystals from one material that reads each row.
|
|
997
|
+
- [Scene depth behind a surface](https://github.com/null3d-engine/null3d/tree/main/examples/water): the water add-on reads the bed's depth through the surface.
|
|
998
|
+
- [Invisible surfaces that hide](https://github.com/null3d-engine/null3d/tree/main/examples/depth-only): a plane with `colorWrite: false` holds back a hall while the page shows through.
|
|
999
|
+
- [Dispersion in glass](https://github.com/null3d-engine/null3d/tree/main/examples/extra-shapes): a torus knot and polyhedra in glass that separates the light into colors.
|
|
872
1000
|
|
|
873
1001
|
## API reference
|
|
874
1002
|
|