@driftengine/core 3.61.0
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/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +9 -0
- package/dist/behavior/behaviorTree.d.ts +140 -0
- package/dist/behavior/behaviorTree.js +289 -0
- package/dist/build/shaderComments.d.ts +64 -0
- package/dist/build/shaderComments.js +0 -0
- package/dist/cinematic/player.d.ts +80 -0
- package/dist/cinematic/player.js +184 -0
- package/dist/cinematic/script.d.ts +63 -0
- package/dist/cinematic/script.js +141 -0
- package/dist/core/bootGate.d.ts +37 -0
- package/dist/core/bootGate.js +47 -0
- package/dist/core/loadTracker.d.ts +78 -0
- package/dist/core/loadTracker.js +106 -0
- package/dist/core/loop.d.ts +118 -0
- package/dist/core/loop.js +84 -0
- package/dist/core/messageQueue.d.ts +61 -0
- package/dist/core/messageQueue.js +104 -0
- package/dist/core/onceSet.d.ts +27 -0
- package/dist/core/onceSet.js +62 -0
- package/dist/core/preferences.d.ts +47 -0
- package/dist/core/preferences.js +140 -0
- package/dist/core/remoteSave.d.ts +154 -0
- package/dist/core/remoteSave.js +249 -0
- package/dist/core/rng.d.ts +64 -0
- package/dist/core/rng.js +72 -0
- package/dist/core/stepBudget.d.ts +91 -0
- package/dist/core/stepBudget.js +105 -0
- package/dist/core/storage.d.ts +52 -0
- package/dist/core/storage.js +85 -0
- package/dist/core/tickTrace.d.ts +72 -0
- package/dist/core/tickTrace.js +102 -0
- package/dist/core/timeCurve.d.ts +83 -0
- package/dist/core/timeCurve.js +107 -0
- package/dist/core/withDefaults.d.ts +21 -0
- package/dist/core/withDefaults.js +29 -0
- package/dist/dev/contactProbe.d.ts +41 -0
- package/dist/dev/contactProbe.js +58 -0
- package/dist/dev/fpsMeter.d.ts +45 -0
- package/dist/dev/fpsMeter.js +86 -0
- package/dist/environment/celestialClock.d.ts +141 -0
- package/dist/environment/celestialClock.js +262 -0
- package/dist/geometry/decal.d.ts +61 -0
- package/dist/geometry/decal.js +178 -0
- package/dist/geometry/filmPatch.d.ts +35 -0
- package/dist/geometry/filmPatch.js +112 -0
- package/dist/geometry/growable.d.ts +70 -0
- package/dist/geometry/growable.js +167 -0
- package/dist/geometry/lightVolume.d.ts +76 -0
- package/dist/geometry/lightVolume.js +65 -0
- package/dist/geometry/meshBuilder.d.ts +426 -0
- package/dist/geometry/meshBuilder.js +1184 -0
- package/dist/geometry/pixelFont.d.ts +59 -0
- package/dist/geometry/pixelFont.js +179 -0
- package/dist/geometry/ribbon.d.ts +101 -0
- package/dist/geometry/ribbon.js +546 -0
- package/dist/geometry/shellFill.d.ts +101 -0
- package/dist/geometry/shellFill.js +203 -0
- package/dist/geometry/spline.d.ts +162 -0
- package/dist/geometry/spline.js +527 -0
- package/dist/geometry/tangents.d.ts +30 -0
- package/dist/geometry/tangents.js +142 -0
- package/dist/geometry/textMesh.d.ts +51 -0
- package/dist/geometry/textMesh.js +57 -0
- package/dist/geometry/treeBuilder.d.ts +37 -0
- package/dist/geometry/treeBuilder.js +56 -0
- package/dist/host/display.d.ts +135 -0
- package/dist/host/display.js +114 -0
- package/dist/host/files.d.ts +25 -0
- package/dist/host/files.js +44 -0
- package/dist/host/lifecycle.d.ts +45 -0
- package/dist/host/lifecycle.js +28 -0
- package/dist/host/platformServices.d.ts +23 -0
- package/dist/host/platformServices.js +1 -0
- package/dist/host/screen.d.ts +49 -0
- package/dist/host/screen.js +90 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +320 -0
- package/dist/input/actionMap.d.ts +181 -0
- package/dist/input/actionMap.js +314 -0
- package/dist/input/activeDevice.d.ts +55 -0
- package/dist/input/activeDevice.js +83 -0
- package/dist/input/gamepadIdentity.d.ts +43 -0
- package/dist/input/gamepadIdentity.js +108 -0
- package/dist/input/gamepadMapping.d.ts +56 -0
- package/dist/input/gamepadMapping.js +91 -0
- package/dist/input/input.d.ts +281 -0
- package/dist/input/input.js +703 -0
- package/dist/input/inputHarness.d.ts +42 -0
- package/dist/input/inputHarness.js +193 -0
- package/dist/input/rightGesture.d.ts +57 -0
- package/dist/input/rightGesture.js +49 -0
- package/dist/input/rumble.d.ts +71 -0
- package/dist/input/rumble.js +119 -0
- package/dist/input/touchControls.d.ts +138 -0
- package/dist/input/touchControls.js +352 -0
- package/dist/input/typingTarget.d.ts +6 -0
- package/dist/input/typingTarget.js +27 -0
- package/dist/math/bounds.d.ts +61 -0
- package/dist/math/bounds.js +121 -0
- package/dist/math/color.d.ts +8 -0
- package/dist/math/color.js +35 -0
- package/dist/math/exact.d.ts +66 -0
- package/dist/math/exact.js +262 -0
- package/dist/math/frustum.d.ts +44 -0
- package/dist/math/frustum.js +90 -0
- package/dist/math/intersect.d.ts +76 -0
- package/dist/math/intersect.js +185 -0
- package/dist/math/scalar.d.ts +51 -0
- package/dist/math/scalar.js +99 -0
- package/dist/math/spring.d.ts +59 -0
- package/dist/math/spring.js +88 -0
- package/dist/nav/navGraph.d.ts +71 -0
- package/dist/nav/navGraph.js +111 -0
- package/dist/nav/navPath.d.ts +93 -0
- package/dist/nav/navPath.js +162 -0
- package/dist/nav/navSearch.d.ts +74 -0
- package/dist/nav/navSearch.js +198 -0
- package/dist/physics/boxSurface.d.ts +48 -0
- package/dist/physics/boxSurface.js +73 -0
- package/dist/physics/colliderSurface.d.ts +46 -0
- package/dist/physics/colliderSurface.js +146 -0
- package/dist/physics/compositeSurface.d.ts +33 -0
- package/dist/physics/compositeSurface.js +108 -0
- package/dist/physics/heightSurface.d.ts +103 -0
- package/dist/physics/heightSurface.js +153 -0
- package/dist/physics/ribbonSurface.d.ts +239 -0
- package/dist/physics/ribbonSurface.js +522 -0
- package/dist/render/ambientOcclusionPass.d.ts +53 -0
- package/dist/render/ambientOcclusionPass.js +179 -0
- package/dist/render/areaLights.d.ts +116 -0
- package/dist/render/areaLights.js +91 -0
- package/dist/render/areaShadowSet.d.ts +184 -0
- package/dist/render/areaShadowSet.js +277 -0
- package/dist/render/atmosphere.d.ts +94 -0
- package/dist/render/atmosphere.js +91 -0
- package/dist/render/backend/api.d.ts +496 -0
- package/dist/render/backend/api.js +1 -0
- package/dist/render/backend/budget.d.ts +82 -0
- package/dist/render/backend/budget.js +99 -0
- package/dist/render/backend/createRenderer.d.ts +135 -0
- package/dist/render/backend/createRenderer.js +201 -0
- package/dist/render/backend/deadline.d.ts +24 -0
- package/dist/render/backend/deadline.js +38 -0
- package/dist/render/backend/probe.d.ts +30 -0
- package/dist/render/backend/probe.js +129 -0
- package/dist/render/backend/select.d.ts +70 -0
- package/dist/render/backend/select.js +249 -0
- package/dist/render/backend/timer.d.ts +50 -0
- package/dist/render/backend/timer.js +1 -0
- package/dist/render/backend/webgl2/instanced.d.ts +21 -0
- package/dist/render/backend/webgl2/instanced.js +42 -0
- package/dist/render/backend/webgl2/morphTexture.d.ts +21 -0
- package/dist/render/backend/webgl2/morphTexture.js +55 -0
- package/dist/render/backend/webgl2/renderer.d.ts +3027 -0
- package/dist/render/backend/webgl2/renderer.js +6041 -0
- package/dist/render/backend/webgl2/skinPaletteTexture.d.ts +32 -0
- package/dist/render/backend/webgl2/skinPaletteTexture.js +68 -0
- package/dist/render/backend/webgpu/boltPass.d.ts +42 -0
- package/dist/render/backend/webgpu/boltPass.js +160 -0
- package/dist/render/backend/webgpu/buffers.d.ts +159 -0
- package/dist/render/backend/webgpu/buffers.js +402 -0
- package/dist/render/backend/webgpu/causticsPass.d.ts +36 -0
- package/dist/render/backend/webgpu/causticsPass.js +138 -0
- package/dist/render/backend/webgpu/clusterBinner.d.ts +51 -0
- package/dist/render/backend/webgpu/clusterBinner.js +206 -0
- package/dist/render/backend/webgpu/depthPass.d.ts +114 -0
- package/dist/render/backend/webgpu/depthPass.js +228 -0
- package/dist/render/backend/webgpu/device.d.ts +52 -0
- package/dist/render/backend/webgpu/device.js +121 -0
- package/dist/render/backend/webgpu/drawCommand.d.ts +43 -0
- package/dist/render/backend/webgpu/drawCommand.js +54 -0
- package/dist/render/backend/webgpu/environmentTexels.d.ts +28 -0
- package/dist/render/backend/webgpu/environmentTexels.js +79 -0
- package/dist/render/backend/webgpu/filmPass.d.ts +29 -0
- package/dist/render/backend/webgpu/filmPass.js +97 -0
- package/dist/render/backend/webgpu/flatPass.d.ts +213 -0
- package/dist/render/backend/webgpu/flatPass.js +482 -0
- package/dist/render/backend/webgpu/flockPass.d.ts +34 -0
- package/dist/render/backend/webgpu/flockPass.js +129 -0
- package/dist/render/backend/webgpu/gpuTimestamps.d.ts +94 -0
- package/dist/render/backend/webgpu/gpuTimestamps.js +213 -0
- package/dist/render/backend/webgpu/insetPass.d.ts +19 -0
- package/dist/render/backend/webgpu/insetPass.js +108 -0
- package/dist/render/backend/webgpu/instanced.d.ts +27 -0
- package/dist/render/backend/webgpu/instanced.js +49 -0
- package/dist/render/backend/webgpu/lightVolumePass.d.ts +75 -0
- package/dist/render/backend/webgpu/lightVolumePass.js +154 -0
- package/dist/render/backend/webgpu/linePass.d.ts +90 -0
- package/dist/render/backend/webgpu/linePass.js +220 -0
- package/dist/render/backend/webgpu/morphTexture.d.ts +18 -0
- package/dist/render/backend/webgpu/morphTexture.js +51 -0
- package/dist/render/backend/webgpu/panelPass.d.ts +37 -0
- package/dist/render/backend/webgpu/panelPass.js +114 -0
- package/dist/render/backend/webgpu/particlePass.d.ts +89 -0
- package/dist/render/backend/webgpu/particlePass.js +280 -0
- package/dist/render/backend/webgpu/pipelineCache.d.ts +93 -0
- package/dist/render/backend/webgpu/pipelineCache.js +140 -0
- package/dist/render/backend/webgpu/plumePass.d.ts +69 -0
- package/dist/render/backend/webgpu/plumePass.js +213 -0
- package/dist/render/backend/webgpu/pointShadowPass.d.ts +88 -0
- package/dist/render/backend/webgpu/pointShadowPass.js +280 -0
- package/dist/render/backend/webgpu/postPass.d.ts +342 -0
- package/dist/render/backend/webgpu/postPass.js +366 -0
- package/dist/render/backend/webgpu/probePass.d.ts +108 -0
- package/dist/render/backend/webgpu/probePass.js +188 -0
- package/dist/render/backend/webgpu/reflectionPass.d.ts +29 -0
- package/dist/render/backend/webgpu/reflectionPass.js +87 -0
- package/dist/render/backend/webgpu/renderer.d.ts +3082 -0
- package/dist/render/backend/webgpu/renderer.js +10911 -0
- package/dist/render/backend/webgpu/scatterPass.d.ts +95 -0
- package/dist/render/backend/webgpu/scatterPass.js +266 -0
- package/dist/render/backend/webgpu/sdfTextPass.d.ts +86 -0
- package/dist/render/backend/webgpu/sdfTextPass.js +190 -0
- package/dist/render/backend/webgpu/shaderModules.d.ts +9 -0
- package/dist/render/backend/webgpu/shaderModules.js +45 -0
- package/dist/render/backend/webgpu/shaders/clusterBin.wgsl.d.ts +23 -0
- package/dist/render/backend/webgpu/shaders/clusterBin.wgsl.js +208 -0
- package/dist/render/backend/webgpu/skinPaletteRing.d.ts +67 -0
- package/dist/render/backend/webgpu/skinPaletteRing.js +97 -0
- package/dist/render/backend/webgpu/skinPaletteTexture.d.ts +17 -0
- package/dist/render/backend/webgpu/skinPaletteTexture.js +68 -0
- package/dist/render/backend/webgpu/skyPass.d.ts +102 -0
- package/dist/render/backend/webgpu/skyPass.js +70 -0
- package/dist/render/backend/webgpu/surfaceTexturePass.d.ts +41 -0
- package/dist/render/backend/webgpu/surfaceTexturePass.js +228 -0
- package/dist/render/backend/webgpu/textPass.d.ts +73 -0
- package/dist/render/backend/webgpu/textPass.js +190 -0
- package/dist/render/backend/webgpu/uniformRing.d.ts +133 -0
- package/dist/render/backend/webgpu/uniformRing.js +208 -0
- package/dist/render/backend/webgpu/waterPass.d.ts +73 -0
- package/dist/render/backend/webgpu/waterPass.js +160 -0
- package/dist/render/backend/webgpu/windStreakPass.d.ts +46 -0
- package/dist/render/backend/webgpu/windStreakPass.js +153 -0
- package/dist/render/billboard.d.ts +27 -0
- package/dist/render/billboard.js +79 -0
- package/dist/render/bloomChain.d.ts +66 -0
- package/dist/render/bloomChain.js +83 -0
- package/dist/render/bloomPass.d.ts +54 -0
- package/dist/render/bloomPass.js +219 -0
- package/dist/render/boltBatch.d.ts +39 -0
- package/dist/render/boltBatch.js +121 -0
- package/dist/render/boltPool.d.ts +135 -0
- package/dist/render/boltPool.js +259 -0
- package/dist/render/boom.d.ts +46 -0
- package/dist/render/boom.js +81 -0
- package/dist/render/camera.d.ts +119 -0
- package/dist/render/camera.js +304 -0
- package/dist/render/causticsRenderer.d.ts +63 -0
- package/dist/render/causticsRenderer.js +119 -0
- package/dist/render/cinematicCamera.d.ts +102 -0
- package/dist/render/cinematicCamera.js +227 -0
- package/dist/render/clusteredLights.d.ts +260 -0
- package/dist/render/clusteredLights.js +479 -0
- package/dist/render/colourGrade.d.ts +62 -0
- package/dist/render/colourGrade.js +91 -0
- package/dist/render/compute.d.ts +74 -0
- package/dist/render/compute.js +8 -0
- package/dist/render/contextLoss.d.ts +32 -0
- package/dist/render/contextLoss.js +46 -0
- package/dist/render/debugLines.d.ts +75 -0
- package/dist/render/debugLines.js +281 -0
- package/dist/render/decalPass.d.ts +34 -0
- package/dist/render/decalPass.js +103 -0
- package/dist/render/decalProjector.d.ts +140 -0
- package/dist/render/decalProjector.js +282 -0
- package/dist/render/decalQueue.d.ts +53 -0
- package/dist/render/decalQueue.js +87 -0
- package/dist/render/depthConvention.d.ts +314 -0
- package/dist/render/depthConvention.js +346 -0
- package/dist/render/drawingBuffer.d.ts +52 -0
- package/dist/render/drawingBuffer.js +67 -0
- package/dist/render/emptyTexture.d.ts +60 -0
- package/dist/render/emptyTexture.js +103 -0
- package/dist/render/envProbeArray.d.ts +85 -0
- package/dist/render/envProbeArray.js +164 -0
- package/dist/render/equirectToCube.d.ts +54 -0
- package/dist/render/equirectToCube.js +123 -0
- package/dist/render/flockGeometry.d.ts +23 -0
- package/dist/render/flockGeometry.js +43 -0
- package/dist/render/flockRenderer.d.ts +37 -0
- package/dist/render/flockRenderer.js +70 -0
- package/dist/render/frame/arena.d.ts +32 -0
- package/dist/render/frame/arena.js +65 -0
- package/dist/render/frame/index.d.ts +18 -0
- package/dist/render/frame/index.js +4 -0
- package/dist/render/frame/replay.d.ts +34 -0
- package/dist/render/frame/replay.js +48 -0
- package/dist/render/frame/resources.d.ts +25 -0
- package/dist/render/frame/resources.js +55 -0
- package/dist/render/frame/schedule.d.ts +37 -0
- package/dist/render/frame/schedule.js +61 -0
- package/dist/render/frameView.d.ts +19 -0
- package/dist/render/frameView.js +1 -0
- package/dist/render/gizmo.d.ts +236 -0
- package/dist/render/gizmo.js +727 -0
- package/dist/render/globalMedium.d.ts +124 -0
- package/dist/render/globalMedium.js +100 -0
- package/dist/render/globalMediumPass.d.ts +101 -0
- package/dist/render/globalMediumPass.js +250 -0
- package/dist/render/gpuCapability.d.ts +111 -0
- package/dist/render/gpuCapability.js +194 -0
- package/dist/render/gpuTimer.d.ts +87 -0
- package/dist/render/gpuTimer.js +145 -0
- package/dist/render/halfFloat.d.ts +4 -0
- package/dist/render/halfFloat.js +38 -0
- package/dist/render/handleRegistry.d.ts +54 -0
- package/dist/render/handleRegistry.js +84 -0
- package/dist/render/iesProfile.d.ts +64 -0
- package/dist/render/iesProfile.js +179 -0
- package/dist/render/imageTexels.d.ts +50 -0
- package/dist/render/imageTexels.js +91 -0
- package/dist/render/instancedMesh.d.ts +48 -0
- package/dist/render/instancedMesh.js +127 -0
- package/dist/render/instances.d.ts +69 -0
- package/dist/render/instances.js +52 -0
- package/dist/render/lightBudget.d.ts +397 -0
- package/dist/render/lightBudget.js +524 -0
- package/dist/render/lightMatrix.d.ts +3 -0
- package/dist/render/lightMatrix.js +45 -0
- package/dist/render/lightVolumeDraw.d.ts +132 -0
- package/dist/render/lightVolumeDraw.js +181 -0
- package/dist/render/lineBatch.d.ts +60 -0
- package/dist/render/lineBatch.js +160 -0
- package/dist/render/linePoints.d.ts +33 -0
- package/dist/render/linePoints.js +46 -0
- package/dist/render/livePointShadowSet.d.ts +72 -0
- package/dist/render/livePointShadowSet.js +258 -0
- package/dist/render/lod.d.ts +35 -0
- package/dist/render/lod.js +65 -0
- package/dist/render/mesh.d.ts +177 -0
- package/dist/render/mesh.js +466 -0
- package/dist/render/occlusion.d.ts +81 -0
- package/dist/render/occlusion.js +378 -0
- package/dist/render/oitPass.d.ts +67 -0
- package/dist/render/oitPass.js +213 -0
- package/dist/render/orderIndependent.d.ts +92 -0
- package/dist/render/orderIndependent.js +108 -0
- package/dist/render/particleBatch.d.ts +140 -0
- package/dist/render/particleBatch.js +186 -0
- package/dist/render/particleMaterial.d.ts +54 -0
- package/dist/render/particleMaterial.js +42 -0
- package/dist/render/particlePool.d.ts +124 -0
- package/dist/render/particlePool.js +182 -0
- package/dist/render/pass.d.ts +195 -0
- package/dist/render/pass.js +9 -0
- package/dist/render/passTarget.d.ts +86 -0
- package/dist/render/passTarget.js +121 -0
- package/dist/render/pickable.d.ts +31 -0
- package/dist/render/pickable.js +172 -0
- package/dist/render/planarReflection.d.ts +59 -0
- package/dist/render/planarReflection.js +194 -0
- package/dist/render/planarReflectionDraw.d.ts +31 -0
- package/dist/render/planarReflectionDraw.js +65 -0
- package/dist/render/plumeGeometry.d.ts +25 -0
- package/dist/render/plumeGeometry.js +61 -0
- package/dist/render/plumeMaterial.d.ts +31 -0
- package/dist/render/plumeMaterial.js +64 -0
- package/dist/render/plumeRenderer.d.ts +96 -0
- package/dist/render/plumeRenderer.js +185 -0
- package/dist/render/pointLightSelection.d.ts +175 -0
- package/dist/render/pointLightSelection.js +301 -0
- package/dist/render/pointShadowArray.d.ts +95 -0
- package/dist/render/pointShadowArray.js +219 -0
- package/dist/render/pointShadowBudget.d.ts +118 -0
- package/dist/render/pointShadowBudget.js +221 -0
- package/dist/render/pointShadowImage.d.ts +265 -0
- package/dist/render/pointShadowImage.js +339 -0
- package/dist/render/pointShadowMap.d.ts +93 -0
- package/dist/render/pointShadowMap.js +167 -0
- package/dist/render/pointShadowSystem.d.ts +195 -0
- package/dist/render/pointShadowSystem.js +336 -0
- package/dist/render/prefilterEnvMap.d.ts +124 -0
- package/dist/render/prefilterEnvMap.js +146 -0
- package/dist/render/prefilterPass.d.ts +44 -0
- package/dist/render/prefilterPass.js +98 -0
- package/dist/render/probeGrid.d.ts +122 -0
- package/dist/render/probeGrid.js +174 -0
- package/dist/render/rainField.d.ts +99 -0
- package/dist/render/rainField.js +168 -0
- package/dist/render/reflectionProbe.d.ts +188 -0
- package/dist/render/reflectionProbe.js +437 -0
- package/dist/render/renderQuality.d.ts +699 -0
- package/dist/render/renderQuality.js +293 -0
- package/dist/render/rendererHarness.d.ts +39 -0
- package/dist/render/rendererHarness.js +185 -0
- package/dist/render/resolutionGovernor.d.ts +107 -0
- package/dist/render/resolutionGovernor.js +144 -0
- package/dist/render/scatterDeform.d.ts +17 -0
- package/dist/render/scatterDeform.js +46 -0
- package/dist/render/sceneTarget.d.ts +288 -0
- package/dist/render/sceneTarget.js +856 -0
- package/dist/render/screenSpaceReflection.d.ts +233 -0
- package/dist/render/screenSpaceReflection.js +415 -0
- package/dist/render/sdfFont.d.ts +77 -0
- package/dist/render/sdfFont.js +86 -0
- package/dist/render/sdfTextLayout.d.ts +46 -0
- package/dist/render/sdfTextLayout.js +145 -0
- package/dist/render/sdfTextRenderer.d.ts +75 -0
- package/dist/render/sdfTextRenderer.js +194 -0
- package/dist/render/seaState.d.ts +25 -0
- package/dist/render/seaState.js +34 -0
- package/dist/render/segmentQuads.d.ts +29 -0
- package/dist/render/segmentQuads.js +75 -0
- package/dist/render/shader.d.ts +5 -0
- package/dist/render/shader.js +172 -0
- package/dist/render/shaders/ambientOcclusion.d.ts +45 -0
- package/dist/render/shaders/ambientOcclusion.js +352 -0
- package/dist/render/shaders/arcane.d.ts +19 -0
- package/dist/render/shaders/arcane.js +102 -0
- package/dist/render/shaders/bloom.d.ts +70 -0
- package/dist/render/shaders/bloom.js +227 -0
- package/dist/render/shaders/bolt.d.ts +17 -0
- package/dist/render/shaders/bolt.js +161 -0
- package/dist/render/shaders/caustics.d.ts +38 -0
- package/dist/render/shaders/caustics.js +167 -0
- package/dist/render/shaders/conditionals.d.ts +21 -0
- package/dist/render/shaders/conditionals.js +55 -0
- package/dist/render/shaders/decalProject.d.ts +25 -0
- package/dist/render/shaders/decalProject.js +125 -0
- package/dist/render/shaders/depth.d.ts +14 -0
- package/dist/render/shaders/depth.js +114 -0
- package/dist/render/shaders/depthOfField.d.ts +41 -0
- package/dist/render/shaders/depthOfField.js +139 -0
- package/dist/render/shaders/film.d.ts +15 -0
- package/dist/render/shaders/film.js +283 -0
- package/dist/render/shaders/fire.d.ts +12 -0
- package/dist/render/shaders/fire.js +178 -0
- package/dist/render/shaders/flat/directionalShadow.d.ts +1 -0
- package/dist/render/shaders/flat/directionalShadow.js +195 -0
- package/dist/render/shaders/flat/index.d.ts +135 -0
- package/dist/render/shaders/flat/index.js +387 -0
- package/dist/render/shaders/flat/lobes.d.ts +1 -0
- package/dist/render/shaders/flat/lobes.js +398 -0
- package/dist/render/shaders/flat/main.d.ts +2 -0
- package/dist/render/shaders/flat/main.js +1630 -0
- package/dist/render/shaders/flat/pointShadow.d.ts +1 -0
- package/dist/render/shaders/flat/pointShadow.js +322 -0
- package/dist/render/shaders/flat/preamble.d.ts +15 -0
- package/dist/render/shaders/flat/preamble.js +864 -0
- package/dist/render/shaders/flat/probeGrid.d.ts +21 -0
- package/dist/render/shaders/flat/probeGrid.js +151 -0
- package/dist/render/shaders/flat/surface.d.ts +2 -0
- package/dist/render/shaders/flat/surface.js +40 -0
- package/dist/render/shaders/flock.d.ts +11 -0
- package/dist/render/shaders/flock.js +102 -0
- package/dist/render/shaders/fog.d.ts +37 -0
- package/dist/render/shaders/fog.js +98 -0
- package/dist/render/shaders/fullscreen.d.ts +16 -0
- package/dist/render/shaders/fullscreen.js +27 -0
- package/dist/render/shaders/generated/ambientOcclusion.wgsl.d.ts +65 -0
- package/dist/render/shaders/generated/ambientOcclusion.wgsl.js +71 -0
- package/dist/render/shaders/generated/arcane.wgsl.d.ts +90 -0
- package/dist/render/shaders/generated/arcane.wgsl.js +96 -0
- package/dist/render/shaders/generated/bloom.wgsl.d.ts +69 -0
- package/dist/render/shaders/generated/bloom.wgsl.js +75 -0
- package/dist/render/shaders/generated/bolt.wgsl.d.ts +118 -0
- package/dist/render/shaders/generated/bolt.wgsl.js +124 -0
- package/dist/render/shaders/generated/caustics.wgsl.d.ts +118 -0
- package/dist/render/shaders/generated/caustics.wgsl.js +124 -0
- package/dist/render/shaders/generated/decalProject.wgsl.d.ts +61 -0
- package/dist/render/shaders/generated/decalProject.wgsl.js +67 -0
- package/dist/render/shaders/generated/depth.wgsl.d.ts +131 -0
- package/dist/render/shaders/generated/depth.wgsl.js +137 -0
- package/dist/render/shaders/generated/film.wgsl.d.ts +134 -0
- package/dist/render/shaders/generated/film.wgsl.js +140 -0
- package/dist/render/shaders/generated/fire.wgsl.d.ts +128 -0
- package/dist/render/shaders/generated/fire.wgsl.js +134 -0
- package/dist/render/shaders/generated/flat.wgsl.d.ts +9163 -0
- package/dist/render/shaders/generated/flat.wgsl.js +9192 -0
- package/dist/render/shaders/generated/flock.wgsl.d.ts +73 -0
- package/dist/render/shaders/generated/flock.wgsl.js +79 -0
- package/dist/render/shaders/generated/fullscreen.wgsl.d.ts +12 -0
- package/dist/render/shaders/generated/fullscreen.wgsl.js +18 -0
- package/dist/render/shaders/generated/globalMedium.wgsl.d.ts +130 -0
- package/dist/render/shaders/generated/globalMedium.wgsl.js +136 -0
- package/dist/render/shaders/generated/lightVolume.wgsl.d.ts +230 -0
- package/dist/render/shaders/generated/lightVolume.wgsl.js +239 -0
- package/dist/render/shaders/generated/line.wgsl.d.ts +128 -0
- package/dist/render/shaders/generated/line.wgsl.js +134 -0
- package/dist/render/shaders/generated/octahedralResolve.wgsl.d.ts +51 -0
- package/dist/render/shaders/generated/octahedralResolve.wgsl.js +57 -0
- package/dist/render/shaders/generated/oitResolve.wgsl.d.ts +23 -0
- package/dist/render/shaders/generated/oitResolve.wgsl.js +29 -0
- package/dist/render/shaders/generated/panel.wgsl.d.ts +48 -0
- package/dist/render/shaders/generated/panel.wgsl.js +54 -0
- package/dist/render/shaders/generated/particle.wgsl.d.ts +332 -0
- package/dist/render/shaders/generated/particle.wgsl.js +338 -0
- package/dist/render/shaders/generated/prefilter.wgsl.d.ts +61 -0
- package/dist/render/shaders/generated/prefilter.wgsl.js +67 -0
- package/dist/render/shaders/generated/rush.wgsl.d.ts +131 -0
- package/dist/render/shaders/generated/rush.wgsl.js +137 -0
- package/dist/render/shaders/generated/scatter.wgsl.d.ts +195 -0
- package/dist/render/shaders/generated/scatter.wgsl.js +201 -0
- package/dist/render/shaders/generated/sdfText.wgsl.d.ts +69 -0
- package/dist/render/shaders/generated/sdfText.wgsl.js +75 -0
- package/dist/render/shaders/generated/sky.wgsl.d.ts +100 -0
- package/dist/render/shaders/generated/sky.wgsl.js +106 -0
- package/dist/render/shaders/generated/smoke.wgsl.d.ts +85 -0
- package/dist/render/shaders/generated/smoke.wgsl.js +91 -0
- package/dist/render/shaders/generated/ssrResolve.wgsl.d.ts +18 -0
- package/dist/render/shaders/generated/ssrResolve.wgsl.js +24 -0
- package/dist/render/shaders/generated/ssrTrace.wgsl.d.ts +86 -0
- package/dist/render/shaders/generated/ssrTrace.wgsl.js +92 -0
- package/dist/render/shaders/generated/temporalResolve.wgsl.d.ts +46 -0
- package/dist/render/shaders/generated/temporalResolve.wgsl.js +52 -0
- package/dist/render/shaders/generated/text.wgsl.d.ts +98 -0
- package/dist/render/shaders/generated/text.wgsl.js +104 -0
- package/dist/render/shaders/generated/water.wgsl.d.ts +247 -0
- package/dist/render/shaders/generated/water.wgsl.js +253 -0
- package/dist/render/shaders/generated/windStreaks.wgsl.d.ts +73 -0
- package/dist/render/shaders/generated/windStreaks.wgsl.js +79 -0
- package/dist/render/shaders/gerstner.d.ts +21 -0
- package/dist/render/shaders/gerstner.js +110 -0
- package/dist/render/shaders/globalMedium.d.ts +56 -0
- package/dist/render/shaders/globalMedium.js +393 -0
- package/dist/render/shaders/lightVolume.d.ts +61 -0
- package/dist/render/shaders/lightVolume.js +527 -0
- package/dist/render/shaders/line.d.ts +18 -0
- package/dist/render/shaders/line.js +122 -0
- package/dist/render/shaders/morph.d.ts +26 -0
- package/dist/render/shaders/morph.js +61 -0
- package/dist/render/shaders/octahedral.d.ts +76 -0
- package/dist/render/shaders/octahedral.js +161 -0
- package/dist/render/shaders/octahedralResolve.d.ts +25 -0
- package/dist/render/shaders/octahedralResolve.js +81 -0
- package/dist/render/shaders/oitResolve.d.ts +17 -0
- package/dist/render/shaders/oitResolve.js +42 -0
- package/dist/render/shaders/outputTransform.d.ts +37 -0
- package/dist/render/shaders/outputTransform.js +106 -0
- package/dist/render/shaders/panel.d.ts +17 -0
- package/dist/render/shaders/panel.js +50 -0
- package/dist/render/shaders/particle.d.ts +82 -0
- package/dist/render/shaders/particle.js +431 -0
- package/dist/render/shaders/prefilter.d.ts +37 -0
- package/dist/render/shaders/prefilter.js +276 -0
- package/dist/render/shaders/rush.d.ts +21 -0
- package/dist/render/shaders/rush.js +355 -0
- package/dist/render/shaders/scatter.d.ts +14 -0
- package/dist/render/shaders/scatter.js +206 -0
- package/dist/render/shaders/sdfText.d.ts +9 -0
- package/dist/render/shaders/sdfText.js +65 -0
- package/dist/render/shaders/skinning.d.ts +17 -0
- package/dist/render/shaders/skinning.js +59 -0
- package/dist/render/shaders/sky.d.ts +10 -0
- package/dist/render/shaders/sky.js +242 -0
- package/dist/render/shaders/smoke.d.ts +8 -0
- package/dist/render/shaders/smoke.js +88 -0
- package/dist/render/shaders/ssrResolve.d.ts +15 -0
- package/dist/render/shaders/ssrResolve.js +28 -0
- package/dist/render/shaders/ssrTrace.d.ts +22 -0
- package/dist/render/shaders/ssrTrace.js +230 -0
- package/dist/render/shaders/tangentFrame.d.ts +17 -0
- package/dist/render/shaders/tangentFrame.js +70 -0
- package/dist/render/shaders/temporalResolve.d.ts +1 -0
- package/dist/render/shaders/temporalResolve.js +150 -0
- package/dist/render/shaders/text.d.ts +17 -0
- package/dist/render/shaders/text.js +155 -0
- package/dist/render/shaders/vertexChannel.d.ts +39 -0
- package/dist/render/shaders/vertexChannel.js +69 -0
- package/dist/render/shaders/water.d.ts +18 -0
- package/dist/render/shaders/water.js +354 -0
- package/dist/render/shaders/windStreaks.d.ts +14 -0
- package/dist/render/shaders/windStreaks.js +129 -0
- package/dist/render/shadowCasters.d.ts +107 -0
- package/dist/render/shadowCasters.js +1 -0
- package/dist/render/shadowMap.d.ts +10 -0
- package/dist/render/shadowMap.js +80 -0
- package/dist/render/shotPlacement.d.ts +80 -0
- package/dist/render/shotPlacement.js +183 -0
- package/dist/render/skinPalette.d.ts +90 -0
- package/dist/render/skinPalette.js +136 -0
- package/dist/render/ssrPass.d.ts +59 -0
- package/dist/render/ssrPass.js +196 -0
- package/dist/render/surfaceSheet.d.ts +52 -0
- package/dist/render/surfaceSheet.js +99 -0
- package/dist/render/surfaceTexture.d.ts +197 -0
- package/dist/render/surfaceTexture.js +116 -0
- package/dist/render/temporalAa.d.ts +104 -0
- package/dist/render/temporalAa.js +194 -0
- package/dist/render/temporalPass.d.ts +54 -0
- package/dist/render/temporalPass.js +135 -0
- package/dist/render/textLayout.d.ts +88 -0
- package/dist/render/textLayout.js +201 -0
- package/dist/render/textRenderer.d.ts +32 -0
- package/dist/render/textRenderer.js +176 -0
- package/dist/render/thirdPersonCamera.d.ts +272 -0
- package/dist/render/thirdPersonCamera.js +479 -0
- package/dist/render/trample.d.ts +57 -0
- package/dist/render/trample.js +134 -0
- package/dist/render/translucentQueue.d.ts +76 -0
- package/dist/render/translucentQueue.js +90 -0
- package/dist/render/uniformVectorBudget.d.ts +105 -0
- package/dist/render/uniformVectorBudget.js +201 -0
- package/dist/render/uploadStep.d.ts +14 -0
- package/dist/render/uploadStep.js +14 -0
- package/dist/render/vertexDefaults.d.ts +48 -0
- package/dist/render/vertexDefaults.js +111 -0
- package/dist/render/visibility.d.ts +22 -0
- package/dist/render/visibility.js +47 -0
- package/dist/render/waterDraw.d.ts +57 -0
- package/dist/render/waterDraw.js +102 -0
- package/dist/render/waterGrid.d.ts +62 -0
- package/dist/render/waterGrid.js +151 -0
- package/dist/render/waterRenderer.d.ts +163 -0
- package/dist/render/waterRenderer.js +165 -0
- package/dist/render/wind.d.ts +45 -0
- package/dist/render/wind.js +32 -0
- package/dist/render/windField.d.ts +34 -0
- package/dist/render/windField.js +13 -0
- package/dist/render/windStreakDraw.d.ts +73 -0
- package/dist/render/windStreakDraw.js +86 -0
- package/dist/render/windStreakRenderer.d.ts +37 -0
- package/dist/render/windStreakRenderer.js +86 -0
- package/dist/scene/node.d.ts +128 -0
- package/dist/scene/node.js +319 -0
- package/dist/scene/visit.d.ts +38 -0
- package/dist/scene/visit.js +43 -0
- package/dist/ui/clipMime.d.ts +46 -0
- package/dist/ui/clipMime.js +88 -0
- package/dist/ui/exportTarget.d.ts +305 -0
- package/dist/ui/exportTarget.js +368 -0
- package/dist/ui/frameOverlay.d.ts +59 -0
- package/dist/ui/frameOverlay.js +76 -0
- package/dist/ui/framePacer.d.ts +142 -0
- package/dist/ui/framePacer.js +284 -0
- package/dist/ui/frameRecorder.d.ts +188 -0
- package/dist/ui/frameRecorder.js +221 -0
- package/dist/ui/fullscreen.d.ts +72 -0
- package/dist/ui/fullscreen.js +92 -0
- package/dist/ui/pixelCursor.d.ts +28 -0
- package/dist/ui/pixelCursor.js +66 -0
- package/dist/ui/splash.d.ts +86 -0
- package/dist/ui/splash.js +300 -0
- package/dist/ui/stillFrame.d.ts +22 -0
- package/dist/ui/stillFrame.js +40 -0
- package/package.json +60 -0
- package/src/behavior/behaviorTree.ts +346 -0
- package/src/build/shaderComments.ts +0 -0
- package/src/cinematic/player.ts +209 -0
- package/src/cinematic/script.ts +231 -0
- package/src/core/bootGate.ts +49 -0
- package/src/core/loadTracker.ts +144 -0
- package/src/core/loop.ts +211 -0
- package/src/core/messageQueue.ts +145 -0
- package/src/core/onceSet.ts +65 -0
- package/src/core/preferences.ts +177 -0
- package/src/core/remoteSave.ts +347 -0
- package/src/core/rng.ts +101 -0
- package/src/core/stepBudget.ts +136 -0
- package/src/core/storage.ts +114 -0
- package/src/core/tickTrace.ts +129 -0
- package/src/core/timeCurve.ts +175 -0
- package/src/core/withDefaults.ts +28 -0
- package/src/dev/contactProbe.ts +115 -0
- package/src/dev/fpsMeter.ts +101 -0
- package/src/environment/celestialClock.ts +385 -0
- package/src/geometry/decal.ts +260 -0
- package/src/geometry/filmPatch.ts +158 -0
- package/src/geometry/growable.ts +165 -0
- package/src/geometry/lightVolume.ts +161 -0
- package/src/geometry/meshBuilder.ts +1397 -0
- package/src/geometry/pixelFont.ts +189 -0
- package/src/geometry/ribbon.ts +790 -0
- package/src/geometry/shellFill.ts +265 -0
- package/src/geometry/spline.ts +659 -0
- package/src/geometry/tangents.ts +173 -0
- package/src/geometry/textMesh.ts +96 -0
- package/src/geometry/treeBuilder.ts +114 -0
- package/src/host/display.ts +180 -0
- package/src/host/files.ts +77 -0
- package/src/host/lifecycle.ts +63 -0
- package/src/host/platformServices.ts +23 -0
- package/src/host/screen.ts +134 -0
- package/src/index.ts +730 -0
- package/src/input/actionMap.ts +377 -0
- package/src/input/activeDevice.ts +86 -0
- package/src/input/gamepadIdentity.ts +131 -0
- package/src/input/gamepadMapping.ts +121 -0
- package/src/input/input.ts +872 -0
- package/src/input/inputHarness.ts +226 -0
- package/src/input/rightGesture.ts +76 -0
- package/src/input/rumble.ts +138 -0
- package/src/input/touchControls.ts +451 -0
- package/src/input/typingTarget.ts +26 -0
- package/src/math/bounds.ts +153 -0
- package/src/math/color.ts +37 -0
- package/src/math/exact.ts +274 -0
- package/src/math/frustum.ts +115 -0
- package/src/math/intersect.ts +228 -0
- package/src/math/scalar.ts +109 -0
- package/src/math/spring.ts +106 -0
- package/src/nav/navGraph.ts +168 -0
- package/src/nav/navPath.ts +217 -0
- package/src/nav/navSearch.ts +200 -0
- package/src/physics/boxSurface.ts +96 -0
- package/src/physics/colliderSurface.ts +213 -0
- package/src/physics/compositeSurface.ts +111 -0
- package/src/physics/heightSurface.ts +234 -0
- package/src/physics/ribbonSurface.ts +642 -0
- package/src/render/ambientOcclusionPass.ts +200 -0
- package/src/render/areaLights.ts +194 -0
- package/src/render/areaShadowSet.ts +405 -0
- package/src/render/atmosphere.ts +186 -0
- package/src/render/backend/api.ts +802 -0
- package/src/render/backend/budget.ts +139 -0
- package/src/render/backend/createRenderer.ts +343 -0
- package/src/render/backend/deadline.ts +37 -0
- package/src/render/backend/probe.ts +152 -0
- package/src/render/backend/select.ts +288 -0
- package/src/render/backend/timer.ts +59 -0
- package/src/render/backend/webgl2/instanced.ts +46 -0
- package/src/render/backend/webgl2/morphTexture.ts +58 -0
- package/src/render/backend/webgl2/renderer.ts +7484 -0
- package/src/render/backend/webgl2/skinPaletteTexture.ts +70 -0
- package/src/render/backend/webgpu/boltPass.ts +205 -0
- package/src/render/backend/webgpu/buffers.ts +553 -0
- package/src/render/backend/webgpu/causticsPass.ts +174 -0
- package/src/render/backend/webgpu/clusterBinner.ts +259 -0
- package/src/render/backend/webgpu/depthPass.ts +261 -0
- package/src/render/backend/webgpu/device.ts +148 -0
- package/src/render/backend/webgpu/drawCommand.ts +79 -0
- package/src/render/backend/webgpu/environmentTexels.ts +96 -0
- package/src/render/backend/webgpu/filmPass.ts +123 -0
- package/src/render/backend/webgpu/flatPass.ts +635 -0
- package/src/render/backend/webgpu/flockPass.ts +163 -0
- package/src/render/backend/webgpu/gpuTimestamps.ts +255 -0
- package/src/render/backend/webgpu/insetPass.ts +123 -0
- package/src/render/backend/webgpu/instanced.ts +55 -0
- package/src/render/backend/webgpu/lightVolumePass.ts +203 -0
- package/src/render/backend/webgpu/linePass.ts +270 -0
- package/src/render/backend/webgpu/morphTexture.ts +61 -0
- package/src/render/backend/webgpu/panelPass.ts +138 -0
- package/src/render/backend/webgpu/particlePass.ts +370 -0
- package/src/render/backend/webgpu/pipelineCache.ts +152 -0
- package/src/render/backend/webgpu/plumePass.ts +292 -0
- package/src/render/backend/webgpu/pointShadowPass.ts +368 -0
- package/src/render/backend/webgpu/postPass.ts +470 -0
- package/src/render/backend/webgpu/probePass.ts +218 -0
- package/src/render/backend/webgpu/reflectionPass.ts +137 -0
- package/src/render/backend/webgpu/renderer.ts +13004 -0
- package/src/render/backend/webgpu/scatterPass.ts +354 -0
- package/src/render/backend/webgpu/sdfTextPass.ts +220 -0
- package/src/render/backend/webgpu/shaderModules.ts +49 -0
- package/src/render/backend/webgpu/shaders/clusterBin.wgsl.ts +219 -0
- package/src/render/backend/webgpu/skinPaletteRing.ts +105 -0
- package/src/render/backend/webgpu/skinPaletteTexture.ts +79 -0
- package/src/render/backend/webgpu/skyPass.ts +85 -0
- package/src/render/backend/webgpu/surfaceTexturePass.ts +257 -0
- package/src/render/backend/webgpu/textPass.ts +224 -0
- package/src/render/backend/webgpu/uniformRing.ts +228 -0
- package/src/render/backend/webgpu/waterPass.ts +211 -0
- package/src/render/backend/webgpu/windStreakPass.ts +196 -0
- package/src/render/billboard.ts +108 -0
- package/src/render/bloomChain.ts +101 -0
- package/src/render/bloomPass.ts +256 -0
- package/src/render/boltBatch.ts +141 -0
- package/src/render/boltPool.ts +360 -0
- package/src/render/boom.ts +123 -0
- package/src/render/camera.ts +348 -0
- package/src/render/causticsRenderer.ts +171 -0
- package/src/render/cinematicCamera.ts +278 -0
- package/src/render/clusteredLights.ts +598 -0
- package/src/render/colourGrade.ts +109 -0
- package/src/render/compute.ts +83 -0
- package/src/render/contextLoss.ts +50 -0
- package/src/render/debugLines.ts +411 -0
- package/src/render/decalPass.ts +124 -0
- package/src/render/decalProjector.ts +390 -0
- package/src/render/decalQueue.ts +110 -0
- package/src/render/depthConvention.ts +383 -0
- package/src/render/drawingBuffer.ts +89 -0
- package/src/render/emptyTexture.ts +130 -0
- package/src/render/envProbeArray.ts +201 -0
- package/src/render/equirectToCube.ts +160 -0
- package/src/render/flockGeometry.ts +53 -0
- package/src/render/flockRenderer.ts +111 -0
- package/src/render/frame/arena.ts +93 -0
- package/src/render/frame/index.ts +29 -0
- package/src/render/frame/replay.ts +50 -0
- package/src/render/frame/resources.ts +61 -0
- package/src/render/frame/schedule.ts +85 -0
- package/src/render/frameView.ts +20 -0
- package/src/render/gizmo.ts +923 -0
- package/src/render/globalMedium.ts +154 -0
- package/src/render/globalMediumPass.ts +323 -0
- package/src/render/gpuCapability.ts +244 -0
- package/src/render/gpuTimer.ts +182 -0
- package/src/render/halfFloat.ts +39 -0
- package/src/render/handleRegistry.ts +96 -0
- package/src/render/iesProfile.ts +215 -0
- package/src/render/imageTexels.ts +109 -0
- package/src/render/instancedMesh.ts +187 -0
- package/src/render/instances.ts +92 -0
- package/src/render/lightBudget.ts +655 -0
- package/src/render/lightMatrix.ts +69 -0
- package/src/render/lightVolumeDraw.ts +216 -0
- package/src/render/lineBatch.ts +180 -0
- package/src/render/linePoints.ts +61 -0
- package/src/render/livePointShadowSet.ts +285 -0
- package/src/render/lod.ts +86 -0
- package/src/render/mesh.ts +536 -0
- package/src/render/occlusion.ts +406 -0
- package/src/render/oitPass.ts +230 -0
- package/src/render/orderIndependent.ts +136 -0
- package/src/render/particleBatch.ts +299 -0
- package/src/render/particleMaterial.ts +84 -0
- package/src/render/particlePool.ts +291 -0
- package/src/render/pass.ts +203 -0
- package/src/render/passTarget.ts +225 -0
- package/src/render/pickable.ts +222 -0
- package/src/render/planarReflection.ts +233 -0
- package/src/render/planarReflectionDraw.ts +87 -0
- package/src/render/plumeGeometry.ts +75 -0
- package/src/render/plumeMaterial.ts +99 -0
- package/src/render/plumeRenderer.ts +272 -0
- package/src/render/pointLightSelection.ts +447 -0
- package/src/render/pointShadowArray.ts +276 -0
- package/src/render/pointShadowBudget.ts +305 -0
- package/src/render/pointShadowImage.ts +470 -0
- package/src/render/pointShadowMap.ts +228 -0
- package/src/render/pointShadowSystem.ts +408 -0
- package/src/render/prefilterEnvMap.ts +162 -0
- package/src/render/prefilterPass.ts +115 -0
- package/src/render/probeGrid.ts +248 -0
- package/src/render/rainField.ts +240 -0
- package/src/render/reflectionProbe.ts +530 -0
- package/src/render/renderQuality.ts +1054 -0
- package/src/render/rendererHarness.ts +214 -0
- package/src/render/resolutionGovernor.ts +189 -0
- package/src/render/scatterDeform.ts +72 -0
- package/src/render/sceneTarget.ts +1032 -0
- package/src/render/screenSpaceReflection.ts +524 -0
- package/src/render/sdfFont.ts +157 -0
- package/src/render/sdfTextLayout.ts +206 -0
- package/src/render/sdfTextRenderer.ts +233 -0
- package/src/render/seaState.ts +55 -0
- package/src/render/segmentQuads.ts +92 -0
- package/src/render/shader.ts +190 -0
- package/src/render/shaders/ambientOcclusion.ts +354 -0
- package/src/render/shaders/arcane.ts +103 -0
- package/src/render/shaders/bloom.ts +232 -0
- package/src/render/shaders/bolt.ts +164 -0
- package/src/render/shaders/caustics.ts +169 -0
- package/src/render/shaders/conditionals.ts +58 -0
- package/src/render/shaders/decalProject.ts +127 -0
- package/src/render/shaders/depth.ts +131 -0
- package/src/render/shaders/depthOfField.ts +141 -0
- package/src/render/shaders/film.ts +285 -0
- package/src/render/shaders/fire.ts +180 -0
- package/src/render/shaders/flat/directionalShadow.ts +196 -0
- package/src/render/shaders/flat/index.ts +502 -0
- package/src/render/shaders/flat/lobes.ts +399 -0
- package/src/render/shaders/flat/main.ts +1631 -0
- package/src/render/shaders/flat/pointShadow.ts +323 -0
- package/src/render/shaders/flat/preamble.ts +875 -0
- package/src/render/shaders/flat/probeGrid.ts +152 -0
- package/src/render/shaders/flat/surface.ts +41 -0
- package/src/render/shaders/flock.ts +103 -0
- package/src/render/shaders/fog.ts +99 -0
- package/src/render/shaders/fullscreen.ts +28 -0
- package/src/render/shaders/generated/ambientOcclusion.wgsl.ts +74 -0
- package/src/render/shaders/generated/arcane.wgsl.ts +98 -0
- package/src/render/shaders/generated/bloom.wgsl.ts +79 -0
- package/src/render/shaders/generated/bolt.wgsl.ts +127 -0
- package/src/render/shaders/generated/caustics.wgsl.ts +127 -0
- package/src/render/shaders/generated/decalProject.wgsl.ts +69 -0
- package/src/render/shaders/generated/depth.wgsl.ts +142 -0
- package/src/render/shaders/generated/film.wgsl.ts +143 -0
- package/src/render/shaders/generated/fire.wgsl.ts +137 -0
- package/src/render/shaders/generated/flat.wgsl.ts +9195 -0
- package/src/render/shaders/generated/flock.wgsl.ts +82 -0
- package/src/render/shaders/generated/fullscreen.wgsl.ts +20 -0
- package/src/render/shaders/generated/globalMedium.wgsl.ts +139 -0
- package/src/render/shaders/generated/lightVolume.wgsl.ts +242 -0
- package/src/render/shaders/generated/line.wgsl.ts +137 -0
- package/src/render/shaders/generated/octahedralResolve.wgsl.ts +60 -0
- package/src/render/shaders/generated/oitResolve.wgsl.ts +31 -0
- package/src/render/shaders/generated/panel.wgsl.ts +57 -0
- package/src/render/shaders/generated/particle.wgsl.ts +343 -0
- package/src/render/shaders/generated/prefilter.wgsl.ts +69 -0
- package/src/render/shaders/generated/rush.wgsl.ts +139 -0
- package/src/render/shaders/generated/scatter.wgsl.ts +205 -0
- package/src/render/shaders/generated/sdfText.wgsl.ts +78 -0
- package/src/render/shaders/generated/sky.wgsl.ts +109 -0
- package/src/render/shaders/generated/smoke.wgsl.ts +93 -0
- package/src/render/shaders/generated/ssrResolve.wgsl.ts +26 -0
- package/src/render/shaders/generated/ssrTrace.wgsl.ts +94 -0
- package/src/render/shaders/generated/temporalResolve.wgsl.ts +54 -0
- package/src/render/shaders/generated/text.wgsl.ts +107 -0
- package/src/render/shaders/generated/water.wgsl.ts +256 -0
- package/src/render/shaders/generated/windStreaks.wgsl.ts +82 -0
- package/src/render/shaders/gerstner.ts +110 -0
- package/src/render/shaders/globalMedium.ts +396 -0
- package/src/render/shaders/lightVolume.ts +546 -0
- package/src/render/shaders/line.ts +125 -0
- package/src/render/shaders/morph.ts +62 -0
- package/src/render/shaders/octahedral.ts +170 -0
- package/src/render/shaders/octahedralResolve.ts +83 -0
- package/src/render/shaders/oitResolve.ts +42 -0
- package/src/render/shaders/outputTransform.ts +107 -0
- package/src/render/shaders/panel.ts +51 -0
- package/src/render/shaders/particle.ts +438 -0
- package/src/render/shaders/prefilter.ts +278 -0
- package/src/render/shaders/rush.ts +357 -0
- package/src/render/shaders/scatter.ts +211 -0
- package/src/render/shaders/sdfText.ts +68 -0
- package/src/render/shaders/skinning.ts +59 -0
- package/src/render/shaders/sky.ts +243 -0
- package/src/render/shaders/smoke.ts +89 -0
- package/src/render/shaders/ssrResolve.ts +28 -0
- package/src/render/shaders/ssrTrace.ts +233 -0
- package/src/render/shaders/tangentFrame.ts +70 -0
- package/src/render/shaders/temporalResolve.ts +151 -0
- package/src/render/shaders/text.ts +156 -0
- package/src/render/shaders/vertexChannel.ts +71 -0
- package/src/render/shaders/water.ts +356 -0
- package/src/render/shaders/windStreaks.ts +130 -0
- package/src/render/shadowCasters.ts +124 -0
- package/src/render/shadowMap.ts +89 -0
- package/src/render/shotPlacement.ts +266 -0
- package/src/render/skinPalette.ts +157 -0
- package/src/render/ssrPass.ts +241 -0
- package/src/render/surfaceSheet.ts +158 -0
- package/src/render/surfaceTexture.ts +310 -0
- package/src/render/temporalAa.ts +221 -0
- package/src/render/temporalPass.ts +153 -0
- package/src/render/textLayout.ts +239 -0
- package/src/render/textRenderer.ts +201 -0
- package/src/render/thirdPersonCamera.ts +578 -0
- package/src/render/trample.ts +140 -0
- package/src/render/translucentQueue.ts +161 -0
- package/src/render/uniformVectorBudget.ts +246 -0
- package/src/render/uploadStep.ts +14 -0
- package/src/render/vertexDefaults.ts +115 -0
- package/src/render/visibility.ts +56 -0
- package/src/render/waterDraw.ts +167 -0
- package/src/render/waterGrid.ts +180 -0
- package/src/render/waterRenderer.ts +352 -0
- package/src/render/wind.ts +79 -0
- package/src/render/windField.ts +50 -0
- package/src/render/windStreakDraw.ts +131 -0
- package/src/render/windStreakRenderer.ts +130 -0
- package/src/scene/node.ts +336 -0
- package/src/scene/visit.ts +82 -0
- package/src/ui/clipMime.ts +109 -0
- package/src/ui/exportTarget.ts +491 -0
- package/src/ui/frameOverlay.ts +159 -0
- package/src/ui/framePacer.ts +351 -0
- package/src/ui/frameRecorder.ts +333 -0
- package/src/ui/fullscreen.ts +113 -0
- package/src/ui/pixelCursor.ts +99 -0
- package/src/ui/splash.ts +347 -0
- package/src/ui/stillFrame.ts +44 -0
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Light in the air: a beam, a shaft through a window, the cone under a lamp.
|
|
3
|
+
*
|
|
4
|
+
* **Its own program because the thing it draws is not a surface.** A surface is lit, fogged
|
|
5
|
+
* and gated by the time of day; light is none of those, and every attempt to express a beam
|
|
6
|
+
* as a material failed in a different place for the same underlying reason. The recorded
|
|
7
|
+
* history, because it is the whole justification for this file existing:
|
|
8
|
+
*
|
|
9
|
+
* - **Alpha blended, it darkened the sky.** Alpha blending moves what is behind a surface
|
|
10
|
+
* *toward* that surface's own colour, so an unlit beam that came out darker than the dusk
|
|
11
|
+
* behind it swept a solid dark wedge across the frame. It was reported five times as a
|
|
12
|
+
* giant malformed bird, which is what a ninety-metre wedge crossing a flock looks like.
|
|
13
|
+
* - **Additive through the flat pass, it vanished.** The fog term is a `mix` toward the
|
|
14
|
+
* medium's colour, applied to something that *is* the medium being lit, and ninety metres
|
|
15
|
+
* of it multiplied to nothing. Twenty times the emissive did not bring it back.
|
|
16
|
+
*
|
|
17
|
+
* So: nothing here is lit, nothing here is fogged, and nothing here is scaled by night. A
|
|
18
|
+
* beam is *more* visible in fog, not less, because the fog is what there is to light. The
|
|
19
|
+
* closest precedent in this renderer is `bolt.ts`, which says the same thing about a
|
|
20
|
+
* discharge and for the same reason.
|
|
21
|
+
*
|
|
22
|
+
* **The volume comes from the grazing term, not from the geometry.** A single surface cannot
|
|
23
|
+
* be a volume, so what is drawn is a few flat panes through the beam's own axis, and each
|
|
24
|
+
* fragment is weighted by how far from face-on the pane is turned. A pane seen face-on
|
|
25
|
+
* contributes almost nothing; a pane seen edge-on contributes fully, which is exactly when a
|
|
26
|
+
* line of sight travels furthest through the slab that pane stands for. Because the panes
|
|
27
|
+
* cross at the axis, the ones that are edge-on are the ones whose bright part *is* the axis,
|
|
28
|
+
* and the result is a soft core down the middle with no hard edge anywhere. A tube would
|
|
29
|
+
* have given the opposite and read as a hollow pipe.
|
|
30
|
+
*
|
|
31
|
+
* **What that leaves out, and what the two optional terms below are for.** The shape above is
|
|
32
|
+
* a monotone falloff along two axes times a constant per pane, so for the pass's whole first
|
|
33
|
+
* life *nothing in it varied per fragment*. A consumer swept strength from 1.5 to 3.2 and
|
|
34
|
+
* spread from 0.038 to 0.13 across six captures and reported the obvious consequence: the beam
|
|
35
|
+
* gets brighter and wider and its shape never changes, which reads as a lit solid rather than
|
|
36
|
+
* as light standing in air. Neither term is on by default, because a torch beam wants neither
|
|
37
|
+
* and every volume drawn before they existed is entitled to the frame it had.
|
|
38
|
+
*
|
|
39
|
+
* - **`uDust`** breaks the body up with a noise field in world space. What is missing from a
|
|
40
|
+
* smooth cone is any variation at all, so the field does not have to be the one the scene's
|
|
41
|
+
* own motes use, and it deliberately does not read a clock: the offset is a position the
|
|
42
|
+
* caller supplies, so a consumer that evaluates arbitrary instants out of order reproduces
|
|
43
|
+
* the same frame every time. That is the same rule the wind field is under.
|
|
44
|
+
* - **`uSunShadow`** cuts the volume where the sun does not reach, sampling the directional
|
|
45
|
+
* map the surfaces below are already shaded by. It is what makes a shaft carry the bars of
|
|
46
|
+
* the window it came through, and without it a barred floor under a smooth shaft is two
|
|
47
|
+
* halves of one frame disagreeing about the same light.
|
|
48
|
+
*/
|
|
49
|
+
import { resolveConditionals } from './conditionals.js';
|
|
50
|
+
export const LIGHT_VOLUME_VERT = `#version 300 es
|
|
51
|
+
precision highp float;
|
|
52
|
+
|
|
53
|
+
layout(location = 0) in vec3 aPosition;
|
|
54
|
+
layout(location = 1) in vec3 aNormal;
|
|
55
|
+
layout(location = 2) in vec3 aColor;
|
|
56
|
+
layout(location = 3) in float aEmissive;
|
|
57
|
+
|
|
58
|
+
uniform mat4 uViewProj;
|
|
59
|
+
uniform mat4 uModel;
|
|
60
|
+
|
|
61
|
+
out vec3 vColor;
|
|
62
|
+
out float vEnergy;
|
|
63
|
+
out vec3 vNormal;
|
|
64
|
+
out vec3 vWorldPos;
|
|
65
|
+
/**
|
|
66
|
+
* The position in the volume's own space, which is where its shape is known.
|
|
67
|
+
*
|
|
68
|
+
* The falloffs along the axis and away from it are the two things that make this read as
|
|
69
|
+
* light rather than as a pane, and both are smooth functions of *where in the volume* a
|
|
70
|
+
* fragment is. There is no way to author them into the geometry: MeshBuilder states one
|
|
71
|
+
* emissive per quad, so a gradient built that way is a staircase, and the first version of
|
|
72
|
+
* this beam was eight steps a pane trying to hide that. A local position costs one varying
|
|
73
|
+
* and gives both gradients per pixel.
|
|
74
|
+
*/
|
|
75
|
+
out vec3 vLocal;
|
|
76
|
+
|
|
77
|
+
void main() {
|
|
78
|
+
vec4 world = uModel * vec4(aPosition, 1.0);
|
|
79
|
+
vWorldPos = world.xyz;
|
|
80
|
+
vLocal = aPosition;
|
|
81
|
+
/*
|
|
82
|
+
* The normal is rotated by the model matrix without being corrected for scale. A light
|
|
83
|
+
* volume is placed by a rigid transform and a uniform scale, which leaves a normal pointing
|
|
84
|
+
* where it was; the inverse transpose exists for non-uniform scale, and paying for one here
|
|
85
|
+
* would be describing a case this pass does not have.
|
|
86
|
+
*/
|
|
87
|
+
vNormal = mat3(uModel) * aNormal;
|
|
88
|
+
vColor = aColor;
|
|
89
|
+
vEnergy = aEmissive;
|
|
90
|
+
gl_Position = uViewProj * world;
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
export function lightVolumeFrag(options) {
|
|
94
|
+
return resolveConditionals(`#version 300 es
|
|
95
|
+
precision highp float;
|
|
96
|
+
|
|
97
|
+
in vec3 vColor;
|
|
98
|
+
in float vEnergy;
|
|
99
|
+
in vec3 vNormal;
|
|
100
|
+
in vec3 vWorldPos;
|
|
101
|
+
in vec3 vLocal;
|
|
102
|
+
|
|
103
|
+
uniform vec3 uCameraPos;
|
|
104
|
+
/** How much of the authored light to add, 0 to 1. A caller fades a beam with this. */
|
|
105
|
+
uniform float uStrength;
|
|
106
|
+
/**
|
|
107
|
+
* How far the volume reaches along its own +Z, in the units its geometry was built in.
|
|
108
|
+
*
|
|
109
|
+
* The light dies at this distance rather than at whatever the geometry happens to end at,
|
|
110
|
+
* which is what lets a beam dissolve into the air instead of stopping at a bright square.
|
|
111
|
+
*/
|
|
112
|
+
uniform float uLength;
|
|
113
|
+
/**
|
|
114
|
+
* How wide the volume opens, as half-width over distance: the tangent of its half-angle.
|
|
115
|
+
*
|
|
116
|
+
* A cone of this aperture is where the light reaches zero, so the geometry should be built to
|
|
117
|
+
* about the same shape. Larger than the geometry leaves a hard edge at the polygon; smaller
|
|
118
|
+
* fades out before the polygon ends, which is safe and merely narrower than it looks.
|
|
119
|
+
*/
|
|
120
|
+
uniform float uSpread;
|
|
121
|
+
/**
|
|
122
|
+
* How much of the beam's body the dust field takes away, 0 to 1. At 0 nothing is computed.
|
|
123
|
+
*
|
|
124
|
+
* An amount rather than a switch, because the useful range is narrow and low: this is the
|
|
125
|
+
* difference between a shaft and a solid, not a texture to be read.
|
|
126
|
+
*/
|
|
127
|
+
uniform float uDust;
|
|
128
|
+
/** Metres per cell of the field. Small is fine dust; large is smoke and shafts of weather. */
|
|
129
|
+
uniform float uDustScale;
|
|
130
|
+
/**
|
|
131
|
+
* Where the field has drifted to, in metres.
|
|
132
|
+
*
|
|
133
|
+
* A position and not a rate, so nothing in this pass reads a clock. Air moves, and what moves
|
|
134
|
+
* it is the scene's wind, which the caller already samples once a frame for everything else in
|
|
135
|
+
* the air; handing that same accumulated drift here is what keeps the motes in a shaft going
|
|
136
|
+
* the way the smoke outside it goes. It also lets a caller that renders instants out of order
|
|
137
|
+
* ask for any one of them twice and get the same frame.
|
|
138
|
+
*/
|
|
139
|
+
uniform vec3 uDustOffset;
|
|
140
|
+
|
|
141
|
+
#if DIRECTIONAL_SHADOWS
|
|
142
|
+
/** How much of the volume the sun's own shadow map removes, 0 to 1. At 0 nothing is sampled. */
|
|
143
|
+
uniform float uSunShadow;
|
|
144
|
+
uniform mat4 uLightViewProj;
|
|
145
|
+
uniform float uShadowMapSize;
|
|
146
|
+
uniform sampler2D uStaticShadowMap;
|
|
147
|
+
uniform sampler2D uPeeledShadowMap;
|
|
148
|
+
uniform sampler2D uDynamicShadowMap;
|
|
149
|
+
uniform int uPeeledShadowEnabled;
|
|
150
|
+
#endif
|
|
151
|
+
|
|
152
|
+
out vec4 fragColor;
|
|
153
|
+
|
|
154
|
+
/** Where the drawn volume starts along its own +Z, so a shaft can be a slice of a wide cone. */
|
|
155
|
+
uniform float uNear;
|
|
156
|
+
/** Camera position in the volume's own space, so the whole march happens in one frame of reference. */
|
|
157
|
+
uniform vec3 uCameraLocal;
|
|
158
|
+
/** The volume's placement, used only to put a sample back into world space for dust and shadow. */
|
|
159
|
+
uniform mat4 uModelWorld;
|
|
160
|
+
/** How many samples the ray takes. See lightVolumeSamples on the renderer's quality options. */
|
|
161
|
+
uniform int uSamples;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The frame's own depth, so the march stops where the light actually lands.
|
|
165
|
+
*
|
|
166
|
+
* **Without this a ray is bounded by the hull and by nothing else**, so a beam whose hull
|
|
167
|
+
* continues past a solid surface keeps integrating light through it: the shaft carries on under
|
|
168
|
+
* the floor and terminates on the hull's boundary rather than on the ground. Reported from Drift
|
|
169
|
+
* Cut about \`cathedral-of-light\` — the ray on the ground read as unnatural — and it was never a
|
|
170
|
+
* difference between the backends, because both did it. \`demo/dev/volume.html\` is the page that
|
|
171
|
+
* shows it, and \`?length=\` is what turns a hard edge into an unmistakable slab.
|
|
172
|
+
*
|
|
173
|
+
* A *copy* of the depth rather than the attachment itself. Neither backend may sample the depth
|
|
174
|
+
* it is currently testing against: WebGL2 calls it undefined and WebGPU rejects the pass, so the
|
|
175
|
+
* renderer takes a single-sample copy before the first volume of the frame draws.
|
|
176
|
+
*/
|
|
177
|
+
uniform sampler2D uSceneDepth;
|
|
178
|
+
/** Zero where no copy could be taken, and then nothing below runs. See \`uSceneDepth\`. */
|
|
179
|
+
uniform int uSceneDepthEnabled;
|
|
180
|
+
/** One over the drawing buffer, to turn \`gl_FragCoord\` into the copy's own coordinates. */
|
|
181
|
+
uniform vec2 uInvViewport;
|
|
182
|
+
/**
|
|
183
|
+
* Straight from a stored depth to this volume's local space, in one matrix.
|
|
184
|
+
*
|
|
185
|
+
* **Built on the CPU, per draw, because the two backends disagree about clip space and this is
|
|
186
|
+
* the only place that disagreement can live without a second shader.** It is the inverse of
|
|
187
|
+
* (clip correction × view-projection × model), with the depth remap folded in: WebGL2 stores
|
|
188
|
+
* depth in [0,1] and wants NDC z in [-1,1], WebGPU stores and wants [0,1], so one backend's
|
|
189
|
+
* matrix carries a remap the other's does not. The shader is then identical for both and reads
|
|
190
|
+
* \`vec4(ndc.xy, stored, 1)\` without knowing which it is running on.
|
|
191
|
+
*
|
|
192
|
+
* Local rather than world, so the clamp is in the same units as \`enter\` and \`leave\` and costs
|
|
193
|
+
* no second transform inside the march.
|
|
194
|
+
*/
|
|
195
|
+
uniform mat4 uDepthToLocal;
|
|
196
|
+
|
|
197
|
+
/** How quickly the light dies toward the far end. Above 1 keeps the near half bright. */
|
|
198
|
+
const float ALONG_POWER = 1.3;
|
|
199
|
+
/**
|
|
200
|
+
* How quickly it dies away from the axis. This is what gives the beam a core.
|
|
201
|
+
*
|
|
202
|
+
* Two rather than the one the pane version used, and the difference is the march. A pane is a
|
|
203
|
+
* thin sheet, so a linear falloff across it already looked tight; integrating the same falloff
|
|
204
|
+
* along a ray sums every value it passes through, and the shoulders that were invisible on one
|
|
205
|
+
* sheet accumulate into a haze with no edge. Squaring puts the beam back inside its own cone.
|
|
206
|
+
*/
|
|
207
|
+
const float ACROSS_POWER = 2.0;
|
|
208
|
+
/** The most a march will cover, as a multiple of the volume's own length. A ray running along
|
|
209
|
+
the axis would otherwise have no far bound at all when the slab clip degenerates. */
|
|
210
|
+
const float MAX_SPAN = 2.0;
|
|
211
|
+
/** The enclosing cylinder's radius, as a multiple of the cone's own far radius. See the clip. */
|
|
212
|
+
const float WIDEST = 1.05;
|
|
213
|
+
/**
|
|
214
|
+
* How much light a volume gives up per unit of normalised path. See the end of main.
|
|
215
|
+
*
|
|
216
|
+
* Not derived from anything: it sets where the usable range of strength sits, and it is
|
|
217
|
+
* chosen so a beam authored against the pass this replaced lands at about the brightness it had. Raising it makes every volume saturate sooner rather than making any of them better.
|
|
218
|
+
*/
|
|
219
|
+
const float VOLUME_GAIN = 3.0;
|
|
220
|
+
/**
|
|
221
|
+
* Depth tolerance for the shadow lookup, and the width the comparison ramps over.
|
|
222
|
+
*
|
|
223
|
+
* There is no acne to bias away from here, since nothing in the air shadows itself; the offset
|
|
224
|
+
* covers the map's own quantisation, which would otherwise stipple the inside of a shaft where
|
|
225
|
+
* the light and the air agree about it.
|
|
226
|
+
*/
|
|
227
|
+
const float BIAS = 0.0015;
|
|
228
|
+
const float SOFTEN = 0.0025;
|
|
229
|
+
|
|
230
|
+
float hash31(vec3 p) {
|
|
231
|
+
return fract(sin(dot(p, vec3(127.1, 311.7, 74.7))) * 43758.5453123);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Value noise on a world position, trilinear between eight corners of a cell.
|
|
236
|
+
*
|
|
237
|
+
* Its own rather than the sky's, because the sky's is two-dimensional and a shaft of light is
|
|
238
|
+
* a body seen from any side: a 2D field extruded along an axis is a set of stripes as soon as
|
|
239
|
+
* the camera moves off that axis, which is precisely the view a shaft is looked at from.
|
|
240
|
+
*/
|
|
241
|
+
float volumeNoise(vec3 p) {
|
|
242
|
+
vec3 i = floor(p);
|
|
243
|
+
vec3 f = fract(p);
|
|
244
|
+
vec3 u = f * f * (3.0 - 2.0 * f);
|
|
245
|
+
float x00 = mix(hash31(i + vec3(0.0, 0.0, 0.0)), hash31(i + vec3(1.0, 0.0, 0.0)), u.x);
|
|
246
|
+
float x10 = mix(hash31(i + vec3(0.0, 1.0, 0.0)), hash31(i + vec3(1.0, 1.0, 0.0)), u.x);
|
|
247
|
+
float x01 = mix(hash31(i + vec3(0.0, 0.0, 1.0)), hash31(i + vec3(1.0, 0.0, 1.0)), u.x);
|
|
248
|
+
float x11 = mix(hash31(i + vec3(0.0, 1.0, 1.0)), hash31(i + vec3(1.0, 1.0, 1.0)), u.x);
|
|
249
|
+
return mix(mix(x00, x10, u.y), mix(x01, x11, u.y), u.z);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Two octaves, and the second one is what stops it reading as a lava lamp.
|
|
254
|
+
*
|
|
255
|
+
* One octave is a field of soft blobs whose size the eye immediately measures, which replaces
|
|
256
|
+
* "no structure" with "one structure". Two is where the picture stopped changing.
|
|
257
|
+
*/
|
|
258
|
+
float dustField(vec3 p) {
|
|
259
|
+
return volumeNoise(p) * 0.65 + volumeNoise(p * 2.17 + 19.3) * 0.35;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
#if DIRECTIONAL_SHADOWS
|
|
263
|
+
/**
|
|
264
|
+
* How much sun reaches one point in the air.
|
|
265
|
+
*
|
|
266
|
+
* Deliberately not the flat shader's shadowFactor, and the difference is why this is short.
|
|
267
|
+
* Almost everything expensive there is about a receiving *surface*: a receiver-plane depth
|
|
268
|
+
* gradient from screen derivatives, a terminator fade by the angle between a normal and the
|
|
269
|
+
* light, a slope bias. A point in the air has no normal, no plane and no self-shadowing, so
|
|
270
|
+
* none of it applies and none of it is paid for.
|
|
271
|
+
*
|
|
272
|
+
* One tap, because the march is already averaging tens of samples along the ray and a filter
|
|
273
|
+
* on top of that is paying twice for the same softness.
|
|
274
|
+
*
|
|
275
|
+
* textureLod at level zero rather than plain texture: these maps carry one storage level and
|
|
276
|
+
* NEAREST filtering, so the fetch is identical, and an implicit derivative reached through the
|
|
277
|
+
* early exits above is exactly the shape AGENTS.md 2026-08-07 is about.
|
|
278
|
+
*/
|
|
279
|
+
/**
|
|
280
|
+
* A ramp rather than a comparison, which is what keeps the march's own dither invisible.
|
|
281
|
+
*
|
|
282
|
+
* A hard test makes every sample along a ray fully lit or fully dark, so where a shaft crosses
|
|
283
|
+
* the edge of an occluder the only thing separating neighbouring pixels is *how many* of their
|
|
284
|
+
* samples fell on each side — an integer, over a couple of dozen samples, and the dither pattern
|
|
285
|
+
* that decides it becomes legible as a screen door. Softening the comparison over a few
|
|
286
|
+
* centimetres of depth gives each sample a fractional answer near the boundary, and the pattern
|
|
287
|
+
* goes with it. It costs one smoothstep and buys back nothing else: away from an edge this is
|
|
288
|
+
* still exactly 0 or 1.
|
|
289
|
+
*/
|
|
290
|
+
float occlusion(float stored, float compare) {
|
|
291
|
+
return smoothstep(-SOFTEN, SOFTEN, compare - stored);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
float sunReach(vec3 worldPos) {
|
|
295
|
+
vec4 lightPos = uLightViewProj * vec4(worldPos, 1.0);
|
|
296
|
+
if (lightPos.w <= 0.0) return 1.0;
|
|
297
|
+
vec3 p = lightPos.xyz / lightPos.w * 0.5 + 0.5;
|
|
298
|
+
if (p.z > 1.0 || p.x < 0.0 || p.x > 1.0 || p.y < 0.0 || p.y > 1.0) return 1.0;
|
|
299
|
+
|
|
300
|
+
/*
|
|
301
|
+
* Fade toward lit at the border of the map rather than cutting at it, for the reason the
|
|
302
|
+
* flat shader gives: the map covers a radius around the viewer, and a hard edge makes a
|
|
303
|
+
* shaft's bars blink on as the camera walks toward them.
|
|
304
|
+
*/
|
|
305
|
+
vec2 fromCentre = abs(p.xy - 0.5) * 2.0;
|
|
306
|
+
float edgeFade = 1.0 - smoothstep(0.72, 0.98, max(fromCentre.x, fromCentre.y));
|
|
307
|
+
edgeFade *= 1.0 - smoothstep(0.90, 1.0, p.z);
|
|
308
|
+
if (edgeFade <= 0.0) return 1.0;
|
|
309
|
+
|
|
310
|
+
float compare = p.z - BIAS;
|
|
311
|
+
float blocked = occlusion(textureLod(uStaticShadowMap, p.xy, 0.0).r, compare);
|
|
312
|
+
if (uPeeledShadowEnabled != 0) {
|
|
313
|
+
blocked = max(blocked, occlusion(textureLod(uPeeledShadowMap, p.xy, 0.0).r, compare));
|
|
314
|
+
}
|
|
315
|
+
blocked = max(blocked, occlusion(textureLod(uDynamicShadowMap, p.xy, 0.0).r, compare));
|
|
316
|
+
return mix(1.0, 1.0 - blocked, uSunShadow * edgeFade);
|
|
317
|
+
}
|
|
318
|
+
#endif
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* How much light the air holds at one point of the volume, in its own space.
|
|
322
|
+
*
|
|
323
|
+
* **The two falloffs are measured against different things, and that is deliberate.** Along the
|
|
324
|
+
* axis, the fade runs across the extent actually drawn, from full at uNear to nothing at uLength, so a volume is brightest where it starts whatever a caller chose to draw. Across
|
|
325
|
+
* the axis it is measured from the *apex*, because the aperture is an angle and an angle is
|
|
326
|
+
* only meaningful from the point it opens at.
|
|
327
|
+
*
|
|
328
|
+
* The alternative, running both from the apex, was what shipped first and it punishes exactly
|
|
329
|
+
* the case the near plane exists for. A shaft of daylight is authored as a slice taken far down
|
|
330
|
+
* a very wide cone, so that it barely widens over the room; measured from the apex, that slice
|
|
331
|
+
* begins two thirds of the way down its own fade and arrives at a quarter of the light, and the
|
|
332
|
+
* scene it was measured on read as haze rather than as a shaft. Nothing about being a slice
|
|
333
|
+
* should make a volume dim.
|
|
334
|
+
*/
|
|
335
|
+
float densityAt(vec3 local, float near) {
|
|
336
|
+
float drawn = max(uLength - near, 1e-4);
|
|
337
|
+
float along = clamp((local.z - near) / drawn, 0.0, 1.0);
|
|
338
|
+
float openness = length(local.xy) / max(local.z, 1e-3);
|
|
339
|
+
float across = clamp(openness / max(uSpread, 1e-4), 0.0, 1.0);
|
|
340
|
+
return pow(1.0 - along, ALONG_POWER) * pow(1.0 - across, ACROSS_POWER);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
void main() {
|
|
344
|
+
/*
|
|
345
|
+
* The ray, in the volume's own space.
|
|
346
|
+
*
|
|
347
|
+
* **This pass integrates rather than draws sheets, and that is the whole of the second
|
|
348
|
+
* rewrite.** What it used to do was rasterise a few flat panes through the axis and weight
|
|
349
|
+
* each fragment by how far from face-on its pane was turned, which is a stand-in for the
|
|
350
|
+
* path length a line of sight takes through the slab that pane represents. It works from the
|
|
351
|
+
* side and it cannot work down the barrel: every pane contains the axis, so a view lying near
|
|
352
|
+
* that axis lies nearly *within all of them at once*, each one collapses to a narrow bright
|
|
353
|
+
* wedge on screen, and their union reads as a six-armed asterisk rather than as the disc a
|
|
354
|
+
* cone's cross-section actually is. It was reported twice from outside, once as a beam whose
|
|
355
|
+
* shape never changed however it was tuned and once as raw lines in the opening of a room,
|
|
356
|
+
* and switching the pass off in a single capture is what identified the second one.
|
|
357
|
+
*
|
|
358
|
+
* No stand-in survives that, because the failure is not in the weight — it is that a handful
|
|
359
|
+
* of flat sheets is not a volume. So the geometry is now only a hull that decides which
|
|
360
|
+
* pixels to run on, and every one of them walks the ray itself. The path length falls out of
|
|
361
|
+
* the walk instead of being modelled, which is also why the grazing term is gone rather than
|
|
362
|
+
* corrected: there is nothing left for it to stand in for.
|
|
363
|
+
*/
|
|
364
|
+
vec3 origin = uCameraLocal;
|
|
365
|
+
vec3 toFragment = vLocal - origin;
|
|
366
|
+
float span = length(toFragment);
|
|
367
|
+
vec3 dir = span > 1e-5 ? toFragment / span : vec3(0.0, 0.0, 1.0);
|
|
368
|
+
|
|
369
|
+
/*
|
|
370
|
+
* Clipped to the volume twice: the slab it occupies along its axis, and the cylinder that
|
|
371
|
+
* encloses its widest point.
|
|
372
|
+
*
|
|
373
|
+
* The slab alone is what shipped first and it is only tight for a ray running down the barrel.
|
|
374
|
+
* Side-on, which is how a beam is almost always watched, a ray crosses the slab in one step
|
|
375
|
+
* and the clip does nothing at all: the march then spreads its samples over the fallback span
|
|
376
|
+
* while the beam itself is a few metres thick, so a handful of samples land inside it and the
|
|
377
|
+
* rest integrate empty air. It arrives as the beam breaking into a row of separate blobs, and
|
|
378
|
+
* that is what a ninety-metre lighthouse beam did on the first capture of this pass.
|
|
379
|
+
*
|
|
380
|
+
* The enclosing cylinder is the cheap half of the fix and gets the common case: one quadratic
|
|
381
|
+
* in xy, always a bounded interval, and conservative, since the cone is inside the cylinder
|
|
382
|
+
* and no real volume can be clipped away. A ray-cone test would be tighter and brings a second
|
|
383
|
+
* nappe behind the apex and a sign flip in the quadratic with it, for samples that the
|
|
384
|
+
* across-axis falloff already values at zero.
|
|
385
|
+
*/
|
|
386
|
+
float near = min(uNear, uLength);
|
|
387
|
+
float enter = 0.0;
|
|
388
|
+
float leave = uLength * MAX_SPAN;
|
|
389
|
+
if (abs(dir.z) > 1e-5) {
|
|
390
|
+
float toNear = (near - origin.z) / dir.z;
|
|
391
|
+
float toFar = (uLength - origin.z) / dir.z;
|
|
392
|
+
enter = min(toNear, toFar);
|
|
393
|
+
leave = max(toNear, toFar);
|
|
394
|
+
} else if (origin.z < near || origin.z > uLength) {
|
|
395
|
+
discard;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
float reach = uSpread * uLength * WIDEST;
|
|
399
|
+
float ca = dot(dir.xy, dir.xy);
|
|
400
|
+
float cb = 2.0 * dot(origin.xy, dir.xy);
|
|
401
|
+
float cc = dot(origin.xy, origin.xy) - reach * reach;
|
|
402
|
+
if (ca > 1e-8) {
|
|
403
|
+
float disc = cb * cb - 4.0 * ca * cc;
|
|
404
|
+
if (disc <= 0.0) discard;
|
|
405
|
+
float root = sqrt(disc);
|
|
406
|
+
enter = max(enter, (-cb - root) / (2.0 * ca));
|
|
407
|
+
leave = min(leave, (-cb + root) / (2.0 * ca));
|
|
408
|
+
} else if (cc > 0.0) {
|
|
409
|
+
/* Parallel to the axis and outside the cylinder: this ray never enters the volume. */
|
|
410
|
+
discard;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
enter = max(enter, 0.0);
|
|
414
|
+
leave = min(leave, enter + uLength * MAX_SPAN);
|
|
415
|
+
|
|
416
|
+
/*
|
|
417
|
+
* And clipped a third time, by whatever the frame already drew at this pixel.
|
|
418
|
+
*
|
|
419
|
+
* The two clips above are both about the *hull*, and a hull knows nothing about the room it
|
|
420
|
+
* is in. This is the one that makes the beam end on the floor instead of passing through it:
|
|
421
|
+
* the stored depth is where the eye ray met something opaque, so no air beyond it is lit and
|
|
422
|
+
* none of it may be integrated.
|
|
423
|
+
*
|
|
424
|
+
* \`hit.w\` is the perspective divide and it can be non-positive for a pixel at the far plane
|
|
425
|
+
* on some projections, which would flip the comparison and clamp the march to nothing — a
|
|
426
|
+
* beam that vanishes wherever it crosses the sky. Guarded rather than assumed.
|
|
427
|
+
*/
|
|
428
|
+
if (uSceneDepthEnabled != 0) {
|
|
429
|
+
vec2 uv = gl_FragCoord.xy * uInvViewport;
|
|
430
|
+
float stored = textureLod(uSceneDepth, uv, 0.0).r;
|
|
431
|
+
vec4 hit = uDepthToLocal * vec4(uv * 2.0 - 1.0, stored, 1.0);
|
|
432
|
+
if (hit.w > 1e-6) {
|
|
433
|
+
leave = min(leave, dot(hit.xyz / hit.w - origin, dir));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (leave <= enter) discard;
|
|
438
|
+
|
|
439
|
+
int samples = clamp(uSamples, 2, 64);
|
|
440
|
+
float step = (leave - enter) / float(samples);
|
|
441
|
+
|
|
442
|
+
/*
|
|
443
|
+
* The samples sit on an even lattice, and only the shadow lookup is dithered off it.
|
|
444
|
+
*
|
|
445
|
+
* **Which half gets the jitter took three captures to get right.** A march that starts every
|
|
446
|
+
* ray at the same place quantises anything with a hard edge in it into shells, so a shaft
|
|
447
|
+
* crossing an occluder needs its shadow lookup dithered or the boundary arrives as bands.
|
|
448
|
+
* Jittering the *sample positions* to achieve that is the obvious move and it is wrong: the
|
|
449
|
+
* offset shifts every sample on a ray together, so against a smooth integrand it does not
|
|
450
|
+
* average out at all, it slides the whole integral along the integrand's own gradient. Two
|
|
451
|
+
* captures found it twice, once as a rattle over the body of a dusty shaft and once as a
|
|
452
|
+
* screen door down the length of a ninety-metre beam carrying no dust and no shadow, which
|
|
453
|
+
* is what finally named it: the term with nothing sharp in it was the one being spoiled.
|
|
454
|
+
*
|
|
455
|
+
* So the lattice is the plain midpoint rule, which for a smooth density is both quieter and
|
|
456
|
+
* more accurate, and the dither is applied only where something is genuinely discontinuous.
|
|
457
|
+
* The pattern is ordered rather than random — any four-by-four block covers the step at
|
|
458
|
+
* sixteen evenly spaced offsets, so a block averages to the truth however a shadow edge falls
|
|
459
|
+
* across it — and roughened inside its own sixteenth, because a regular figure is what an eye
|
|
460
|
+
* finds once a step is worth about one value of an eight-bit channel.
|
|
461
|
+
*/
|
|
462
|
+
const float BAYER[16] = float[16](
|
|
463
|
+
0.0, 8.0, 2.0, 10.0,
|
|
464
|
+
12.0, 4.0, 14.0, 6.0,
|
|
465
|
+
3.0, 11.0, 1.0, 9.0,
|
|
466
|
+
15.0, 7.0, 13.0, 5.0
|
|
467
|
+
);
|
|
468
|
+
int cell = int(mod(gl_FragCoord.y, 4.0)) * 4 + int(mod(gl_FragCoord.x, 4.0));
|
|
469
|
+
float shadowOffset = ((BAYER[cell] + hash31(vec3(gl_FragCoord.xy, 3.7))) / 16.0 - 0.5) * step;
|
|
470
|
+
|
|
471
|
+
float total = 0.0;
|
|
472
|
+
for (int i = 0; i < 64; i++) {
|
|
473
|
+
if (i >= samples) break;
|
|
474
|
+
float travelled = enter + (float(i) + 0.5) * step;
|
|
475
|
+
vec3 local = origin + dir * travelled;
|
|
476
|
+
|
|
477
|
+
float density = densityAt(local, near);
|
|
478
|
+
if (density <= 0.0) continue;
|
|
479
|
+
|
|
480
|
+
vec3 world = (uModelWorld * vec4(local, 1.0)).xyz;
|
|
481
|
+
if (uDust > 0.0) {
|
|
482
|
+
density *= mix(1.0, dustField((world + uDustOffset) / max(uDustScale, 1e-3)), uDust);
|
|
483
|
+
}
|
|
484
|
+
#if DIRECTIONAL_SHADOWS
|
|
485
|
+
if (uSunShadow > 0.0) {
|
|
486
|
+
vec3 dithered = (uModelWorld * vec4(origin + dir * (travelled + shadowOffset), 1.0)).xyz;
|
|
487
|
+
density *= sunReach(dithered);
|
|
488
|
+
}
|
|
489
|
+
#endif
|
|
490
|
+
total += density;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/*
|
|
494
|
+
* The integral, made dimensionless, then saturated.
|
|
495
|
+
*
|
|
496
|
+
* A raw metre-integral is what the physics wants and is unusable as an authored value: the
|
|
497
|
+
* same settings that read as a shaft across a room would arrive white on a ninety-metre beam,
|
|
498
|
+
* because the longer one simply has more air in it. So it is divided by a length belonging to
|
|
499
|
+
* the volume itself.
|
|
500
|
+
*
|
|
501
|
+
* **The aperture, and not the length, which is the mistake this was written with.** Dividing
|
|
502
|
+
* by the axial extent looks like the obvious choice and quietly assumes every ray runs down
|
|
503
|
+
* the axis. Almost none do: a shaft is nearly always watched from the side, where a ray
|
|
504
|
+
* crosses only the cone's width, so the first version of this divided a two-metre crossing by
|
|
505
|
+
* a twelve-metre extent and the volume arrived at a fifth of the light it should have. It was
|
|
506
|
+
* invisible in the frame and it was invisible in the arithmetic, which is why it took a debug
|
|
507
|
+
* capture writing the span and the accumulation into separate channels to see that the march
|
|
508
|
+
* was running correctly the whole time and only the last line was wrong. The far radius is the
|
|
509
|
+
* transverse scale, so a side-on ray now lands near 1 and an axial one, which really does
|
|
510
|
+
* travel further through more air, lands brighter.
|
|
511
|
+
*
|
|
512
|
+
* Saturating rather than clipping, because a volume of light is a medium: doubling the dust in
|
|
513
|
+
* a shaft does not double what comes out of it, and a linear term either reads flat at usable
|
|
514
|
+
* settings or blows to a white slab past them. This cannot exceed 1 whatever it is handed.
|
|
515
|
+
*/
|
|
516
|
+
float reference = max(uSpread * uLength, 1e-4);
|
|
517
|
+
float lit = 1.0 - exp(-total * step / reference * VOLUME_GAIN);
|
|
518
|
+
|
|
519
|
+
/*
|
|
520
|
+
* Alpha is 1 and the energy is in the colour, because the blend is SRC_ALPHA, ONE. Putting
|
|
521
|
+
* it in both squares it, which is how an effect authored as bright arrives as faint. Every
|
|
522
|
+
* emissive material in this renderer has to pick one channel and mean it: see bolt.ts.
|
|
523
|
+
*/
|
|
524
|
+
fragColor = vec4(vColor * (vEnergy * lit * uStrength), 1.0);
|
|
525
|
+
}
|
|
526
|
+
`, { DIRECTIONAL_SHADOWS: options.directionalShadows }, 'lightVolume');
|
|
527
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A polyline: a flat colour with a clean edge, a real width, and fog.
|
|
3
|
+
*
|
|
4
|
+
* **The plain sibling of `bolt.ts`, and they share a vertex expansion for a reason.** Both
|
|
5
|
+
* turn a segment into a quad that faces the viewer, because a filament has no thickness to
|
|
6
|
+
* see around and a world-fixed cross would make half the segments vanish edge-on. What they
|
|
7
|
+
* do not share is everything after that: an arc is light arriving, so it is additive,
|
|
8
|
+
* unlit, unfogged and allowed past white; a line is a thing in the world, so it is alpha
|
|
9
|
+
* blended, fogged, and its edge is a clean one.
|
|
10
|
+
*
|
|
11
|
+
* **This exists because there is no portable wide line.** WebGL2's `lineWidth` is clamped to
|
|
12
|
+
* one pixel by nearly every driver, and WebGPU has no line width at all. A one-pixel
|
|
13
|
+
* hairline is also the wrong answer on a high-density display, where it reads as a scratch
|
|
14
|
+
* rather than as a stroke. So the only line worth having is a triangle, which is what this
|
|
15
|
+
* draws.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LINE_VERT = "#version 300 es\nlayout(location = 0) in vec3 aFrom;\nlayout(location = 1) in vec3 aTo;\n/** Along the segment (0 or 1), and which side of it (-1 or +1). */\nlayout(location = 2) in vec2 aCorner;\n\nuniform mat4 uViewProj;\nuniform mat4 uModel;\nuniform vec3 uCameraPos;\n/** Half-width in metres, and how much of a pixel a far line must still cover. */\nuniform float uWidth;\nuniform float uMinWidthPerMetre;\n\nout float vSide;\nout vec3 vWorldPos;\n\nvoid main() {\n /*\n * Through the model matrix before anything else, unlike an arc, whose endpoints are\n * world-space by nature. A line is usually attached to something that moves, and the\n * alternative is making every caller transform its own points on the CPU each frame.\n *\n * The width is deliberately *not* scaled by the model. A stroke's weight is a property\n * of how it is drawn rather than of the geometry it follows, so a card that shrinks\n * keeps the same line weight, which is what a reader expects and what a designer means.\n */\n vec3 from = (uModel * vec4(aFrom, 1.0)).xyz;\n vec3 to = (uModel * vec4(aTo, 1.0)).xyz;\n\n vec3 mid = mix(from, to, aCorner.x);\n vec3 dir = to - from;\n float len = length(dir);\n dir = len > 1e-6 ? dir / len : vec3(0.0, 1.0, 0.0);\n\n vec3 view = mid - uCameraPos;\n float dist = length(view);\n view = dist > 1e-6 ? view / dist : vec3(0.0, 0.0, 1.0);\n\n /*\n * Across the segment and across the line of sight. Degenerate exactly when the segment\n * points at the viewer, where any perpendicular is as good as another, and where the\n * segment covers almost no screen anyway.\n */\n vec3 across = cross(dir, view);\n float span = length(across);\n across = span > 1e-4 ? across / span : normalize(cross(dir, vec3(0.0, 1.0, 0.0)) + vec3(1e-3));\n\n /*\n * A floor on the world-space width that grows with distance, so a stroke never thins\n * below a pixel. Under a pixel a thin line does not get fainter, it *flickers*, because\n * the rasteriser catches it on some frames and not others.\n */\n float halfWidth = max(uWidth, dist * uMinWidthPerMetre);\n vec3 world = mid + across * aCorner.y * halfWidth;\n\n vSide = aCorner.y;\n vWorldPos = world;\n gl_Position = uViewProj * vec4(world, 1.0);\n}\n";
|
|
18
|
+
export declare const LINE_FRAG = "#version 300 es\nprecision highp float;\n\nin float vSide;\nin vec3 vWorldPos;\n\nuniform vec3 uColor;\nuniform float uOpacity;\nuniform vec3 uCameraPos;\n/**\n * How far in from the edge the stroke fades, as a fraction of its half-width. Zero is a\n * clean edge, one is a stroke that is soft all the way to its middle.\n */\nuniform float uSoftness;\n\n\nuniform vec3 uFogColor;\n/** Extinction per metre **at the camera's own height**, not at the base. */\nuniform float uFogDensity;\n/** Reciprocal scale height of the haze, per metre. 0 is a uniform medium. */\nuniform float uFogHeightFalloff;\n/** The camera's height, so a fragment's own height is one subtraction away. */\nuniform float uFogEyeY;\nuniform vec3 uUnderwaterColor;\nuniform float uUnderwaterFogDensity;\nuniform float uUnderwaterFactor;\n/** 0 integrates a medium (Beer-Lambert); 1 ramps linearly between near and far. */\nuniform int uFogMode;\n/** Linear mode only: where haze begins, and where it is total. */\nuniform float uFogNear;\nuniform float uFogFar;\n\n/** What distance converges toward: the day's haze, or the water column. */\nvec3 mediumColor() {\n return mix(uFogColor, uUnderwaterColor, uUnderwaterFactor);\n}\n\n/**\n * How much of a surface standing at height pointY, dist metres away, is lost to\n * the medium in between. 0 is perfectly clear, 1 is the medium's own colour.\n */\nfloat mediumFog(float dist, float pointY) {\n /*\n * A depth ramp rather than a medium, for worlds authored against one.\n *\n * Beer-Lambert is the honest model and stays the default: it integrates something\n * physically there, so extinction begins at the eye and never stops. A linear near/far\n * fog is not that \u2014 it is a *look*, with a hard start distance before which the air is\n * perfectly clear, and it is what the fixed-function pipeline offered and what several\n * renderers still expose. Approximating one with the other is not a matter of tuning:\n * matched at half occlusion, the exponential curve still lays haze over everything\n * inside near, where the ramp lays none, and near-field colour desaturates toward the\n * fog colour with nothing to show for it.\n *\n * Height falloff has no meaning here and is ignored: a ramp is defined on distance\n * alone.\n */\n if (uFogMode == 1) {\n float span = max(uFogFar - uFogNear, 1e-4);\n float ramp = clamp((dist - uFogNear) / span, 0.0, 1.0);\n if (uUnderwaterFactor <= 0.0) return ramp;\n float wetLinear = uUnderwaterFogDensity * dist;\n return mix(ramp, 1.0 - exp2(-wetLinear * wetLinear * 1.442695), uUnderwaterFactor);\n }\n\n float t = (pointY - uFogEyeY) * uFogHeightFalloff;\n // (1 - e^-t)/t, which tends to 1 as the ray levels out. Guarded rather than\n // branched: at t = 0 the quotient is 0/0, and 1e-4 of a scale height is 8 mm.\n float denom = abs(t) < 1e-4 ? 1e-4 : t;\n float air = 1.0 - exp(-uFogDensity * dist * (1.0 - exp(-denom)) / denom);\n if (uUnderwaterFactor <= 0.0) return air;\n // Water is its own medium and keeps its own curve, so crossing the surface\n // changes nothing about how the water column reads.\n float wet = uUnderwaterFogDensity * dist;\n return mix(air, 1.0 - exp2(-wet * wet * 1.442695), uUnderwaterFactor);\n}\n\n\nout vec4 outColor;\n\n/** 0 none, 1 sRGB, 2 ACES then sRGB. See renderQuality.ts. */\nuniform int uOutputTransform;\n/** Scales the scene into the tone curve. 1 is the reference grade. See renderQuality.ts. */\nuniform float uOutputExposure;\n\n/*\n * ACES: the reference fit, not the cheap one.\n *\n * This was Narkowicz's single rational function, on the argument that the difference from\n * the reference curve is invisible next to the gain. That argument holds for a look and\n * fails for a *match*, which is what this option is for \u2014 aces exists so a world ported\n * from three.js reads the same, and three.js applies the full fit: into AP1 through\n * ACESInputMat, the RRT and ODT together, then back out through ACESOutputMat.\n *\n * The two curves are not a shade apart. Narkowicz is markedly brighter through the\n * midtones, which is exactly where an interior scene lives, and it is a large part of a\n * measured ~1.7x that survived correcting the colour space and the missing Lambert pi.\n * An approximation of a standard is the wrong thing to hold when the standard is the\n * specification.\n */\nvec3 rrtAndOdtFit(vec3 v) {\n vec3 a = v * (v + 0.0245786) - 0.000090537;\n vec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;\n return a / b;\n}\n\nvec3 acesFilmic(vec3 x) {\n /*\n * Exposure first, because a tone curve is only defined relative to one.\n *\n * The reference RRT and ODT are graded for a dark cinema. Every renderer that ships ACES\n * scales its input to suit whatever it is actually shown on, and the factor each one\n * picks is a *look*, not a standard - so this engine takes no position and reads it from\n * the caller. Neutral by default, which is the reference grade unmodified. three.js's own\n * pick is 1 / 0.6, for a consumer matching one.\n */\n x *= uOutputExposure;\n // Columns, as GLSL reads them: sRGB -> XYZ -> D65_2_D60 -> AP1 -> RRT_SAT.\n const mat3 ACES_INPUT = mat3(\n 0.59719, 0.07600, 0.02840,\n 0.35458, 0.90834, 0.13383,\n 0.04823, 0.01566, 0.83777\n );\n // ODT_SAT -> XYZ -> D60_2_D65 -> sRGB.\n const mat3 ACES_OUTPUT = mat3(\n 1.60475, -0.10208, -0.00327,\n -0.53108, 1.10813, -0.07276,\n -0.07367, -0.00605, 1.07602\n );\n return clamp(ACES_OUTPUT * rrtAndOdtFit(ACES_INPUT * x), 0.0, 1.0);\n}\n\n/*\n * Linear to sRGB. The piecewise form rather than a plain pow: the linear toe near black\n * is where banding lives in an 8-bit buffer, and the cheap approximation puts it in the\n * wrong place.\n */\nvec3 linearToSrgb(vec3 c) {\n vec3 low = c * 12.92;\n vec3 high = 1.055 * pow(max(c, vec3(0.0)), vec3(1.0 / 2.4)) - 0.055;\n return mix(high, low, step(c, vec3(0.0031308)));\n}\n\nvec3 applyOutputTransform(vec3 c) {\n if (uOutputTransform == 0) return c;\n if (uOutputTransform == 2) c = acesFilmic(c);\n return linearToSrgb(c);\n}\n\n\nvoid main() {\n /*\n * Coverage across the ribbon: one down the middle, falling to zero at both edges.\n *\n * The band is at least one pixel wide *in screen space*, which is what lets one shader\n * draw a stroke of any width at any distance without either aliasing into a staircase or\n * blurring into a smear. A constant band is tuned for one width and is wrong at the rest,\n * which is the same argument `SDF_TEXT_FRAG` makes for the same reason.\n */\n float edge = 1.0 - abs(vSide);\n float band = max(fwidth(vSide), uSoftness);\n float coverage = smoothstep(0.0, band, edge);\n\n /*\n * Fogged like geometry, which is where this parts company with `bolt.ts`. That shader\n * includes the same helpers and never calls them, because an arc is light arriving\n * rather than a surface losing some of itself to the air on the way over. A drawn line\n * is a thing in the world and recedes like one.\n */\n float fog = mediumFog(distance(vWorldPos, uCameraPos), vWorldPos.y);\n vec3 color = mix(uColor, mediumColor(), fog);\n outColor = vec4(applyOutputTransform(color), coverage * uOpacity);\n}\n";
|