@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,352 @@
|
|
|
1
|
+
import { glslIsFarDepth, glslSceneDepthToNdc } from '../depthConvention.js';
|
|
2
|
+
/**
|
|
3
|
+
* Ambient occlusion from depth: the estimate, and the blur that makes it usable.
|
|
4
|
+
*
|
|
5
|
+
* Contact shading — the darkening where two surfaces meet, under a wheel arch, along a panel
|
|
6
|
+
* gap, where a plinth stands on a floor. It is most of what makes a model sit in a room
|
|
7
|
+
* rather than float in it, and its absence does not read as a missing effect. It reads as
|
|
8
|
+
* the geometry having been pasted over the picture.
|
|
9
|
+
*
|
|
10
|
+
* **Two passes rather than one, and that is the whole design decision.** Occlusion estimated
|
|
11
|
+
* inside the composite pass and used directly was built first and looked at: twelve depth
|
|
12
|
+
* samples per pixel is a noisy estimate of a smooth quantity, and a frame of it is salt and
|
|
13
|
+
* pepper over every surface. Every renderer that ships this blurs it, and a blur needs the
|
|
14
|
+
* estimate to exist somewhere first. So the estimate lands in its own single-channel target,
|
|
15
|
+
* gets smoothed by a separable pass that will not cross a depth edge, and the composite
|
|
16
|
+
* multiplies by the result.
|
|
17
|
+
*
|
|
18
|
+
* The pairing that makes twelve taps enough: the sampling directions are turned by a
|
|
19
|
+
* rotation that repeats every four pixels, and the blur runs over eight. Every four-pixel run
|
|
20
|
+
* contains all sixteen rotations exactly once, so averaging one recovers a sixteen-times-denser
|
|
21
|
+
* kernel; averaging two also halves what is left of the noise, and — the part that decides the
|
|
22
|
+
* width — leaves a pixel hard against a silhouette with four consecutive taps still on its own
|
|
23
|
+
* side of the edge. Neither half works alone: a random per-pixel rotation leaves noise the blur
|
|
24
|
+
* can only soften, and a window narrower than two periods leaves the tile itself on screen
|
|
25
|
+
* wherever the depth test cuts the window short, as a dotted line along every edge.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The estimate. Writes one channel: 1 is open sky, 0 is fully enclosed.
|
|
29
|
+
*
|
|
30
|
+
* The estimator is the Alchemy/scalable-AO one — for each neighbour, the vector v from this
|
|
31
|
+
* surface to it, weighted max(0, v·n) / (v·v). Two properties earn it its place over a
|
|
32
|
+
* hemisphere of offset points: nothing has to be oriented, so there is no tangent frame and
|
|
33
|
+
* no rotation matrix per pixel, and the 1 / v·v term falls away on its own, so a neighbour
|
|
34
|
+
* further off contributes less without a second range test doing it by hand.
|
|
35
|
+
*/
|
|
36
|
+
export const AO_FRAG = `#version 300 es
|
|
37
|
+
precision highp float;
|
|
38
|
+
|
|
39
|
+
in vec2 vUv;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* **highp, and the whole effect depends on it.** GLSL ES gives a fragment shader's samplers a
|
|
43
|
+
* default precision of *lowp*, whatever the precision highp float line above says — that
|
|
44
|
+
* sets the default for float, not for a sampler. A lowp sampler may hand back eight bits,
|
|
45
|
+
* and eight bits of depth is a scene collapsed onto a couple of hundred planes.
|
|
46
|
+
*
|
|
47
|
+
* This was built without the qualifier and looked at first. The picture says exactly what it
|
|
48
|
+
* is once you know: the reconstructed normal came back as (0, 0, 1) over every surface,
|
|
49
|
+
* because within one of those planes the depth does not change between neighbouring pixels
|
|
50
|
+
* and the cross product of the two derivatives has nothing to work with. What reached the
|
|
51
|
+
* screen was contour banding along the planes themselves — rings up the car's flanks and
|
|
52
|
+
* stripes across the floor, which is a topographic map of the quantisation.
|
|
53
|
+
*/
|
|
54
|
+
uniform highp sampler2D uDepth;
|
|
55
|
+
/**
|
|
56
|
+
* The projection's x and y scales, which turn a world radius into a screen one.
|
|
57
|
+
*
|
|
58
|
+
* mat4[0][0] and [1][1] of the perspective matrix and nothing else, so the whole projection
|
|
59
|
+
* does not have to be uploaded to answer "how much of the frame does half a metre cover at
|
|
60
|
+
* this depth". It carries the aspect ratio with it, which is why the reach is a vec2: a
|
|
61
|
+
* circle on screen is not a circle in UV.
|
|
62
|
+
*/
|
|
63
|
+
uniform vec2 uProjScale;
|
|
64
|
+
/** Clip back to view space, so a depth sample becomes a position that can be compared. */
|
|
65
|
+
uniform mat4 uInvProjection;
|
|
66
|
+
/** How far the sampling reaches, in metres of the world. */
|
|
67
|
+
uniform float uRadius;
|
|
68
|
+
|
|
69
|
+
out float fragColor;
|
|
70
|
+
|
|
71
|
+
/** How many depths each pixel compares itself against. Fixed, so the cost is fixed. */
|
|
72
|
+
const int AO_TAPS = 12;
|
|
73
|
+
/**
|
|
74
|
+
* The golden angle, in radians.
|
|
75
|
+
*
|
|
76
|
+
* Successive taps turned by it never line up into spokes, which a rational fraction of a
|
|
77
|
+
* turn does: a kernel that repeats a direction is blind along it, and it is blind the same
|
|
78
|
+
* way in every pixel, so it reads as a pattern in the surface rather than as noise.
|
|
79
|
+
*/
|
|
80
|
+
const float AO_GOLDEN_ANGLE = 2.39996323;
|
|
81
|
+
/**
|
|
82
|
+
* How far the sampling may reach across the frame, whatever the depth says.
|
|
83
|
+
*
|
|
84
|
+
* A surface almost touching the near plane projects half a metre onto most of the screen,
|
|
85
|
+
* and without a ceiling those pixels each read the whole frame's depth: the effect stops
|
|
86
|
+
* being contact shading and becomes an expensive wide darkening. 6% of the frame.
|
|
87
|
+
*/
|
|
88
|
+
const float AO_MAX_REACH_UV = 0.06;
|
|
89
|
+
/**
|
|
90
|
+
* Self-occlusion guard, as a fraction of the pixel's own view depth.
|
|
91
|
+
*
|
|
92
|
+
* Depth is quantised, so a flat surface samples itself very slightly in front of itself and
|
|
93
|
+
* every flat surface in the world comes back faintly dirty. The error grows with distance,
|
|
94
|
+
* which is why the guard is proportional to depth rather than a constant.
|
|
95
|
+
*/
|
|
96
|
+
const float AO_BIAS = 0.004;
|
|
97
|
+
/**
|
|
98
|
+
* The floor under the 1 / (v·v) weighting, in square metres.
|
|
99
|
+
*
|
|
100
|
+
* Not a guard against dividing by zero, which is what a value near the float epsilon would
|
|
101
|
+
* be. The nearest taps land about a centimetre away, where v·v is 1e-4 and the weight is ten
|
|
102
|
+
* thousand — so a depth quantised to a millimetre yields several units of occlusion out of
|
|
103
|
+
* nothing at all. Measured that way first, with 1e-4 here: a flat floor came back as static.
|
|
104
|
+
* A hundredth of a square metre is a tenth of a metre of separation, which is the scale
|
|
105
|
+
* below which two samples are the same surface rather than one occluding the other.
|
|
106
|
+
*/
|
|
107
|
+
const float AO_EPSILON = 0.01;
|
|
108
|
+
/**
|
|
109
|
+
* How many times further one neighbour may be than the other before the pair straddles an edge.
|
|
110
|
+
*
|
|
111
|
+
* Eight, and deliberately far above anything a continuous surface produces. On a plane seen at a
|
|
112
|
+
* grazing angle the two one-sided depth deltas do differ — depth grows nonlinearly with screen
|
|
113
|
+
* position — but only by a few percent except within a pixel or two of the vanishing point. A
|
|
114
|
+
* silhouette is not a factor of eight, it is a factor of hundreds, so the gate can afford to sit
|
|
115
|
+
* high and it is worth putting it there: every fragment this test lets through keeps the plain
|
|
116
|
+
* quad derivative, which is the picture that shipped.
|
|
117
|
+
*/
|
|
118
|
+
const float AO_EDGE_RATIO = 8.0;
|
|
119
|
+
/**
|
|
120
|
+
* The floor under that ratio, as a fraction of the pixel's own view depth.
|
|
121
|
+
*
|
|
122
|
+
* **Without it the test is a comparison of two quantisation errors**, which is how a flat floor
|
|
123
|
+
* acquires a horizontal band at every contour of constant depth. Five percent of the distance is
|
|
124
|
+
* far above any depth buffer's quantum, above the difference two sides of a grazing plane show,
|
|
125
|
+
* and far below the step at any edge worth shading — a kerb against a deck is metres of it.
|
|
126
|
+
*/
|
|
127
|
+
const float AO_EDGE_FLOOR = 0.05;
|
|
128
|
+
|
|
129
|
+
/** View-space position of whatever is at this pixel, from its depth alone. */
|
|
130
|
+
vec3 viewPosition(vec2 uv, float depth) {
|
|
131
|
+
vec4 clip = vec4(uv * 2.0 - 1.0, ${glslSceneDepthToNdc('depth')}, 1.0);
|
|
132
|
+
vec4 view = uInvProjection * clip;
|
|
133
|
+
return view.xyz / view.w;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
void main() {
|
|
137
|
+
/*
|
|
138
|
+
* One output pixel, in UV, along each axis.
|
|
139
|
+
*
|
|
140
|
+
* Taken before anything branches, because that is where a derivative is defined, and taken of
|
|
141
|
+
* vUv rather than of a reconstructed position: vUv is linear across a fullscreen triangle, so
|
|
142
|
+
* these are exact and constant. They are the *output's* pixel, which is what the neighbour
|
|
143
|
+
* taps below want — this estimate runs at half the frame on one backend and at full size on
|
|
144
|
+
* the other, and a step measured in the depth texture's texels would be wrong on one of them.
|
|
145
|
+
*/
|
|
146
|
+
vec2 stepX = dFdx(vUv);
|
|
147
|
+
vec2 stepY = dFdy(vUv);
|
|
148
|
+
|
|
149
|
+
float depth = textureLod(uDepth, vUv, 0.0).r;
|
|
150
|
+
vec3 p = viewPosition(vUv, depth);
|
|
151
|
+
/*
|
|
152
|
+
* Both derivatives taken before anything branches on the depth. dFdx is only defined where
|
|
153
|
+
* every pixel of the quad reaches it, so a sky pixel returning early would leave the
|
|
154
|
+
* derivative undefined for the *geometry* pixels beside it — a wrong normal along every
|
|
155
|
+
* horizon in the frame, from a shader that reads as correct.
|
|
156
|
+
*/
|
|
157
|
+
vec3 dpdx = dFdx(p);
|
|
158
|
+
vec3 dpdy = dFdy(p);
|
|
159
|
+
/* Nothing occludes the sky, and there is no surface here to occlude. */
|
|
160
|
+
if (${glslIsFarDepth('depth')}) {
|
|
161
|
+
fragColor = 1.0;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/*
|
|
166
|
+
* At a silhouette, the quad derivative above is replaced by the one-sided difference that
|
|
167
|
+
* stays on this pixel's own surface. **Everywhere else it is left exactly alone**, and that
|
|
168
|
+
* restraint is the whole design of these twelve lines.
|
|
169
|
+
*
|
|
170
|
+
* **What it fixes.** A hardware derivative is a difference across a 2x2 quad, and every
|
|
171
|
+
* silhouette in the frame puts two surfaces in one quad: the difference is a secant from the
|
|
172
|
+
* near surface to the far one, metres long, and the cross product of two such secants is a
|
|
173
|
+
* normal roughly *perpendicular* to the real one. The dot of v with n for taps on the
|
|
174
|
+
* neighbouring surface comes back large and positive, the sum saturates, and the pixel clamps
|
|
175
|
+
* to black — every platform edge, every kerb and the character's own outline carrying black
|
|
176
|
+
* speckle. Speckle rather than a clean line, because the rotation tile below turns each
|
|
177
|
+
* pixel's taps differently, and the depth-aware blur that follows is designed *not* to cross
|
|
178
|
+
* an edge, so it preserved the garbage precisely where the garbage was.
|
|
179
|
+
*
|
|
180
|
+
* **What it must not do, learned the hard way.** The textbook cure is to take both one-sided
|
|
181
|
+
* differences everywhere and keep whichever has the smaller depth delta. That was built and
|
|
182
|
+
* shipped to a reporter, and it bands: the two sides of a flat surface differ by a
|
|
183
|
+
* quantisation step or by nothing, so "smaller delta" selects whichever side happens to read
|
|
184
|
+
* zero, the choice flips wherever the depth steps, and on a plane receding from the camera
|
|
185
|
+
* that is a contour — a horizontal stripe across the floor, over the whole world. The header
|
|
186
|
+
* above this shader describes the same picture arriving from a lowp sampler and names it: a
|
|
187
|
+
* topographic map of the quantisation.
|
|
188
|
+
*
|
|
189
|
+
* So the substitution is gated on a *discontinuity*, not on a preference. One side must be
|
|
190
|
+
* several times the other **and** clear of a floor proportional to this pixel's own distance,
|
|
191
|
+
* which no quantisation step and no continuous slope can reach. On everything that is not an
|
|
192
|
+
* edge these lines change nothing at all, which is what makes them safe to add.
|
|
193
|
+
*/
|
|
194
|
+
vec3 right = viewPosition(vUv + stepX, textureLod(uDepth, vUv + stepX, 0.0).r);
|
|
195
|
+
vec3 left = viewPosition(vUv - stepX, textureLod(uDepth, vUv - stepX, 0.0).r);
|
|
196
|
+
vec3 down = viewPosition(vUv + stepY, textureLod(uDepth, vUv + stepY, 0.0).r);
|
|
197
|
+
vec3 up = viewPosition(vUv - stepY, textureLod(uDepth, vUv - stepY, 0.0).r);
|
|
198
|
+
|
|
199
|
+
/* View distance is positive down -z, and the floor is a fraction of this pixel's own. */
|
|
200
|
+
float here = -p.z;
|
|
201
|
+
float edgeFloor = AO_EDGE_FLOOR * here;
|
|
202
|
+
float rightGap = abs(-right.z - here);
|
|
203
|
+
float leftGap = abs(-left.z - here);
|
|
204
|
+
float downGap = abs(-down.z - here);
|
|
205
|
+
float upGap = abs(-up.z - here);
|
|
206
|
+
|
|
207
|
+
/* Both arms written towards increasing x and y, so which one wins cannot flip the handedness
|
|
208
|
+
of the cross product below — only the eye-facing test after it would have to notice. */
|
|
209
|
+
if (rightGap > leftGap * AO_EDGE_RATIO + edgeFloor) dpdx = p - left;
|
|
210
|
+
else if (leftGap > rightGap * AO_EDGE_RATIO + edgeFloor) dpdx = right - p;
|
|
211
|
+
if (downGap > upGap * AO_EDGE_RATIO + edgeFloor) dpdy = p - up;
|
|
212
|
+
else if (upGap > downGap * AO_EDGE_RATIO + edgeFloor) dpdy = down - p;
|
|
213
|
+
|
|
214
|
+
vec3 n = normalize(cross(dpdx, dpdy));
|
|
215
|
+
/*
|
|
216
|
+
* Turned to face the eye. Which sign the cross product comes out with is a fact about the
|
|
217
|
+
* screen-space winding and the handedness of the projection, and a normal pointing away
|
|
218
|
+
* from the camera makes every v·n come back zero, which is a frame with no occlusion in it
|
|
219
|
+
* anywhere. In view space the eye is the origin, so a normal facing it satisfies n·p < 0.
|
|
220
|
+
*/
|
|
221
|
+
if (dot(n, p) > 0.0) n = -n;
|
|
222
|
+
|
|
223
|
+
/*
|
|
224
|
+
* The radius as a fraction of the frame. A metre subtends less of the screen the further
|
|
225
|
+
* away it is, which is the entire reason this is computed per pixel rather than handed in.
|
|
226
|
+
*/
|
|
227
|
+
vec2 reach = min(
|
|
228
|
+
uRadius * uProjScale * 0.5 / max(-p.z, 1e-3),
|
|
229
|
+
vec2(AO_MAX_REACH_UV)
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
/*
|
|
233
|
+
* A rotation that repeats every four pixels: sixteen distinct turns laid out over a 4x4
|
|
234
|
+
* tile. Paired with the four-wide blur that follows, every blurred pixel averages all
|
|
235
|
+
* sixteen, which is what makes twelve taps enough. A per-pixel hash would decorrelate
|
|
236
|
+
* neighbours better in principle and is worse here, because the blur can then only soften
|
|
237
|
+
* the noise rather than complete the kernel.
|
|
238
|
+
*/
|
|
239
|
+
float tile = mod(gl_FragCoord.x, 4.0) + 4.0 * mod(gl_FragCoord.y, 4.0);
|
|
240
|
+
float turn = tile * (6.2831853 / 16.0);
|
|
241
|
+
|
|
242
|
+
float sum = 0.0;
|
|
243
|
+
for (int i = 0; i < AO_TAPS; i++) {
|
|
244
|
+
float t = (float(i) + 0.5) / float(AO_TAPS);
|
|
245
|
+
float angle = turn + float(i) * AO_GOLDEN_ANGLE;
|
|
246
|
+
/* The square root spreads the taps evenly over the disk; without it they crowd the
|
|
247
|
+
centre, where they are measuring the pixel's own depth. */
|
|
248
|
+
vec2 uv = vUv + vec2(cos(angle), sin(angle)) * sqrt(t) * reach;
|
|
249
|
+
|
|
250
|
+
/*
|
|
251
|
+
* textureLod, not texture, and it is the rule rather than a preference: this sample sits
|
|
252
|
+
* inside a loop whose iterations a compiler cannot prove uniform, and an implicit
|
|
253
|
+
* derivative there is what lets one flatten the body and pay for every arm. The fetch is
|
|
254
|
+
* identical — the depth texture has one storage level and NEAREST filters, so there is no
|
|
255
|
+
* mip for a derivative to select. See AGENTS.md, 2026-08-07.
|
|
256
|
+
*/
|
|
257
|
+
float sampled = textureLod(uDepth, uv, 0.0).r;
|
|
258
|
+
if (${glslIsFarDepth('sampled')}) continue;
|
|
259
|
+
|
|
260
|
+
vec3 v = viewPosition(uv, sampled) - p;
|
|
261
|
+
float vv = dot(v, v);
|
|
262
|
+
/* Past the radius it is a different surface rather than a neighbour of this one. */
|
|
263
|
+
if (vv > uRadius * uRadius) continue;
|
|
264
|
+
sum += max(0.0, dot(v, n) - AO_BIAS * (-p.z)) / (vv + AO_EPSILON);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
fragColor = clamp(1.0 - 2.0 * uRadius * sum / float(AO_TAPS), 0.0, 1.0);
|
|
268
|
+
}
|
|
269
|
+
`;
|
|
270
|
+
/**
|
|
271
|
+
* One direction of the blur. Run twice, across and then down.
|
|
272
|
+
*
|
|
273
|
+
* Separable, so a four-wide square costs eight taps rather than sixteen, and **depth-aware**,
|
|
274
|
+
* so it does not carry a car's occlusion out onto the wall behind it. That second part is
|
|
275
|
+
* what separates a blur from a smear: an ordinary gaussian over this estimate produces a
|
|
276
|
+
* dark halo around every silhouette, which is more obviously wrong than the noise it was
|
|
277
|
+
* added to remove.
|
|
278
|
+
*/
|
|
279
|
+
export const AO_BLUR_FRAG = `#version 300 es
|
|
280
|
+
precision highp float;
|
|
281
|
+
|
|
282
|
+
in vec2 vUv;
|
|
283
|
+
|
|
284
|
+
uniform sampler2D uAo;
|
|
285
|
+
/** highp for the same reason as the estimate: a lowp sampler may return eight bits, and a
|
|
286
|
+
blur that decides what an edge is from eight-bit depth finds edges that are not there. */
|
|
287
|
+
uniform highp sampler2D uDepth;
|
|
288
|
+
/** One texel across, in UV, along the axis being blurred. The other component is zero. */
|
|
289
|
+
uniform vec2 uStep;
|
|
290
|
+
/**
|
|
291
|
+
* Turns a depth sample into view-space metres, as (m22, m32, m23, m33) of the inverse
|
|
292
|
+
* projection. The whole matrix is not needed to answer how far away a pixel is, and the blur
|
|
293
|
+
* asks that question five times per pixel.
|
|
294
|
+
*/
|
|
295
|
+
uniform vec4 uDepthToViewZ;
|
|
296
|
+
|
|
297
|
+
out float fragColor;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* How far apart two pixels may be, as a fraction of their distance from the eye, before they
|
|
301
|
+
* stop being the same surface.
|
|
302
|
+
*
|
|
303
|
+
* Relative rather than absolute, because the same 5 cm step is a cliff on a dashboard and
|
|
304
|
+
* nothing at all on a far wall.
|
|
305
|
+
*/
|
|
306
|
+
const float AO_BLUR_DEPTH_TOLERANCE = 0.02;
|
|
307
|
+
|
|
308
|
+
float viewZ(float depth) {
|
|
309
|
+
float ndc = ${glslSceneDepthToNdc('depth')};
|
|
310
|
+
return (uDepthToViewZ.x * ndc + uDepthToViewZ.y) / (uDepthToViewZ.z * ndc + uDepthToViewZ.w);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
void main() {
|
|
314
|
+
float centre = viewZ(textureLod(uDepth, vUv, 0.0).r);
|
|
315
|
+
float tolerance = AO_BLUR_DEPTH_TOLERANCE * abs(centre) + 1e-4;
|
|
316
|
+
float sum = 0.0;
|
|
317
|
+
float weight = 0.0;
|
|
318
|
+
/*
|
|
319
|
+
* **Eight consecutive pixels: two whole periods of the rotation tile, not one.**
|
|
320
|
+
*
|
|
321
|
+
* One period was the original design and it is a quarter of a denoiser. The estimate is
|
|
322
|
+
* twelve taps of a noisy quantity, and it is only usable because a run of pixels averages
|
|
323
|
+
* the sixteen rotations of the 4x4 tile back into one kernel — but averaging four estimates
|
|
324
|
+
* divides their noise by two, and two of those four are the *same* pixel's neighbours seen
|
|
325
|
+
* from one side. What reached the screen was a soft field with a visible grain in it, and
|
|
326
|
+
* along every silhouette something worse.
|
|
327
|
+
*
|
|
328
|
+
* **The edge is what forces the second period.** The weight below is designed to fall to zero
|
|
329
|
+
* across a depth edge, so a pixel beside a rail keeps only the taps on its own side. With a
|
|
330
|
+
* four-wide window that can be a single tap — one rotation out of sixteen, at the tile's own
|
|
331
|
+
* four-pixel period, running along the edge. That is the dotted line reported along every
|
|
332
|
+
* rail, and no amount of care in the estimate removes it, because the estimate was never
|
|
333
|
+
* meant to stand alone. Eight wide, a pixel hard against an edge still has four consecutive
|
|
334
|
+
* taps on its own side, which is every phase exactly once — the kernel the estimate was
|
|
335
|
+
* designed around, recovered on the one side it can be recovered from.
|
|
336
|
+
*
|
|
337
|
+
* The cost is four more taps an axis on a single-channel target, and what it buys back is the
|
|
338
|
+
* halving of the noise that the four-wide window was already relying on and not getting.
|
|
339
|
+
*/
|
|
340
|
+
for (int i = -3; i <= 4; i++) {
|
|
341
|
+
vec2 uv = vUv + uStep * float(i);
|
|
342
|
+
float z = viewZ(textureLod(uDepth, uv, 0.0).r);
|
|
343
|
+
/* One if this neighbour is on the same surface, falling to zero across an edge. */
|
|
344
|
+
float w = max(0.0, 1.0 - abs(z - centre) / tolerance);
|
|
345
|
+
sum += textureLod(uAo, uv, 0.0).r * w;
|
|
346
|
+
weight += w;
|
|
347
|
+
}
|
|
348
|
+
/* An isolated pixel — a thin rail against a far wall — keeps its own estimate rather than
|
|
349
|
+
dividing by nothing. */
|
|
350
|
+
fragColor = weight > 0.0 ? sum / weight : textureLod(uAo, vUv, 0.0).r;
|
|
351
|
+
}
|
|
352
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An arcane aura: the volume a floating object sits inside.
|
|
3
|
+
*
|
|
4
|
+
* Pairs with `PLUME_VERT`, exactly as `FIRE_FRAG` does — the vertex stage only builds
|
|
5
|
+
* a world-fixed cross of quads, and which effect that cross becomes is entirely a
|
|
6
|
+
* fragment-stage decision. So this costs no new renderer and no new geometry path.
|
|
7
|
+
*
|
|
8
|
+
* Where a flame is carved *vertically* — a taper toward the tip, a threshold rising
|
|
9
|
+
* with height, so it licks and breaks up — a spell is carved *radially*. Everything
|
|
10
|
+
* below works in polar coordinates about the quad centre: a bright thin core, a wide
|
|
11
|
+
* soft corona, and two noise bands turning in opposite directions.
|
|
12
|
+
*
|
|
13
|
+
* The counter-rotation is the whole effect. One band turning alone reads as a sheet
|
|
14
|
+
* being spun, which is the same flatness `BLADES` describes for a billboarded fire;
|
|
15
|
+
* two bands shearing against each other have no single rotation to read, so the eye
|
|
16
|
+
* gets motion without direction. That is what separates a spell from a lamp on a
|
|
17
|
+
* dimmer.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ARCANE_FRAG = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\nin float vSeed;\nin float vDistance;\nin vec3 vWorldPos;\n\nuniform float uTime;\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\nuniform int uNoiseOctaves;\nuniform vec4 uClipPlane;\nuniform int uClipEnabled;\n/** The caller's colour, so an aura shifts with the world's own palette. */\nuniform vec3 uTint;\n\nout vec4 outColor;\n\nfloat hash21(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nfloat valueNoise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),\n mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nvoid main() {\n if (uClipEnabled != 0 && dot(vec4(vWorldPos, 1.0), uClipPlane) < 0.0) discard;\n\n // Polar about the quad centre. This is the line that makes it an orb rather\n // than a column; everything downstream reads radius and angle, never height.\n float radius = length(vUv - 0.5) * 2.0;\n if (radius >= 1.0) discard;\n\n vec2 d = vUv - 0.5;\n float angle = atan(d.y, d.x);\n float t = uTime + vSeed * 37.0;\n\n /*\n * Two bands, turning opposite ways at different rates. Sampled in (angle, radius)\n * space so the noise wraps around the disc instead of sliding across it \u2014 noise in\n * UV space would drift off one edge and read as a texture being scrolled.\n */\n float inner = valueNoise(vec2(angle * 1.9 + t * 0.55, radius * 4.2));\n float outer = valueNoise(vec2(angle * 3.1 - t * 0.34, radius * 2.6));\n float swirl = inner * 0.62 + outer * 0.38;\n if (uNoiseOctaves > 1) {\n swirl = mix(swirl, swirl * valueNoise(vec2(angle * 6.3 + t * 0.9, radius * 8.0)) * 2.0, 0.35);\n }\n\n /*\n * Core and corona as two separate falloffs rather than one curve. A single falloff\n * gives a blob; what makes this read as *contained energy* is a small bright centre\n * with a much wider, much fainter halo, so the object inside stays legible.\n */\n float core = 1.0 - smoothstep(0.0, 0.28, radius);\n float corona = (1.0 - smoothstep(0.18, 1.0, radius)) * (0.35 + swirl * 0.65);\n float body = core * 0.9 + corona;\n if (body <= 0.02) discard;\n\n // Hot centre through the tint to a dark rim, so the core reads as white-hot\n // energy and the edge as the colour it is made of.\n vec3 col = mix(uTint * 0.35, uTint, smoothstep(0.0, 0.55, body));\n col = mix(col, vec3(1.0), smoothstep(0.82, 1.4, body));\n col *= uTint;\n\n float alpha = clamp(body * 1.6, 0.0, 1.0);\n // Additive light must lose alpha as it scatters, or mixing its colour alone\n // still makes a distant aura glow through fog and through water.\n float fog = mediumFog(vDistance, vWorldPos.y);\n col = mix(col, mediumColor(), fog);\n alpha *= 1.0 - fog;\n\n outColor = vec4(col, alpha);\n}\n";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { FOG_GLSL } from './fog.js';
|
|
2
|
+
/**
|
|
3
|
+
* An arcane aura: the volume a floating object sits inside.
|
|
4
|
+
*
|
|
5
|
+
* Pairs with `PLUME_VERT`, exactly as `FIRE_FRAG` does — the vertex stage only builds
|
|
6
|
+
* a world-fixed cross of quads, and which effect that cross becomes is entirely a
|
|
7
|
+
* fragment-stage decision. So this costs no new renderer and no new geometry path.
|
|
8
|
+
*
|
|
9
|
+
* Where a flame is carved *vertically* — a taper toward the tip, a threshold rising
|
|
10
|
+
* with height, so it licks and breaks up — a spell is carved *radially*. Everything
|
|
11
|
+
* below works in polar coordinates about the quad centre: a bright thin core, a wide
|
|
12
|
+
* soft corona, and two noise bands turning in opposite directions.
|
|
13
|
+
*
|
|
14
|
+
* The counter-rotation is the whole effect. One band turning alone reads as a sheet
|
|
15
|
+
* being spun, which is the same flatness `BLADES` describes for a billboarded fire;
|
|
16
|
+
* two bands shearing against each other have no single rotation to read, so the eye
|
|
17
|
+
* gets motion without direction. That is what separates a spell from a lamp on a
|
|
18
|
+
* dimmer.
|
|
19
|
+
*/
|
|
20
|
+
export const ARCANE_FRAG = `#version 300 es
|
|
21
|
+
precision highp float;
|
|
22
|
+
|
|
23
|
+
in vec2 vUv;
|
|
24
|
+
in float vSeed;
|
|
25
|
+
in float vDistance;
|
|
26
|
+
in vec3 vWorldPos;
|
|
27
|
+
|
|
28
|
+
uniform float uTime;
|
|
29
|
+
${FOG_GLSL}
|
|
30
|
+
uniform int uNoiseOctaves;
|
|
31
|
+
uniform vec4 uClipPlane;
|
|
32
|
+
uniform int uClipEnabled;
|
|
33
|
+
/** The caller's colour, so an aura shifts with the world's own palette. */
|
|
34
|
+
uniform vec3 uTint;
|
|
35
|
+
|
|
36
|
+
out vec4 outColor;
|
|
37
|
+
|
|
38
|
+
float hash21(vec2 p) {
|
|
39
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
float valueNoise(vec2 p) {
|
|
43
|
+
vec2 i = floor(p);
|
|
44
|
+
vec2 f = fract(p);
|
|
45
|
+
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
46
|
+
return mix(
|
|
47
|
+
mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),
|
|
48
|
+
mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),
|
|
49
|
+
u.y
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void main() {
|
|
54
|
+
if (uClipEnabled != 0 && dot(vec4(vWorldPos, 1.0), uClipPlane) < 0.0) discard;
|
|
55
|
+
|
|
56
|
+
// Polar about the quad centre. This is the line that makes it an orb rather
|
|
57
|
+
// than a column; everything downstream reads radius and angle, never height.
|
|
58
|
+
float radius = length(vUv - 0.5) * 2.0;
|
|
59
|
+
if (radius >= 1.0) discard;
|
|
60
|
+
|
|
61
|
+
vec2 d = vUv - 0.5;
|
|
62
|
+
float angle = atan(d.y, d.x);
|
|
63
|
+
float t = uTime + vSeed * 37.0;
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* Two bands, turning opposite ways at different rates. Sampled in (angle, radius)
|
|
67
|
+
* space so the noise wraps around the disc instead of sliding across it — noise in
|
|
68
|
+
* UV space would drift off one edge and read as a texture being scrolled.
|
|
69
|
+
*/
|
|
70
|
+
float inner = valueNoise(vec2(angle * 1.9 + t * 0.55, radius * 4.2));
|
|
71
|
+
float outer = valueNoise(vec2(angle * 3.1 - t * 0.34, radius * 2.6));
|
|
72
|
+
float swirl = inner * 0.62 + outer * 0.38;
|
|
73
|
+
if (uNoiseOctaves > 1) {
|
|
74
|
+
swirl = mix(swirl, swirl * valueNoise(vec2(angle * 6.3 + t * 0.9, radius * 8.0)) * 2.0, 0.35);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* Core and corona as two separate falloffs rather than one curve. A single falloff
|
|
79
|
+
* gives a blob; what makes this read as *contained energy* is a small bright centre
|
|
80
|
+
* with a much wider, much fainter halo, so the object inside stays legible.
|
|
81
|
+
*/
|
|
82
|
+
float core = 1.0 - smoothstep(0.0, 0.28, radius);
|
|
83
|
+
float corona = (1.0 - smoothstep(0.18, 1.0, radius)) * (0.35 + swirl * 0.65);
|
|
84
|
+
float body = core * 0.9 + corona;
|
|
85
|
+
if (body <= 0.02) discard;
|
|
86
|
+
|
|
87
|
+
// Hot centre through the tint to a dark rim, so the core reads as white-hot
|
|
88
|
+
// energy and the edge as the colour it is made of.
|
|
89
|
+
vec3 col = mix(uTint * 0.35, uTint, smoothstep(0.0, 0.55, body));
|
|
90
|
+
col = mix(col, vec3(1.0), smoothstep(0.82, 1.4, body));
|
|
91
|
+
col *= uTint;
|
|
92
|
+
|
|
93
|
+
float alpha = clamp(body * 1.6, 0.0, 1.0);
|
|
94
|
+
// Additive light must lose alpha as it scatters, or mixing its colour alone
|
|
95
|
+
// still makes a distant aura glow through fog and through water.
|
|
96
|
+
float fog = mediumFog(vDistance, vWorldPos.y);
|
|
97
|
+
col = mix(col, mediumColor(), fog);
|
|
98
|
+
alpha *= 1.0 - fog;
|
|
99
|
+
|
|
100
|
+
outColor = vec4(col, alpha);
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bloom: the three stages of spreading a bright thing past its own pixels.
|
|
3
|
+
*
|
|
4
|
+
* **What it is for, in the words of the consumer who asked for it.** Nothing in this renderer
|
|
5
|
+
* makes a bright thing look bright: an emissive surface is exactly as bright as its pixels and
|
|
6
|
+
* not one pixel wider, so anything meant to overwhelm the eye has to be faked in geometry — a
|
|
7
|
+
* core sphere, a second sphere slightly larger, and fifty-four additive particles standing in
|
|
8
|
+
* for one pass. Every neon ring, lit poster, glyph band and shaft of daylight is the same
|
|
9
|
+
* request.
|
|
10
|
+
*
|
|
11
|
+
* **It composes with the tone curve rather than replacing it.** The curve decides how a bright
|
|
12
|
+
* pixel rolls off; this decides how far it spreads. So the result is added in linear scene
|
|
13
|
+
* units, before the grade, and the grade then rolls off the sum exactly as it rolls off
|
|
14
|
+
* anything else.
|
|
15
|
+
*
|
|
16
|
+
* **The threshold is in scene units, which is only meaningful with a target that keeps them.**
|
|
17
|
+
* With an eight-bit target the scene is clipped to 0..1 before the composite ever sees it, so a
|
|
18
|
+
* star and a sheet of white paper arrive as the same colour and a threshold can only mean
|
|
19
|
+
* whiteness. That is the whole reason hdrScene exists and it is why bloom asks for it.
|
|
20
|
+
*
|
|
21
|
+
* Three stages, and the middle one repeats:
|
|
22
|
+
*
|
|
23
|
+
* 1. **Prefilter**, full resolution down to half: subtract the threshold and keep what is left.
|
|
24
|
+
* 2. **Downsample**, halving each time, six levels or as many as the frame allows. Each level
|
|
25
|
+
* is an octave of the spread, and adding them back is what produces a wide falloff rather
|
|
26
|
+
* than one gaussian with a hard end.
|
|
27
|
+
* 3. **Upsample**, additively back up the chain through a tent filter.
|
|
28
|
+
*
|
|
29
|
+
* Deliberately absent, because they were asked against by name: lens dirt, anamorphic streaks
|
|
30
|
+
* and ghosting. One threshold, one radius, one strength.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Stage one: threshold the scene and halve it.
|
|
34
|
+
*
|
|
35
|
+
* **Subtracted rather than stepped**, which is what keeps one number honest. A hard cut at the
|
|
36
|
+
* threshold puts a visible edge through any gradient that crosses it, and repairing that is
|
|
37
|
+
* where a second knob usually arrives. Scaling the colour by how far its own luminance sits
|
|
38
|
+
* past the threshold is continuous, starts at exactly nothing, and needs no knee: a pixel just
|
|
39
|
+
* over the line contributes almost none of itself, and one far over contributes nearly all.
|
|
40
|
+
*
|
|
41
|
+
* **The boxes are averaged by the Karis weighting here and nowhere else.** A single pixel far
|
|
42
|
+
* brighter than its neighbours — which this renderer produces, on glossy dark paint, and which
|
|
43
|
+
* STATUS 6.3 measures — would otherwise be spread into a visible blob by the very pass whose
|
|
44
|
+
* job is to spread bright things. Weighting each box by 1 / (1 + luma) before averaging makes
|
|
45
|
+
* one runaway pixel count for little against its four neighbours. It is applied only to the
|
|
46
|
+
* first stage because it is not energy-preserving, and running it down the whole chain darkens
|
|
47
|
+
* every large bright area rather than only taming isolated ones.
|
|
48
|
+
*/
|
|
49
|
+
export declare const BLOOM_PREFILTER_FRAG = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\n\nuniform sampler2D uSource;\n/** One source texel in UV. The thirteen taps are laid out in source texels. */\nuniform vec2 uTexel;\n/** In scene units. 1.0 is \"brighter than white\", which is the useful place to start. */\nuniform float uThreshold;\n\nout vec4 fragColor;\n\n/**\n * A ceiling on what any one pixel may contribute, well above anything a scene means.\n *\n * Not a look control. A half-float target can hold an infinity, and an infinity through the\n * threshold below is inf/inf, which is a NaN that the chain then spreads across the whole\n * frame \u2014 the one failure mode where a post pass destroys the picture rather than degrading\n * it. Anything above this is indistinguishable after the tone curve anyway.\n */\nconst float BLOOM_CEILING = 256.0;\n\nfloat brightness(vec3 c) {\n return max(c.r, max(c.g, c.b));\n}\n\nvec3 fetch(vec2 uv) {\n vec3 c = min(textureLod(uSource, uv, 0.0).rgb, vec3(BLOOM_CEILING));\n float bright = brightness(c);\n return c * (max(bright - uThreshold, 0.0) / max(bright, 1e-4));\n}\n\n/** How much a box counts for. A runaway pixel drags its box's brightness up and its weight down. */\nfloat firefly(vec3 c) {\n return 1.0 / (1.0 + brightness(c));\n}\n\nvoid main() {\n\n vec2 t = uTexel;\n vec3 a = fetch(vUv + vec2(-2.0, 2.0) * t);\n vec3 b = fetch(vUv + vec2( 0.0, 2.0) * t);\n vec3 c = fetch(vUv + vec2( 2.0, 2.0) * t);\n vec3 d = fetch(vUv + vec2(-2.0, 0.0) * t);\n vec3 e = fetch(vUv);\n vec3 f = fetch(vUv + vec2( 2.0, 0.0) * t);\n vec3 g = fetch(vUv + vec2(-2.0, -2.0) * t);\n vec3 h = fetch(vUv + vec2( 0.0, -2.0) * t);\n vec3 i = fetch(vUv + vec2( 2.0, -2.0) * t);\n vec3 j = fetch(vUv + vec2(-1.0, 1.0) * t);\n vec3 k = fetch(vUv + vec2( 1.0, 1.0) * t);\n vec3 l = fetch(vUv + vec2(-1.0, -1.0) * t);\n vec3 m = fetch(vUv + vec2( 1.0, -1.0) * t);\n\n vec3 box0 = (a + b + d + e) * 0.25;\n vec3 box1 = (b + c + e + f) * 0.25;\n vec3 box2 = (d + e + g + h) * 0.25;\n vec3 box3 = (e + f + h + i) * 0.25;\n vec3 box4 = (j + k + l + m) * 0.25;\n\n float w0 = firefly(box0) * 0.125;\n float w1 = firefly(box1) * 0.125;\n float w2 = firefly(box2) * 0.125;\n float w3 = firefly(box3) * 0.125;\n float w4 = firefly(box4) * 0.5;\n vec3 sum = box0 * w0 + box1 * w1 + box2 * w2 + box3 * w3 + box4 * w4;\n fragColor = vec4(sum / max(w0 + w1 + w2 + w3 + w4, 1e-4), 1.0);\n}\n";
|
|
50
|
+
/**
|
|
51
|
+
* Stage two: halve what is already thresholded, once per level.
|
|
52
|
+
*
|
|
53
|
+
* The weights sum to exactly one, so each level holds the average of what fed it and the chain
|
|
54
|
+
* neither gains nor loses light. Nothing is thresholded again: that decision was made once, at
|
|
55
|
+
* full resolution, where it could still be made per pixel.
|
|
56
|
+
*/
|
|
57
|
+
export declare const BLOOM_DOWNSAMPLE_FRAG = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\n\nuniform sampler2D uSource;\nuniform vec2 uTexel;\n\nout vec4 fragColor;\n\nvec3 fetch(vec2 uv) {\n return textureLod(uSource, uv, 0.0).rgb;\n}\n\nvoid main() {\n\n vec2 t = uTexel;\n vec3 a = fetch(vUv + vec2(-2.0, 2.0) * t);\n vec3 b = fetch(vUv + vec2( 0.0, 2.0) * t);\n vec3 c = fetch(vUv + vec2( 2.0, 2.0) * t);\n vec3 d = fetch(vUv + vec2(-2.0, 0.0) * t);\n vec3 e = fetch(vUv);\n vec3 f = fetch(vUv + vec2( 2.0, 0.0) * t);\n vec3 g = fetch(vUv + vec2(-2.0, -2.0) * t);\n vec3 h = fetch(vUv + vec2( 0.0, -2.0) * t);\n vec3 i = fetch(vUv + vec2( 2.0, -2.0) * t);\n vec3 j = fetch(vUv + vec2(-1.0, 1.0) * t);\n vec3 k = fetch(vUv + vec2( 1.0, 1.0) * t);\n vec3 l = fetch(vUv + vec2(-1.0, -1.0) * t);\n vec3 m = fetch(vUv + vec2( 1.0, -1.0) * t);\n\n vec3 box0 = (a + b + d + e) * 0.25;\n vec3 box1 = (b + c + e + f) * 0.25;\n vec3 box2 = (d + e + g + h) * 0.25;\n vec3 box3 = (e + f + h + i) * 0.25;\n vec3 box4 = (j + k + l + m) * 0.25;\n\n fragColor = vec4(box4 * 0.5 + (box0 + box1 + box2 + box3) * 0.125, 1.0);\n}\n";
|
|
58
|
+
/**
|
|
59
|
+
* Stage three: a 3x3 tent, added into the level above.
|
|
60
|
+
*
|
|
61
|
+
* **Additive rather than a mix, and each octave counts the same.** A lone bright pixel arrives
|
|
62
|
+
* at level n divided by four to the n, spread over four to the n pixels, so summing the levels
|
|
63
|
+
* lifts its own pixel by about a third and lays a long shallow tail around it. That falloff is
|
|
64
|
+
* what a real glare looks like; a single gaussian gives a disc with an end to it.
|
|
65
|
+
*
|
|
66
|
+
* The radius is in UV rather than in texels, so it is the same fraction of the frame at every
|
|
67
|
+
* level and on every display. A tent rather than a box because the seams between the four
|
|
68
|
+
* texels a bilinear upsample reads are otherwise visible as a grid on a wide, faint halo.
|
|
69
|
+
*/
|
|
70
|
+
export declare const BLOOM_UPSAMPLE_FRAG = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\n\nuniform sampler2D uSource;\n/** How far the tent reaches, in UV. One number for the whole chain. */\nuniform float uRadius;\n\nout vec4 fragColor;\n\nvoid main() {\n float r = uRadius;\n vec3 a = textureLod(uSource, vUv + vec2(-r, r), 0.0).rgb;\n vec3 b = textureLod(uSource, vUv + vec2(0.0, r), 0.0).rgb;\n vec3 c = textureLod(uSource, vUv + vec2( r, r), 0.0).rgb;\n vec3 d = textureLod(uSource, vUv + vec2(-r, 0.0), 0.0).rgb;\n vec3 e = textureLod(uSource, vUv, 0.0).rgb;\n vec3 f = textureLod(uSource, vUv + vec2( r, 0.0), 0.0).rgb;\n vec3 g = textureLod(uSource, vUv + vec2(-r, -r), 0.0).rgb;\n vec3 h = textureLod(uSource, vUv + vec2(0.0, -r), 0.0).rgb;\n vec3 i = textureLod(uSource, vUv + vec2( r, -r), 0.0).rgb;\n\n vec3 sum = e * 4.0 + (b + d + f + h) * 2.0 + (a + c + g + i);\n fragColor = vec4(sum * 0.0625, 1.0);\n}\n";
|