@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
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: porting/threejs-materials
|
|
3
3
|
title: Porting materials and textures
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.3"
|
|
6
4
|
summary: "Parameter-by-parameter conversion; color spaces; approximations."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Porting materials and textures
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
Most three.js materials map to `materials.standard`, which follows the same glTF metallic-roughness model and the same formulas. So the values of a `MeshStandardMaterial` or a `MeshPhysicalMaterial` carry over. Lambert, Phong and Toon materials have no direct equivalent, so they become a standard material with converted values, or a surface function.
|
|
14
10
|
|
|
15
11
|
This page goes through each three.js material, then the texture settings, then four recipes. [Materials](../api/materials.md) describes every option, and [Color management](../concepts/color-management.md) explains the color spaces.
|
|
@@ -83,7 +79,16 @@ Both become `materials.standard` with `metalness: 0`. The standard material keep
|
|
|
83
79
|
|
|
84
80
|
## MeshToonMaterial and MeshMatcapMaterial
|
|
85
81
|
|
|
86
|
-
Both become custom materials, as the recipes below show.
|
|
82
|
+
Both become custom materials, as the recipes below show. The toon recipe takes the light's direction as a uniform, because a surface function cannot read the scene's lights. For bands that follow the main light, the point and spot lights and their shadows, step the light in a lobe function instead ([Surface functions](../shaders/surface-functions.md#a-materials-own-lobe)).
|
|
83
|
+
|
|
84
|
+
<details>
|
|
85
|
+
<summary>Technical details: toon bands in a lobe function</summary>
|
|
86
|
+
|
|
87
|
+
The engine calls `fn lobe(input: LobeInput) -> vec3f` for the main directional light and for each point and spot light. It gets the light's direction and its shadowed irradiance, and its color adds to that light's specular. The base lighting stays beside it, so set `s.baseColor` to black and `s.roughness` to 1, as the toon recipe does. The engine calls no lobe for the fill directional lights and the area lights, so the bands do not follow them.
|
|
88
|
+
|
|
89
|
+
</details>
|
|
90
|
+
|
|
91
|
+
The matcap recipe looks up a texture by the normal in view space. It is an unlit function, so it ignores the scene's lights, as three.js's matcap does.
|
|
87
92
|
|
|
88
93
|
## Other materials
|
|
89
94
|
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: porting/threejs-overview
|
|
3
3
|
title: Porting from three.js
|
|
4
|
-
|
|
5
|
-
since: "0.3"
|
|
6
|
-
summary: "The porting workflow; what gets faster; what needs rewriting."
|
|
4
|
+
summary: "A port is a rewrite; the limits a port meets; the porting workflow; what gets faster; what needs rewriting."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Porting from three.js
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
```mermaid
|
|
14
10
|
flowchart LR
|
|
15
11
|
inventory["1. Inventory:<br/>list the three.js<br/>features in use"] --> baseline["2. Baseline:<br/>images and timings<br/>of the original"]
|
|
@@ -23,6 +19,30 @@ A good port looks like the original, runs faster, and reads like null3D code. A
|
|
|
23
19
|
|
|
24
20
|
This page gives the workflow and the main differences. The [three.js to null3D mapping](threejs-mapping.md) gives the null3D equivalent of each three.js API.
|
|
25
21
|
|
|
22
|
+
## A port is a rewrite
|
|
23
|
+
|
|
24
|
+
No layer runs three.js code on null3D. A port rewrites the scene in null3D's own API:
|
|
25
|
+
|
|
26
|
+
- The scene code moves into a sketch, which runs in a worker with no DOM. Engine objects are handles, which setters change. Many similar objects become the rows of one batch, and the sketch writes their positions, rotations and colors in typed arrays.
|
|
27
|
+
- null3D shaders are WGSL, and the engine has no shader chunks to patch. A `ShaderMaterial` or an `onBeforeCompile` patch becomes a surface function, an unlit function or a vertex offset function ([Porting shaders](threejs-shaders.md)).
|
|
28
|
+
- An `EffectComposer` chain becomes `post.set` settings, with `post.addEffect` for each custom `ShaderPass` ([Porting post-processing](threejs-postprocessing.md)).
|
|
29
|
+
|
|
30
|
+
The `@null3d/three-compat` add-on does not change this. It holds three.js's Reinhard and Cineon tone curves and the soft outline of `OutlinePass`, and nothing more. It takes no three.js scene, object, material or shader ([three.js looks](../api/three-compat.md)).
|
|
31
|
+
|
|
32
|
+
### Limits that a port meets
|
|
33
|
+
|
|
34
|
+
A three.js scene with custom shaders often passes one of these limits. Find them in the inventory, and plan the workaround before you port.
|
|
35
|
+
|
|
36
|
+
| three.js | The null3D limit | Workaround |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| An `InstancedBufferAttribute` with more than four floats for each instance | A batch row carries four values and a color ([Per-row values](../concepts/instances.md#per-row-values)) | Pack the data into the four values. Or keep the rest in a data texture from `textures.fromData`, and read it with `textureLoad` at the row's place, `input.instance` |
|
|
39
|
+
| A `ShaderMaterial` with many uniforms | The uniforms of a custom material fit in 32 numbers, less one for each texture ([Uniforms](../shaders/surface-functions.md#uniforms)) | Keep the rest in a data texture, and read it with `textureLoad` |
|
|
40
|
+
| A shader that samples more than 6 textures | A custom material samples up to 6 textures | Join textures of one size into a texture array, which takes one slot ([Textures](../shaders/surface-functions.md#textures)) |
|
|
41
|
+
| An environment map for each material, or two maps that a shader blends | One environment lights the whole scene | `scene.setEnvironment`, with `envIntensity` on each material. For a day and a night, `timeOfDay` and the sky's environment follow the sun ([Environment maps](../concepts/lighting.md#environment-maps)) |
|
|
42
|
+
| `side: BackSide` | Materials draw front faces, or both sides with `doubleSided: true` | Flip the geometry's winding, or draw both sides |
|
|
43
|
+
|
|
44
|
+
[Unsupported three.js features](threejs-unsupported.md) lists the rest.
|
|
45
|
+
|
|
26
46
|
## What gets faster
|
|
27
47
|
|
|
28
48
|
null3D keeps scene data in flat arrays in WebAssembly memory, and job workers process the arrays in bulk. three.js keeps each object as a JavaScript object, and walks the scene graph one object at a time on the page's main thread. The gap grows with the object count.
|
|
@@ -85,7 +105,7 @@ These parts have no automatic route. Plan time for them before you start.
|
|
|
85
105
|
## What stays the same
|
|
86
106
|
|
|
87
107
|
- **Color management.** three.js r152 and later, like null3D, read hex colors as sRGB and light in linear space.
|
|
88
|
-
- **Light units.** null3D uses physical units, as three.js r155 and later do: candela for point and spot lights, and lux for
|
|
108
|
+
- **Light units.** null3D uses physical units, as three.js r155 and later do: candela for point and spot lights, nits for rectangle and tube lights, and lux for directional and ambient lights.
|
|
89
109
|
- **Material options.** `materials.standard` keeps most of the names, ranges and formulas of `MeshStandardMaterial` and `MeshPhysicalMaterial`, such as the clear coat and the sheen.
|
|
90
110
|
- **Camera controls.** The controls in `@null3d/controls` keep the option names and defaults of three.js's `OrbitControls`, `MapControls`, `FlyControls` and `FirstPersonControls`.
|
|
91
111
|
- **Geometry generators.** `@null3d/geometry` returns the same vertices as three.js's extra geometry classes.
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: porting/threejs-postprocessing
|
|
3
3
|
title: Porting post-processing
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.2"
|
|
6
4
|
summary: "EffectComposer passes and pmndrs effects to post.set settings; ShaderPass to post.addEffect; three.js tone mappings to custom tone curves."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Porting post-processing
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.2, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
three.js builds post-processing from passes in an `EffectComposer`. null3D has the chain built in. A port turns most passes into settings of `post.set`, and each custom `ShaderPass` into a custom effect with `post.addEffect`.
|
|
14
10
|
|
|
15
11
|
```mermaid
|
|
@@ -64,7 +60,7 @@ post.set({ toneMapping: 'aces', exposure: 1.2, vignette: { size: 1, intensity: 1
|
|
|
64
60
|
| `LUTPass` | `lut: await assets.loadLut(url)`, `lutIntensity` | Load the same `.cube` or `.3dl` file. A `Data3DTexture` that code fills becomes `await assets.lutFromData({ size, data })`, with floats from 0 to 1 in the same order. |
|
|
65
61
|
| `ShaderPass(VignetteShader)` | `vignette: { size: offset, intensity: darkness }` under ACES; under AgX, `vignette: { size: offset, intensity: Math.min(darkness, 1), falloff: 3 }` | null3D darkens HDR color before the tone curve, so bright corners darken instead of turning gray. Under ACES the default falloff gives a close match. With a `darkness` below 1, three.js also lifts dark corners toward a gray, and null3D does not. |
|
|
66
62
|
| `FXAAPass`, `ShaderPass(FXAAShader)` | `createEngine({ antialias: 'fxaa' })` on the page | FXAA runs in the final pass. |
|
|
67
|
-
| `SMAAPass`, `SSAARenderPass`, `TAARenderPass` | MSAA, which the presets from Medium up use | null3D has no SMAA, SSAA
|
|
63
|
+
| `SMAAPass`, `SSAARenderPass`, `TAARenderPass` | MSAA, which the presets from Medium up use | null3D has no SMAA over the whole image, no SSAA and no TAA of a moving view. A view that holds still blends jittered frames by itself, so TAARenderPass and SSAARenderPass on a still camera need no pass. Bloom, outlines, automatic exposure, custom effects and sharpening stop that blend ([Still-camera accumulation](../concepts/post-processing.md#still-camera-accumulation)). |
|
|
68
64
|
| `SharpenNode`, the `sharpen()` node | `sharpen` | Both sharpen display color with FSR 1's RCAS in the final pass, so the port needs no render target and no pass of its own. three.js scales the sharpening by `2^-sharpness`, where 0 sharpens the most and 2 does nothing. Set `sharpen` to that factor, so three.js's default of 0.2 is `sharpen: 0.87`. null3D damps the sharpening where the ring around a pixel is noise, which three.js does only with `denoise: true`. |
|
|
69
65
|
| `BokehPass` | `dof: { focusDistance: focus, aperture, maxBlur }` and `camera.setFocalLength(mm)` | `focus` becomes `focusDistance`. null3D's `aperture` is an f-number of a camera's lens, so pick one by eye, such as 2.8, with the camera's focal length. `maxblur` is a share of the canvas's width, and `maxBlur` of its height: multiply by the aspect ratio. null3D blurs the near and far fields apart, so sharp objects spread no halo. |
|
|
70
66
|
| `FilmPass`, `GlitchPass`, `HalftonePass`, `DotScreenPass`, `RenderPixelatedPass` | A custom effect for each | Port each shader as a `ShaderPass`. |
|
|
@@ -122,7 +118,7 @@ The WGSL must be a template literal right after a `/* wgsl */` comment, or a `.w
|
|
|
122
118
|
| A `sampler2D` uniform, such as a noise texture | `var noise: texture_2d<f32>;` and the effect's `textures` option, read with `textureSampleLevel(noise, noiseSampler, uv, 0.0)` |
|
|
123
119
|
| A render target's `texture` from an earlier pass | A pass's texture from `textures.fromPass(pass)` in `textures`, read at `effectPassUv(uv)` |
|
|
124
120
|
|
|
125
|
-
Uniforms are `f32`, `i32`, `u32`, `vec2f`, `vec3f` or `vec4f`,
|
|
121
|
+
Uniforms are `f32`, `i32`, `u32`, `vec2f`, `vec3f` or `vec4f`, in 32 floats less one for each texture in the `textures` option. Each `vec3f` and `vec4f` starts a new group of four floats. A `vec3f` also takes a color string, which the engine converts from sRGB to linear. A uniform name that the WGSL does not declare fails the TypeScript check, and throws [E1216](../errors/E1216.md) when the sketch runs. [Porting shaders](threejs-shaders.md) maps the rest of GLSL to WGSL.
|
|
126
122
|
|
|
127
123
|
### Example: RGBShiftShader
|
|
128
124
|
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: porting/threejs-shaders
|
|
3
3
|
title: "Porting shaders: GLSL, onBeforeCompile and TSL"
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.3"
|
|
6
4
|
summary: "GLSL to WGSL; three.js built-ins to engine built-ins; worked examples."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Porting shaders: GLSL, onBeforeCompile and TSL
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
```mermaid
|
|
14
10
|
flowchart LR
|
|
15
11
|
glsl["ShaderMaterial<br/>GLSL"] --> pick{"What does<br/>the shader do?"}
|
|
@@ -17,7 +13,8 @@ flowchart LR
|
|
|
17
13
|
tsl["TSL or<br/>node material"] --> pick
|
|
18
14
|
pick -- "changes a lit surface" --> surface["Surface function"]
|
|
19
15
|
pick -- "moves vertices" --> offset["vertexOffset"]
|
|
20
|
-
pick -- "
|
|
16
|
+
pick -- "changes each light's response" --> lobe["Lobe function"]
|
|
17
|
+
pick -- "draws its own fixed light" --> full["Full shader"]
|
|
21
18
|
pick -- "full-screen pass" --> effect["post.addEffect"]
|
|
22
19
|
```
|
|
23
20
|
|
|
@@ -32,7 +29,8 @@ A custom material takes its WGSL in one `wgsl` option, as a template literal tag
|
|
|
32
29
|
| Changes the color, roughness, emission or alpha of a lit surface | A surface function |
|
|
33
30
|
| Moves vertices | `vertexOffset`, with a surface function where needed |
|
|
34
31
|
| Ignores the lights, such as a hologram or a fresnel glow | An unlit function, `fn unlit(input: SurfaceInput) -> vec4f`, which returns the color and the opacity with no lighting ([Unlit surfaces](../shaders/surface-functions.md#unlit-surfaces)) |
|
|
35
|
-
|
|
|
32
|
+
| Adds a specular lobe for each light, such as a rim or a banded highlight | A lobe function, `fn lobe(input: LobeInput) -> vec3f`, called for the main directional light and each point and spot light. It adds to that light's specular, and the base lighting stays, so a toon look sets `s.baseColor` to black and `s.roughness` to 1 ([A material's own lobe](../shaders/surface-functions.md#a-materials-own-lobe), [toon recipe](threejs-materials.md)) |
|
|
33
|
+
| Lights the surface its own way with fixed lights | A full shader with the `null3d::lighting` helpers. It gets no scene lights and no uniforms, so its light directions and colors are constants in the WGSL |
|
|
36
34
|
| Is a full-screen pass | `post.addEffect`, or `render.addPass({ kind: 'fullscreen' })` when it writes a target of its own ([Porting post-processing](threejs-postprocessing.md)) |
|
|
37
35
|
| Draws into a texture for another material | A scene pass of `render.addPass` |
|
|
38
36
|
|
|
@@ -62,7 +60,7 @@ A surface function keeps instancing, skinning, shadows, fog and both GPU paths.
|
|
|
62
60
|
| `lessThan(a, b)` | `a < b`, which gives a vector of bools |
|
|
63
61
|
| `mix`, `step`, `smoothstep`, `clamp`, `fract`, `pow`, `dot`, `cross`, `normalize`, `reflect` | The same names |
|
|
64
62
|
| `c ? a : b` | `select(b, a, c)`, with the false value first and the condition last |
|
|
65
|
-
| `v.xy = w;` | `v = vec3f(w, v.z);`.
|
|
63
|
+
| `v.xy = w;` | `v = vec3f(w, v.z);`. The null3D build rejects an assignment to a swizzle ([WGSL rules](../shaders/wgsl-rules.md#language-features)). |
|
|
66
64
|
| `discard;` | `discard;` |
|
|
67
65
|
| `gl_FrontFacing` | `input.frontFacing` |
|
|
68
66
|
| `gl_FragCoord` | `input.fragCoord`, from the top left (see [Conventions](#conventions)) |
|
|
@@ -90,11 +88,11 @@ The engine gives each surface function and vertex offset the values that three.j
|
|
|
90
88
|
| `normalMatrix`, in view space | `input.normal` is already in world space. Multiply it by `camera.view` for view space. |
|
|
91
89
|
| Varyings such as `vWorldPosition`, `vViewDir` and `vNormal` | `input.worldPosition`, `input.viewDirection`, `input.normal` |
|
|
92
90
|
| `instanceMatrix`, `instanceColor` | The engine applies each row's transform. A batch made with `colors: true` multiplies each row's color into `input.vertexColor`. |
|
|
93
|
-
| An `InstancedBufferAttribute` such as a phase per instance | `object.values`, four floats per row from a batch made with `values: true` |
|
|
91
|
+
| An `InstancedBufferAttribute` such as a phase per instance | `object.values`, four floats per row from a batch made with `values: true`. For more than four, pack them, or keep the rest in a data texture and read it with `textureLoad` at the row's place, `input.instance` |
|
|
94
92
|
| A `time` uniform that the app updates | `frame.time` |
|
|
95
93
|
| The fog, tone mapping and color space chunks | Nothing: the engine adds fog after the surface function, and the final pass tone maps and encodes once. |
|
|
96
94
|
| The `<common>` and `<packing>` helpers | `null3d::math`, `null3d::depth` |
|
|
97
|
-
| The lighting chunks and light uniforms | The engine lights a surface function. A
|
|
95
|
+
| The lighting chunks and light uniforms | The engine lights a surface function. A lobe function reads each main, point and spot light. |
|
|
98
96
|
|
|
99
97
|
The engine works relative to the camera, so positions stay precise far from the origin. That is why `object.worldMatrix` and `camera.view` hold no camera translation.
|
|
100
98
|
|
|
@@ -109,7 +107,7 @@ The engine works relative to the camera, so positions stay precise far from the
|
|
|
109
107
|
|
|
110
108
|
## ShaderMaterial and RawShaderMaterial
|
|
111
109
|
|
|
112
|
-
1. List the uniforms. Each becomes a field of `struct Uniforms`, with its first value in the `uniforms` option. A `sampler2D` uniform becomes `var name: texture_2d<f32>;` and an entry of the `textures` option, and a `sampler2DArray` becomes `var name: texture_2d_array<f32>;`. A material takes up to 6 textures, fixed when you create it.
|
|
110
|
+
1. List the uniforms. Each becomes a field of `struct Uniforms`, with its first value in the `uniforms` option. A `sampler2D` uniform becomes `var name: texture_2d<f32>;` and an entry of the `textures` option, and a `sampler2DArray` becomes `var name: texture_2d_array<f32>;`. A material takes up to 6 textures, fixed when you create it. Textures of one size can join in a texture array, which takes one slot.
|
|
113
111
|
2. Replace each update such as `material.uniforms.uSpeed.value = 2` with `material.set({ speed: 2 })`. A name that `struct Uniforms` lacks fails the type check, and throws [E1216](../errors/E1216.md) when the sketch runs.
|
|
114
112
|
3. Read the vertex shader. When it only places the vertices and passes varyings on, delete it. When it moves vertices, port that part as `vertexOffset`.
|
|
115
113
|
4. Read the fragment shader. Map its varyings to the surface input, and its output to the surface's fields. A lit look goes to `baseColor`, `roughness` and `metalness`. An unlit look goes to the color that `fn unlit` returns, in place of `surface`. Transparency goes to `alpha`, or to the opacity that `fn unlit` returns, with the matching `alphaMode`.
|
|
@@ -118,7 +116,7 @@ The engine works relative to the camera, so positions stay precise far from the
|
|
|
118
116
|
|
|
119
117
|
A `RawShaderMaterial` adds nothing by itself, so every matrix and attribute is in its source. The same steps apply.
|
|
120
118
|
|
|
121
|
-
Uniforms take `f32`, `i32`, `u32`, `vec2f`, `vec3f` and `vec4f`,
|
|
119
|
+
Uniforms take `f32`, `i32`, `u32`, `vec2f`, `vec3f` and `vec4f`, in 32 numbers less one for each texture. Each `vec3f` and `vec4f` starts a group of four, so a matrix passed as four `vec4f` values takes 16. three.js's `elements` array and the engine both store a matrix by column, so pass its four columns. Keep more numbers in a data texture from `textures.fromData`, and read them with `textureLoad`. Rename a uniform called `color`, `roughness` or another standard value, because those names belong to the material.
|
|
122
120
|
|
|
123
121
|
## onBeforeCompile patches
|
|
124
122
|
|
|
@@ -130,7 +128,7 @@ Uniforms take `f32`, `i32`, `u32`, `vec2f`, `vec3f` and `vec4f`, up to 32 number
|
|
|
130
128
|
| Adds glow in `<emissivemap_fragment>` | `s.emissive` |
|
|
131
129
|
| Adds `discard`, for a dissolve or a cut-out | `alphaMode: 'mask'` and `s.alpha` |
|
|
132
130
|
| Adds a varying such as a world position | `input.worldPosition` |
|
|
133
|
-
| Replaces a lighting chunk | A full shader
|
|
131
|
+
| Replaces a lighting chunk | A lobe function, beside the base lighting; a full shader only when its lights can be fixed in the WGSL |
|
|
134
132
|
| Keeps `shader.uniforms` to update them later | `material.set({ ... })`, or `frame.time` for time |
|
|
135
133
|
|
|
136
134
|
Keep the original material's standard values on the new material. `materials.shader` takes every `materials.standard` option but the texture maps, and `defaultSurface()` starts from them. The original's maps become textures of the WGSL, which the surface function samples.
|
|
@@ -253,6 +251,10 @@ const foliage = materials.shader({
|
|
|
253
251
|
|
|
254
252
|
### A dissolve from TSL
|
|
255
253
|
|
|
254
|
+

|
|
255
|
+
|
|
256
|
+
The dissolve port at progress 0, 0.3, 0.5 and 0.7.
|
|
257
|
+
|
|
256
258
|
```js
|
|
257
259
|
// three.js TSL
|
|
258
260
|
const progress = uniform(0);
|
|
@@ -288,13 +290,13 @@ const dissolve = materials.shader({
|
|
|
288
290
|
|
|
289
291
|
- A `textureSample` inside a branch that differs between pixels breaks a WGSL rule that GLSL does not have. Chrome refuses such a shader. Sample before the branch, or use `textureSampleLevel`.
|
|
290
292
|
- `%` is not `mod`: negative inputs give other results.
|
|
291
|
-
-
|
|
293
|
+
- The build rejects an assignment to a swizzle. Write the whole vector.
|
|
292
294
|
- Flip y for `gl_FragCoord` and for full-screen coordinates.
|
|
293
295
|
- Replace three.js's depth formulas with the `null3d::depth` helpers.
|
|
294
296
|
- Convert raw sRGB constants from a `ShaderMaterial` to linear.
|
|
295
297
|
- three.js's `normalMatrix` works in view space, and null3D's normals are in world space.
|
|
296
298
|
- WGSL does not mix `f32` and `i32` in arithmetic, so convert explicitly.
|
|
297
|
-
- A surface function shares its file with the engine's template. Rename GLSL helpers whose names clash with it, such as `frame`, `camera`, `object`, `material`, `shade` or `
|
|
299
|
+
- A surface function shares its file with the engine's template. Rename GLSL helpers whose names clash with it, such as `frame`, `camera`, `object`, `material`, `shade` or `fs` ([Rules](../shaders/surface-functions.md#rules) lists every name).
|
|
298
300
|
- Test on WebGL2 with `?gpu=webgl2`. The translated GLSL can meet limits that the WGSL did not.
|
|
299
301
|
|
|
300
302
|
## Related pages
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: porting/threejs-unsupported
|
|
3
3
|
title: Unsupported three.js features
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.3"
|
|
6
4
|
summary: "three.js features with no null3D equivalent, with workarounds."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Unsupported three.js features
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
Most three.js features have a null3D equivalent, which the [three.js to null3D mapping](threejs-mapping.md) gives. This page lists the features that have none, and the parts of features that behave differently. Each entry gives the workaround.
|
|
14
10
|
|
|
15
11
|
Check this list before a port starts. When a feature is central to the app, such as an XR experience, keep the app in three.js. Never drop a feature without telling the app's owner.
|
|
@@ -35,12 +31,14 @@ Do not draw a three.js canvas over the null3D canvas to keep one effect. Two GPU
|
|
|
35
31
|
|
|
36
32
|
| three.js | In null3D | Workaround |
|
|
37
33
|
| --- | --- | --- |
|
|
38
|
-
| `MeshToonMaterial` | Surface functions cannot read the scene's lights |
|
|
34
|
+
| `MeshToonMaterial` | Surface functions cannot read the scene's lights | A toon surface function with the light's direction as a uniform, or a lobe function that follows each light ([Porting materials and textures](threejs-materials.md#meshtoonmaterial-and-meshmatcapmaterial)) |
|
|
39
35
|
| Standard maps on a `ShaderMaterial` | A custom material takes no standard maps, such as `map` or `normalMap` | Declare up to 6 textures in the WGSL, and pass them with the `textures` option ([Porting shaders](threejs-shaders.md)) |
|
|
36
|
+
| An `InstancedBufferAttribute` with more than four floats for each instance | A batch row carries four values and a color | Pack the data into the four values. Or keep the rest in a data texture from `textures.fromData`, and read it with `textureLoad` at the row's place, `input.instance` ([Per-row values](../concepts/instances.md#per-row-values)) |
|
|
37
|
+
| A `ShaderMaterial` whose uniforms pass 32 numbers | A custom material's uniforms fit in 32 numbers, less one for each texture | Keep the rest in a data texture, and read it with `textureLoad` ([Porting shaders](threejs-shaders.md)) |
|
|
40
38
|
| `onBeforeCompile` shader chunks | The engine has no shader chunks to patch | A surface function or a vertex offset function |
|
|
41
39
|
| `material.alphaMap` | No separate alpha map | Copy the map's green channel into the base color map's alpha |
|
|
42
40
|
| `PointsMaterial.alphaMap` | No alpha map on points | Put the alpha in the points' `map` |
|
|
43
|
-
| Clipping planes | No clipping planes | A surface function with `alphaMode: 'mask'
|
|
41
|
+
| Clipping planes | No clipping planes | A surface function with `alphaMode: 'mask'` ([Porting materials and textures](threejs-materials.md)) |
|
|
44
42
|
|
|
45
43
|
## Objects and scenes
|
|
46
44
|
|
|
@@ -80,6 +78,8 @@ Do not draw a three.js canvas over the null3D canvas to keep one effect. Two GPU
|
|
|
80
78
|
| drei `<AdaptiveDpr>` with `performance.regress()` | The governor follows frame times, not camera movement | Remove the `regress()` calls |
|
|
81
79
|
| Pointer events on objects behind the closest one | Only the closest object and its parents get an event | `scene.raycastAll` finds the objects behind, nearest first |
|
|
82
80
|
|
|
81
|
+
null3D's own [contact shadows](../concepts/shadows.md#contact-shadows) are another effect: the short dark line where an object meets the ground, cast toward the main directional light.
|
|
82
|
+
|
|
83
83
|
[Porting React Three Fiber](react-three-fiber.md) covers the rest of a React Three Fiber port.
|
|
84
84
|
|
|
85
85
|
## Related pages
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: porting/verification
|
|
3
3
|
title: Verifying a port
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.3"
|
|
6
4
|
summary: "Parity images per camera view; performance comparison; the WebGL2 path; phones."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Verifying a port
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
```mermaid
|
|
14
10
|
flowchart LR
|
|
15
11
|
views["Choose 3 to 8<br/>camera views"] --> baseline["Capture each view<br/>in the three.js app"]
|
package/docs/shaders/builtins.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: shaders/builtins
|
|
3
3
|
title: Built-in shader inputs
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.1"
|
|
6
4
|
summary: "Camera, time, object and instance values available to custom shaders, with the camera's and the object's matrices and ids."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Built-in shader inputs
|
|
10
8
|
|
|
11
|
-
>
|
|
9
|
+
> The built-in values hold no light values. Pass a light's direction or color to a material as a uniform.
|
|
12
10
|
|
|
13
11
|
A custom material's WGSL reads four built-in values besides its inputs: `frame`, `camera`, `object` and `material`. The engine fills them before it calls your functions, in the vertex offset and in the surface function alike. Read them anywhere in your WGSL, as global values. A [full shader](../guides/custom-shaders.md#full-shaders) imports `frame`, `camera` and `object` from `null3d::builtins`, and fills them with `fill_builtins`.
|
|
14
12
|
|
|
@@ -24,6 +22,10 @@ fn surface(input: SurfaceInput) -> Surface {
|
|
|
24
22
|
}
|
|
25
23
|
```
|
|
26
24
|
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
One material that reads frame, camera and object values. It is not the opening example.
|
|
28
|
+
|
|
27
29
|
## `frame`
|
|
28
30
|
|
|
29
31
|
The values of the frame, the same for every draw in it.
|
|
@@ -103,7 +105,7 @@ The custom material's uniforms, which the WGSL declares as `struct Uniforms`. [S
|
|
|
103
105
|
|
|
104
106
|
## What the inputs cost
|
|
105
107
|
|
|
106
|
-
|
|
108
|
+
A value that a material does not read costs nothing. The inputs in this table cost something, so only WGSL that reads them gets them:
|
|
107
109
|
|
|
108
110
|
| Input | Its cost, only where the WGSL reads it |
|
|
109
111
|
| --- | --- |
|
|
@@ -116,6 +118,15 @@ The values above that a material does not read cost it nothing. A few inputs cos
|
|
|
116
118
|
|
|
117
119
|
The pixel's position, the camera's values and `object.position` cost nothing.
|
|
118
120
|
|
|
121
|
+
A mesh that lacks the vertex colors, the vertex record or the tangent that a material reads does not draw with that material. A mesh without second texture coordinates gives its first set in their place.
|
|
122
|
+
|
|
123
|
+
<details>
|
|
124
|
+
<summary>Technical details: how the plugin finds the inputs a material reads</summary>
|
|
125
|
+
|
|
126
|
+
The plugin finds which fields the WGSL reads when it builds the material. It counts a field only where the WGSL reads it from a value of the input's type, such as the `input: VertexInput` parameter. So a structure of your own may name a field `tangent` or `colors` at no cost.
|
|
127
|
+
|
|
128
|
+
</details>
|
|
129
|
+
|
|
119
130
|
## Positions relative to the camera
|
|
120
131
|
|
|
121
132
|
The engine draws everything relative to the camera, so positions stay precise far from the origin of the world. The surface input's `relativePosition` is the position of a point relative to the camera. It is exact near the camera wherever the camera is. Use it for distances, fades and effects that depend on the view.
|
package/docs/shaders/library.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: shaders/library
|
|
3
3
|
title: Shader library and imports
|
|
4
|
-
|
|
5
|
-
since: "0.1"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "The WGSL modules that ship with the engine: math, noise, color, lighting, fog, vertex, depth and signed distance helpers, and how to import them."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -10,7 +9,7 @@ summary: "The WGSL modules that ship with the engine: math, noise, color, lighti
|
|
|
10
9
|
|
|
11
10
|
# Shader library and imports
|
|
12
11
|
|
|
13
|
-
>
|
|
12
|
+
> A custom material's surface function, vertex offset or full shader can call these modules.
|
|
14
13
|
|
|
15
14
|
The shader library is a set of WGSL modules that ship with the engine. A shader imports a module with an `#import` line, and the build adds the functions that the shader calls. The build then translates the shader for WebGL2, so each function works on both GPU paths. The engine's own shaders use the same modules.
|
|
16
15
|
|
|
@@ -401,7 +400,9 @@ The brightest linear color that the engine stores in a 16-bit float target: one
|
|
|
401
400
|
fn limit_hdr(c: vec3f) -> vec3f
|
|
402
401
|
```
|
|
403
402
|
|
|
404
|
-
A linear color with each channel no brighter than HDR_LIMIT, so that a 16-bit float target holds it. Infinity becomes HDR_LIMIT, and a NaN becomes 0, so it draws black.
|
|
403
|
+
A linear color with each channel no brighter than HDR_LIMIT, so that a 16-bit float target holds it. Infinity becomes HDR_LIMIT, and a NaN becomes 0, so it draws black.
|
|
404
|
+
|
|
405
|
+
The NaN test reads the bits: an exponent of all ones with a mantissa that is not 0. WGSL lets a compiler assume that no NaN exists, so a test such as `c != c` may fold to false, and `min` may return either operand for a NaN. A NaN that stays in the scene color spreads through bloom's blur over the whole picture.
|
|
405
406
|
|
|
406
407
|
### `luminance`
|
|
407
408
|
|
|
@@ -605,7 +606,7 @@ How much the change of the normal across a pixel widens the highlight, Filament'
|
|
|
605
606
|
const SPECULAR_AA_LIMIT: f32 = 0.01;
|
|
606
607
|
```
|
|
607
608
|
|
|
608
|
-
The most that the specular anti-aliasing kernel adds to the squared GGX alpha, so silhouettes do not turn matte: half of Filament's threshold, squared as Filament squares it. The lower limit flickers less on small glossy shapes
|
|
609
|
+
The most that the specular anti-aliasing kernel adds to the squared GGX alpha, so silhouettes do not turn matte: half of Filament's threshold, squared as Filament squares it. The lower limit flickers less on small glossy shapes.
|
|
609
610
|
|
|
610
611
|
### `lambert`
|
|
611
612
|
|
|
@@ -887,7 +888,9 @@ The light that a PBR surface reflects from an environment map. The prefiltered r
|
|
|
887
888
|
|
|
888
889
|
## `null3d::fog`
|
|
889
890
|
|
|
890
|
-
The scene's fog. A fog factor runs from 0, no fog, to 1, where the fog color hides the surface. Fog measures each point's straight-line distance from the camera, so a point keeps its fog as the camera turns. The fog can thin with height, and can glow toward the sun. The engine's shaders mix their exposed linear color with the fog before any tone mapping and encoding.
|
|
891
|
+
The scene's fog. A fog factor runs from 0, no fog, to 1, where the fog color hides the surface. Fog measures each point's straight-line distance from the camera, so a point keeps its fog as the camera turns. The fog can thin with height, and can glow toward the sun. The engine's shaders mix their exposed linear color with the fog before any tone mapping and encoding.
|
|
892
|
+
|
|
893
|
+
Per pixel, the fog costs a square root, one `exp` and a `pow` for the sun glow. Fog that thins with height adds an `exp` and a division. The fog is a branch on the frame's values, not a permutation bit, so every scene shares the same shader builds.
|
|
891
894
|
|
|
892
895
|
### `OFF`
|
|
893
896
|
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: shaders/surface-functions
|
|
3
3
|
title: Surface functions
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.1"
|
|
6
4
|
summary: "The surface record; normals for the diffuse light and the sky's light; occlusion counted once; uniforms and textures; reflections; transmission; light through thin surfaces; clear coat and sheen; vertex-offset functions; the coverage of a shadow caster and where its lookup reads; a material's own lobe; values per row of a batch; second texture coordinates, pixel position and instance index."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Surface functions
|
|
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.
|
|
12
|
-
|
|
13
9
|
A surface function changes how a material's surface looks, and keeps the engine's lighting. You write it in WGSL. For each pixel, the engine gives it a `SurfaceInput`, and it returns a `Surface`: the base color, roughness, metalness, normal and light of that point. The engine then lights the surface with the scene's lights and shadows, as it lights a standard material. The function works on every GPU path, because the null3D Vite plugin builds it into the standard material's shader for WebGPU and WebGL2.
|
|
14
10
|
|
|
15
11
|
```ts
|
|
@@ -33,6 +29,10 @@ export default defineSketch(({ scene, geometry, materials }) => {
|
|
|
33
29
|
});
|
|
34
30
|
```
|
|
35
31
|
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
Top row: each pair must match. Bottom row: surface functions that change the look.
|
|
35
|
+
|
|
36
36
|
## Make a custom material
|
|
37
37
|
|
|
38
38
|
`materials.shader(options)` makes a custom material. Its `wgsl` option holds the WGSL. Its `uniforms` and `textures` options give the values of the WGSL's [uniforms](#uniforms) and [textures](#textures). Its other options are those of `materials.standard`, but the texture maps, which a custom material samples as textures of its own. [Materials](../api/materials.md) lists them.
|
|
@@ -97,7 +97,9 @@ A `Surface` holds the values that the engine lights. Colors are linear, as the e
|
|
|
97
97
|
| `iridescenceIor` | `f32` | The film's index of refraction, 1 or more |
|
|
98
98
|
| `iridescenceThickness` | `f32` | The film's thickness in nanometers |
|
|
99
99
|
|
|
100
|
-
`defaultSurface(input)` returns the surface that the material's own options make. The base color is `color` times the vertex color. `metalness`, `roughness` and the emissive light come from the options too. The normal, the diffuse normal and the sky's normal are the input's normal.
|
|
100
|
+
`defaultSurface(input)` returns the surface that the material's own options make. The base color is `color` times the vertex color. `metalness`, `roughness` and the emissive light come from the options too. The normal, the diffuse normal and the sky's normal are the input's normal.
|
|
101
|
+
|
|
102
|
+
The occlusion is 1, and it multiplies screen-space occlusion. The irradiance and the reflection are zero. The transmission, the thickness, the diffuse transmission and its color, and the layers' values are the material's, and the coat's normal is the input's. Start from it, and change only the fields that your look needs:
|
|
101
103
|
|
|
102
104
|
```wgsl
|
|
103
105
|
fn surface(input: SurfaceInput) -> Surface {
|
|
@@ -147,7 +149,9 @@ fn surface(input: SurfaceInput) -> Surface {
|
|
|
147
149
|
|
|
148
150
|
## A normal for the sky's light
|
|
149
151
|
|
|
150
|
-
A surface can light the sky's light by a normal of its own, and keep its other normals for the sun. The sky's light is the ambient and hemisphere lights and the environment's diffuse light. It also takes in the diffuse light of the reflection probes and the probe grid.
|
|
152
|
+
A surface can light the sky's light by a normal of its own, and keep its other normals for the sun. The sky's light is the ambient and hemisphere lights and the environment's diffuse light. It also takes in the diffuse light of the reflection probes and the probe grid.
|
|
153
|
+
|
|
154
|
+
A crown of leaves uses this with a bent normal, the mean open direction from each point toward the sky. A leaf deep in the crown then takes its sky light from the gaps above it. The sun still lights it by its own normal.
|
|
151
155
|
|
|
152
156
|
```wgsl
|
|
153
157
|
fn surface(input: SurfaceInput) -> Surface {
|
|
@@ -165,7 +169,9 @@ fn surface(input: SurfaceInput) -> Surface {
|
|
|
165
169
|
|
|
166
170
|
## Occlusion counted once
|
|
167
171
|
|
|
168
|
-
`s.occlusion` darkens the light that reaches the point from all directions: the ambient and hemisphere lights, the environment's light and the probes' light. Where [ambient occlusion](../concepts/post-processing.md#ambient-occlusion) draws, the engine multiplies `s.occlusion` by the screen's occlusion. That suits an occlusion map, which holds creases too small for the screen to see.
|
|
172
|
+
`s.occlusion` darkens the light that reaches the point from all directions: the ambient and hemisphere lights, the environment's light and the probes' light. Where [ambient occlusion](../concepts/post-processing.md#ambient-occlusion) draws, the engine multiplies `s.occlusion` by the screen's occlusion. That suits an occlusion map, which holds creases too small for the screen to see.
|
|
173
|
+
|
|
174
|
+
An occlusion that a bake took from the same shapes that ambient occlusion sees darkens twice instead. A crown's occlusion, baked from its own leaves, is such an occlusion. Set `s.occlusionByMinimum` to `true`, and the engine takes the smaller of the two, so the shade counts once:
|
|
169
175
|
|
|
170
176
|
```wgsl
|
|
171
177
|
fn surface(input: SurfaceInput) -> Surface {
|
|
@@ -276,15 +282,23 @@ const metal = materials.shader({ wgsl: worn, color: '#b0b4b8', textures: { detai
|
|
|
276
282
|
|
|
277
283
|
- Sample a texture with the WGSL texture functions: `textureSample`, `textureSampleLevel`, `textureSampleBias`, `textureSampleGrad`, `textureGather` and `textureLoad`. `textureDimensions` and `textureNumLevels` work too. Pass the texture straight to the function. The engine keeps each texture as a layer of a texture array, so it adds the layer to each such call. A texture cannot go to a function of your own, so sample it where you need it.
|
|
278
284
|
- `textureGather` draws on WebGPU alone: WebGL2's shader language has no gather, so a material that uses it fails to link there. Read the four texels with `textureLoad` where a material draws on both paths.
|
|
279
|
-
- A texture array declares `var name: texture_2d_array<f32>;` instead, and the surface function picks the layer. Give the slot a texture of several layers, and each texture function takes the layer after the coordinates: `textureSampleLevel(facades, facadesSampler, uv, layer, 0.0)`.
|
|
285
|
+
- A texture array declares `var name: texture_2d_array<f32>;` instead, and the surface function picks the layer. Give the slot a texture of several layers, and each texture function takes the layer after the coordinates: `textureSampleLevel(facades, facadesSampler, uv, layer, 0.0)`.
|
|
286
|
+
- The layer is the texture's own, from 0 to its depth less 1, so one array serves every facade or window in a set and the shader chooses one for each pixel. `textureNumLayers(name)` gives the number of layers. A texture array takes one map slot and one number of the uniforms, as a 2D texture does.
|
|
280
287
|
- A vertex offset samples textures too, with `textureSampleLevel` or `textureLoad`, as WGSL allows in a vertex shader. A height map then moves each vertex.
|
|
281
288
|
- Each texture's sampler takes the `wrap` and `filter` options of the texture. The `colorSpace` option says whether sampling turns sRGB colors into linear ones, as for the maps of a standard material.
|
|
282
289
|
- Until a texture's image is on the GPU, sampling it gives white: `vec4f(1.0)`. So does a texture that the WGSL declares and the `textures` option does not give. Multiply by a texture, and the material draws with its own values until the image arrives.
|
|
283
|
-
- A material samples up to 6 textures. Each texture takes one of the 32 numbers of the uniforms, so a material with 2 textures has 30 numbers for its uniforms. On WebGL2
|
|
290
|
+
- A material samples up to 6 textures. Each texture takes one of the 32 numbers of the uniforms, so a material with 2 textures has 30 numbers for its uniforms. On WebGL2, a material whose textures and maps together pass the shader stage's texture units is refused with [E1209](../errors/E1209.md).
|
|
284
291
|
- The textures are fixed when the material is created. Make a second material for another set of textures.
|
|
285
292
|
- A texture is 2D, with one layer: an image, a KTX2 file or data with a depth of 1. A texture array comes from `textures.fromData` with a `depth`, or from a KTX2 file that holds layers, and its layers all have the texture's size. Data textures of `rgba16float` sample with filtering too.
|
|
286
293
|
- In TypeScript, the `textures` option takes only the names that the WGSL declares. A wrong name fails the type check.
|
|
287
294
|
|
|
295
|
+
<details>
|
|
296
|
+
<summary>Technical details: texture units on WebGL2</summary>
|
|
297
|
+
|
|
298
|
+
On WebGL2 the engine's lighting takes 7 of a fragment shader's texture units, which are at least 16. A lit material with all 6 textures thus leaves 3 units free on a device with 16. The engine refuses the material before the device fails to link its shader.
|
|
299
|
+
|
|
300
|
+
</details>
|
|
301
|
+
|
|
288
302
|
A facade material samples one texture array of six window images, and picks the window for each pixel:
|
|
289
303
|
|
|
290
304
|
```ts
|
|
@@ -354,16 +368,18 @@ A surface function reads the depth of the opaque scene behind its point. The eng
|
|
|
354
368
|
| `sceneDistance(uv)` | The distance in front of the camera of the surface at `uv`, in world units |
|
|
355
369
|
|
|
356
370
|
```wgsl
|
|
371
|
+
#import null3d::depth::{is_orthographic}
|
|
372
|
+
|
|
357
373
|
struct Uniforms { shallow: vec3f, deep: vec3f, foam: vec3f }
|
|
358
374
|
|
|
359
375
|
/// The distance in front of the camera of a depth value, as sceneDistance converts the copy's.
|
|
360
376
|
fn distance_of(depth: f32) -> f32 {
|
|
361
|
-
let near =
|
|
362
|
-
let far =
|
|
363
|
-
if
|
|
364
|
-
return
|
|
377
|
+
let near = camera.near;
|
|
378
|
+
let far = camera.far;
|
|
379
|
+
if is_orthographic(camera.projection) {
|
|
380
|
+
return far - depth * (far - near);
|
|
365
381
|
}
|
|
366
|
-
return far
|
|
382
|
+
return near * far / (near + depth * (far - near));
|
|
367
383
|
}
|
|
368
384
|
|
|
369
385
|
fn surface(input: SurfaceInput) -> Surface {
|
|
@@ -493,6 +509,10 @@ const stone = materials.shader({ wgsl: wet, color: '#8d8a84', roughness: 0.85 })
|
|
|
493
509
|
|
|
494
510
|
A vertex offset moves each vertex of the mesh before the engine places the object in the world. You write `fn vertexOffset`, which returns how far to move the vertex, in the mesh's own space. The engine then applies the object's transform and instancing, and lights the moved surface:
|
|
495
511
|
|
|
512
|
+

|
|
513
|
+
|
|
514
|
+
The wave from this section.
|
|
515
|
+
|
|
496
516
|
```wgsl
|
|
497
517
|
struct Uniforms { height: f32, waves: f32 }
|
|
498
518
|
|
|
@@ -587,7 +607,9 @@ A custom material's levels of detail fade, and so do the edges of its distance b
|
|
|
587
607
|
|
|
588
608
|
## Built-in values
|
|
589
609
|
|
|
590
|
-
Besides its inputs, a custom material reads the built-in values `frame`, `camera`, `object` and `material` anywhere in its WGSL. The sketch time, `frame.time`, animates a look. The origin of each object, `object.position`, gives each object its own look from one material. On the rows of a batch made with `values: true`, `object.values` holds the row's four numbers, such as a phase or a tint ([Instances and batching](../concepts/instances.md#per-row-values)).
|
|
610
|
+
Besides its inputs, a custom material reads the built-in values `frame`, `camera`, `object` and `material` anywhere in its WGSL. The sketch time, `frame.time`, animates a look. The origin of each object, `object.position`, gives each object its own look from one material. On the rows of a batch made with `values: true`, `object.values` holds the row's four numbers, such as a phase or a tint ([Instances and batching](../concepts/instances.md#per-row-values)).
|
|
611
|
+
|
|
612
|
+
The material also reads the camera's `view`, `projection`, `near` and `far`, and the object's `worldMatrix`, `normalMatrix` and `id`. [Built-in shader inputs](builtins.md) lists every field.
|
|
591
613
|
|
|
592
614
|
## Library functions
|
|
593
615
|
|
|
@@ -608,12 +630,25 @@ fn surface(input: SurfaceInput) -> Surface {
|
|
|
608
630
|
|
|
609
631
|
Your WGSL shares one file with the engine's standard material, so a few rules apply besides the [WGSL rules for portable shaders](wgsl-rules.md):
|
|
610
632
|
|
|
611
|
-
- Do not declare a name that the engine declares. The build stops at your line when a name clashes. The
|
|
633
|
+
- Do not declare a name that the engine declares. The build stops at your line when a name clashes. The names `surface`, `vertexOffset`, `lobe`, `unlit` and `coverage` are yours to declare.
|
|
612
634
|
- Import library items by name, as in `#import null3d::noise::{fbm3}`. An import of a whole module reserves the module's name. After `#import null3d::color`, no name in the file can be `color`.
|
|
613
635
|
- The WGSL cannot hold directives such as `enable`.
|
|
614
636
|
- Do not declare a name that ends in `Sampler` after a texture's name, such as `detailSampler` beside `detail`. The engine declares it.
|
|
615
637
|
- Call `dpdx`, `dpdy`, `fwidth` and `textureSample` in uniform control flow, outside branches that differ between pixels. Chrome rejects the shader otherwise.
|
|
616
638
|
|
|
639
|
+
<details>
|
|
640
|
+
<summary>Technical details: the names that the engine declares</summary>
|
|
641
|
+
|
|
642
|
+
Always declared: `SurfaceInput`, `Surface`, `VertexInput`, `surface_place`, `surface_input`, `LobeInput`, `defaultSurface`, `shade`, `light_surface`, `frame`, `camera`, `object`, `material`, `FrameValues`, `CameraValues`, `ObjectValues`, `fill_builtins`, `engine_frame`, `material_row`, `load_material_uniforms`, `custom_value`, `custom_texture_layers`, `load_custom_texture_layers`, `VertexIn`, `VertexOut`, `vs`, `fs`, `FLAT_SHADING`, `sceneDepth`, `sceneDistance`, `scene_depth_copy`, `scene_depth_texel`.
|
|
643
|
+
|
|
644
|
+
Library items that the standard material imports: `Material`, `Instance`, `InstanceIn`, `find_instance`, `clip_of`, `relative_position`, `world_normal`, `finish_material`, `finish_exposed_material`, `fogged`, `fragment_color`, `material_of`, `PbrMaterial`, `pbr_material`, `with_specular`, `dfg_lut`, `direct_light`, `indirect_diffuse`, `multiscatter_compensation`, `clustered_light`, `sun_shadow`.
|
|
645
|
+
|
|
646
|
+
Added when the WGSL reads `instance` or `object.id`: `object_ids`. Added when the WGSL reads the object's matrices: `affine_matrix`, `affine_normal_matrix`.
|
|
647
|
+
|
|
648
|
+
Added when the material declares a lobe, because the lobe's loop reads them: `clustered_lobed_light`, `Reflected`, `half_vector`, `cluster_lights`, `cluster_sample`, `light_of`, `grid_word`, `KIND_RECT`, `area_light`, `AreaTerms`, `area_terms`.
|
|
649
|
+
|
|
650
|
+
</details>
|
|
651
|
+
|
|
617
652
|
When the WGSL breaks a rule, the build stops with the file, line and column of the problem, as for any WGSL in your code.
|
|
618
653
|
|
|
619
654
|
## Related pages
|