@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,310 @@
|
|
|
1
|
+
/** A GPU image the caller supplies, sampled by the flat shader as surface colour. */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How a texture behaves past its edges and between its texels.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately small. Every knob here is one a tiling world actually needs; anything
|
|
7
|
+
* beyond it — swizzles, borders, compressed formats — is a format decision that
|
|
8
|
+
* belongs to whoever is generating the pixels, not to the surface that shows them.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Everything the flat pass needs to know about a surface, in one call.
|
|
12
|
+
*
|
|
13
|
+
* **Shaped for what comes after it.** ORM is the next map and emissive the one after; both are a
|
|
14
|
+
* field here rather than a fourth and fifth setter, which is the whole reason this replaced
|
|
15
|
+
* `setSurfaceTexture` rather than sitting beside it. A consumer setting four maps in four calls is
|
|
16
|
+
* four chances to forget one, and four resets `bindMeshPass` has to reason about.
|
|
17
|
+
*
|
|
18
|
+
* **Every field is independent.** A material with a `normal` and no `albedo` is a legitimate one —
|
|
19
|
+
* vertex colour with authored normals — and shades as such rather than as no material at all.
|
|
20
|
+
*
|
|
21
|
+
* **Generic over the texture, for the reason `SurfaceTextureHandle` exists.** The two backends have
|
|
22
|
+
* different texture classes and the public API speaks in an opaque handle; parameterising here lets
|
|
23
|
+
* each renderer take its own concrete type while a consumer sees one shape. Defaulted to the
|
|
24
|
+
* WebGL2 class so the common spelling stays `SurfaceMaterial`.
|
|
25
|
+
*/
|
|
26
|
+
export interface SurfaceMaterial<Texture = SurfaceTexture> {
|
|
27
|
+
albedo?: Texture | null;
|
|
28
|
+
/**
|
|
29
|
+
* Surface-space directions, turned into world space through the mesh's tangent frame.
|
|
30
|
+
*
|
|
31
|
+
* Read by the flat pass since 2026-08-22, from the attribute at location 10 where the mesh has
|
|
32
|
+
* one and from a per-fragment cotangent frame where it does not. `normalStrength` gates it.
|
|
33
|
+
* See `docs/RENDERING.md` for the normal-map path.
|
|
34
|
+
*/
|
|
35
|
+
normal?: Texture | null;
|
|
36
|
+
/**
|
|
37
|
+
* Occlusion in R, roughness in G, metallic in B, in one image.
|
|
38
|
+
*
|
|
39
|
+
* glTF's packing, because that is what an import carries, and one unit for three channels rather
|
|
40
|
+
* than three units for three maps. Sampled linear and never sRGB: these numbers *are* the data.
|
|
41
|
+
*/
|
|
42
|
+
orm?: Texture | null;
|
|
43
|
+
/**
|
|
44
|
+
* Where a surface glows, and in what colour.
|
|
45
|
+
*
|
|
46
|
+
* **It modulates the surface's own emission rather than creating it**, which is glTF's rule
|
|
47
|
+
* — emitted colour is `emissiveFactor * emissiveTexture` — and is the one thing about this map
|
|
48
|
+
* that surprises people. A mesh whose `emissive` attribute is 0 emits nothing however bright
|
|
49
|
+
* the image it binds, because there is nothing for the image to scale. An import carries the
|
|
50
|
+
* factor for you: `gltf.ts` puts `max(emissiveFactor)` in the attribute and the factor itself
|
|
51
|
+
* in `emissiveColor`. A procedurally built mesh has to say so the same way it says its colour,
|
|
52
|
+
* which is in vertex data, because that is what makes a whole world one draw call here.
|
|
53
|
+
*
|
|
54
|
+
* Sampled **sRGB**, unlike `normal` and `orm`: this one is a colour a person picked, where
|
|
55
|
+
* those two are numbers. glTF says the same.
|
|
56
|
+
*/
|
|
57
|
+
emissive?: Texture | null;
|
|
58
|
+
/** Repeats across the mesh's own UV range, per axis. Applies to every map the material holds. */
|
|
59
|
+
uScale?: number;
|
|
60
|
+
vScale?: number;
|
|
61
|
+
/** Alpha below which a fragment is discarded. See `uAlbedoCutout`. */
|
|
62
|
+
cutout?: number;
|
|
63
|
+
/**
|
|
64
|
+
* How hard the normal map turns the shading normal.
|
|
65
|
+
*
|
|
66
|
+
* **Defaults to 1 when a `normal` is supplied and 0 when it is not**, because binding a map and
|
|
67
|
+
* saying nothing about strength means "use it" rather than "use it at nothing".
|
|
68
|
+
*/
|
|
69
|
+
normalStrength?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Scales the ORM map's G channel. glTF's `roughnessFactor`. Default 1.
|
|
72
|
+
*
|
|
73
|
+
* The map *replaces* the mesh's own roughness attribute rather than scaling it, and this is what
|
|
74
|
+
* gives back the scaling. Scaling the attribute was the alternative and it is wrong outside an
|
|
75
|
+
* import: `vertexDefaults.ts` hands an absent roughness **0.4277**, not 1, so every procedurally
|
|
76
|
+
* built mesh would read far glossier than the image it was handed, with nothing in the API to
|
|
77
|
+
* say it would.
|
|
78
|
+
*/
|
|
79
|
+
roughnessScale?: number;
|
|
80
|
+
/** Scales the ORM map's B channel. glTF's `metallicFactor`. Default 1. */
|
|
81
|
+
metallicScale?: number;
|
|
82
|
+
/**
|
|
83
|
+
* How much of the ORM map's R channel to apply. glTF's `occlusionTexture.strength`. Default 1.
|
|
84
|
+
*
|
|
85
|
+
* **0 is no occlusion, not full occlusion.** glTF defines it as `1 + strength * (texel - 1)`, so
|
|
86
|
+
* the shader mixes from 1 rather than multiplying — a multiply at 0 would black the surface out,
|
|
87
|
+
* which is the opposite of what the caller asked for.
|
|
88
|
+
*/
|
|
89
|
+
occlusionStrength?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Scales the emissive map, per channel. Default 1.
|
|
92
|
+
*
|
|
93
|
+
* The counterpart of `roughnessScale` and `metallicScale`: a factor that multiplies a texture is
|
|
94
|
+
* not a value, and this is where the multiplier lives once an image supplies the shape. A
|
|
95
|
+
* consumer who wants a bound map twice as bright asks here rather than rebuilding the mesh.
|
|
96
|
+
*/
|
|
97
|
+
emissiveScale?: readonly [number, number, number];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface SurfaceTextureOptions {
|
|
101
|
+
/**
|
|
102
|
+
* `repeat` tiles the image, `clamp` stretches its edge texels.
|
|
103
|
+
*
|
|
104
|
+
* Repeat is the default because the case this exists for is a wall: one small image
|
|
105
|
+
* covering a large surface, with `uvScale` deciding how often it lands. Clamp is for
|
|
106
|
+
* an image that is a *picture* — a portrait, a sign — where a second copy of it
|
|
107
|
+
* appearing past the edge is a bug rather than a pattern.
|
|
108
|
+
*/
|
|
109
|
+
wrap?: 'repeat' | 'clamp';
|
|
110
|
+
/**
|
|
111
|
+
* How the image's values are encoded, so the shader can sample light rather than pixels.
|
|
112
|
+
*
|
|
113
|
+
* `linear` is the default and the old behaviour: the bytes are handed to the shader as
|
|
114
|
+
* they are. That is right for a mask, a height field, anything whose numbers *are* the
|
|
115
|
+
* data.
|
|
116
|
+
*
|
|
117
|
+
* `srgb` is right for anything that was authored to be looked at — a photo, a painted
|
|
118
|
+
* canvas, a biome tile. Those bytes are display values, and shading maths is linear, so
|
|
119
|
+
* multiplying a light into them without decoding first is a category error: mid-greys
|
|
120
|
+
* come out roughly twice as bright as they should, and the mistake is invisible until an
|
|
121
|
+
* output transform is applied and everything blows out at once. The GPU decodes
|
|
122
|
+
* `SRGB8_ALPHA8` in the sampler, so this costs nothing per fetch and, unlike decoding in
|
|
123
|
+
* the shader, it happens *before* filtering — which is the only place it is correct.
|
|
124
|
+
*/
|
|
125
|
+
colorSpace?: 'linear' | 'srgb';
|
|
126
|
+
/**
|
|
127
|
+
* How a texel is chosen when the image is magnified: smoothed between texels, or taken whole.
|
|
128
|
+
*
|
|
129
|
+
* **`linear` is the default and is every surface that shipped before this**, which is right for
|
|
130
|
+
* anything photographic: a wall, a painted canvas, a biome tile, where the texel grid is an
|
|
131
|
+
* artefact of resolution rather than the subject.
|
|
132
|
+
*
|
|
133
|
+
* `nearest` is for an image whose *pixels are the subject* — pixel art, an icon atlas, a
|
|
134
|
+
* hand-authored tile. **Reported by a consumer whose block atlas is exactly that**: linear
|
|
135
|
+
* magnification turns an authored tile into a smear as the camera approaches, and there was no
|
|
136
|
+
* way to ask for anything else. They composed their atlas with `imageSmoothingEnabled = false`
|
|
137
|
+
* and kept tiles at twice the resolution they wanted, and neither touches magnification — the
|
|
138
|
+
* smoothing happens in the sampler, after everything a caller controls.
|
|
139
|
+
*
|
|
140
|
+
* **Minification still blends between mip levels**, and that is not the option being ignored. A
|
|
141
|
+
* tiled floor at a grazing angle minifies far past one texel per pixel, which is what mips exist
|
|
142
|
+
* for; taking the nearest *level* as well would trade a smear for a visible pop as the camera
|
|
143
|
+
* pulls back. So the choice applies where it was asked about, and within a level either way.
|
|
144
|
+
*
|
|
145
|
+
* `@driftengine/ui2d` takes the same option and defaults it the other way, because a sprite sheet
|
|
146
|
+
* is usually pixel art and a world surface usually is not.
|
|
147
|
+
*/
|
|
148
|
+
filter?: 'linear' | 'nearest';
|
|
149
|
+
/**
|
|
150
|
+
* Build a mip chain. On by default, and it is not a quality preference.
|
|
151
|
+
*
|
|
152
|
+
* A tiled surface seen at a grazing angle — which is every floor and every corridor
|
|
153
|
+
* wall — minifies far past one texel per pixel, and without mips that undersampling
|
|
154
|
+
* is aliasing that *crawls* as the camera moves. It is the single most visible
|
|
155
|
+
* artefact a textured world can have. Off is for a texture drawn at roughly its own
|
|
156
|
+
* size, where the chain is memory spent on levels nothing will sample.
|
|
157
|
+
*/
|
|
158
|
+
mipmap?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Anisotropic samples, when the extension is present. 1 disables it.
|
|
161
|
+
*
|
|
162
|
+
* Mips fix the crawling and cost sharpness: a floor stretching to the horizon picks
|
|
163
|
+
* its mip from the *worse* of the two axes, so it blurs along the one that was still
|
|
164
|
+
* well sampled. Anisotropy is the standard repair, it is cheap at these sizes, and
|
|
165
|
+
* on a machine without the extension the clamp below silently leaves it at 1.
|
|
166
|
+
*/
|
|
167
|
+
anisotropy?: number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const DEFAULT_ANISOTROPY = 4;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* An image uploaded once and bound per draw.
|
|
174
|
+
*
|
|
175
|
+
* The engine ships no image assets and fetches nothing — that payload rule is intact
|
|
176
|
+
* and this does not weaken it. What it takes is a `TexImageSource` the *consumer*
|
|
177
|
+
* already has: a canvas it generated procedurally at runtime, an `ImageBitmap` it
|
|
178
|
+
* decoded, a video frame. The engine owns the GPU object and the sampler state; where
|
|
179
|
+
* the pixels came from is the caller's business and stays that way.
|
|
180
|
+
*/
|
|
181
|
+
export class SurfaceTexture {
|
|
182
|
+
private texture: WebGLTexture | null;
|
|
183
|
+
private readonly mipmapped: boolean;
|
|
184
|
+
/** Whether the sampler decodes sRGB on fetch. See `colorSpace`. */
|
|
185
|
+
private readonly srgb: boolean;
|
|
186
|
+
|
|
187
|
+
constructor(
|
|
188
|
+
gl: WebGL2RenderingContext,
|
|
189
|
+
source: TexImageSource,
|
|
190
|
+
options: SurfaceTextureOptions = {},
|
|
191
|
+
) {
|
|
192
|
+
const texture = gl.createTexture();
|
|
193
|
+
if (texture === null) throw new Error('SurfaceTexture: createTexture failed');
|
|
194
|
+
this.texture = texture;
|
|
195
|
+
this.mipmapped = options.mipmap ?? true;
|
|
196
|
+
this.srgb = (options.colorSpace ?? 'linear') === 'srgb';
|
|
197
|
+
|
|
198
|
+
const wrap = (options.wrap ?? 'repeat') === 'repeat' ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
|
199
|
+
|
|
200
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
201
|
+
/*
|
|
202
|
+
* **Not flipped, and this used to be, which is the bug it is written down for.**
|
|
203
|
+
*
|
|
204
|
+
* The flip was here with a comment saying every source is a 2D drawing surface whose Y
|
|
205
|
+
* runs down from the top-left, so without it "every texture arrives mirrored". That is
|
|
206
|
+
* true of a canvas and **WebGL ignores `UNPACK_FLIP_Y_WEBGL` entirely for an
|
|
207
|
+
* `ImageBitmap`**, which carries its own orientation. So the two source types the same
|
|
208
|
+
* method accepts arrived the opposite way up from each other, and nothing caught it
|
|
209
|
+
* because every canvas-sourced texture in this repository was symmetric under a vertical
|
|
210
|
+
* flip: eroded noise, a radial halo, a sleeve blurred to 24 pixels and back. One consumer
|
|
211
|
+
* painted lettering to a canvas beside a sleeve decoded as a bitmap and the text was
|
|
212
|
+
* upside down.
|
|
213
|
+
*
|
|
214
|
+
* **Made to agree by dropping the flip rather than by extending it**, and the direction
|
|
215
|
+
* is a deliberate choice about blast radius rather than a coin toss: `drftLoader` builds
|
|
216
|
+
* every model texture from an `ImageBitmap`, so flipping bitmaps to match canvases would
|
|
217
|
+
* turn over every painted surface on every loaded model. Dropping it changes only
|
|
218
|
+
* canvas-sourced textures, and every one of those that exists today is symmetric.
|
|
219
|
+
*
|
|
220
|
+
* A caller that was mirroring its own canvas to cancel this must stop.
|
|
221
|
+
*/
|
|
222
|
+
gl.texImage2D(
|
|
223
|
+
gl.TEXTURE_2D,
|
|
224
|
+
0,
|
|
225
|
+
this.srgb ? gl.SRGB8_ALPHA8 : gl.RGBA,
|
|
226
|
+
gl.RGBA,
|
|
227
|
+
gl.UNSIGNED_BYTE,
|
|
228
|
+
source,
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);
|
|
232
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);
|
|
233
|
+
/* Nearest where the caller said their pixels are the subject; see `filter`. The mip chain is
|
|
234
|
+
still blended between levels, because that is minification and this option is about
|
|
235
|
+
magnification. */
|
|
236
|
+
const nearest = options.filter === 'nearest';
|
|
237
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, nearest ? gl.NEAREST : gl.LINEAR);
|
|
238
|
+
gl.texParameteri(
|
|
239
|
+
gl.TEXTURE_2D,
|
|
240
|
+
gl.TEXTURE_MIN_FILTER,
|
|
241
|
+
this.mipmapped
|
|
242
|
+
? nearest
|
|
243
|
+
? gl.NEAREST_MIPMAP_LINEAR
|
|
244
|
+
: gl.LINEAR_MIPMAP_LINEAR
|
|
245
|
+
: nearest
|
|
246
|
+
? gl.NEAREST
|
|
247
|
+
: gl.LINEAR,
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
if (this.mipmapped) gl.generateMipmap(gl.TEXTURE_2D);
|
|
251
|
+
applyAnisotropy(gl, options.anisotropy ?? DEFAULT_ANISOTROPY);
|
|
252
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Replace the pixels, keeping the GPU object and its sampler state.
|
|
257
|
+
*
|
|
258
|
+
* For a source that changes — a canvas being redrawn, a decoded frame. Re-uploading
|
|
259
|
+
* beats constructing a second texture because the binding the caller already handed
|
|
260
|
+
* to a draw stays valid, and because a texture created per frame is a leak in every
|
|
261
|
+
* case where the caller forgets the matching dispose.
|
|
262
|
+
*
|
|
263
|
+
* Not a hot path: it re-uploads the whole image and regenerates the chain. A caller
|
|
264
|
+
* doing this every frame at any size wants to know that it costs what it costs.
|
|
265
|
+
*/
|
|
266
|
+
update(gl: WebGL2RenderingContext, source: TexImageSource): void {
|
|
267
|
+
if (this.texture === null) return;
|
|
268
|
+
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
269
|
+
/* Unflipped, matching the constructor. See it for why, and for what it cost. */
|
|
270
|
+
gl.texImage2D(
|
|
271
|
+
gl.TEXTURE_2D,
|
|
272
|
+
0,
|
|
273
|
+
this.srgb ? gl.SRGB8_ALPHA8 : gl.RGBA,
|
|
274
|
+
gl.RGBA,
|
|
275
|
+
gl.UNSIGNED_BYTE,
|
|
276
|
+
source,
|
|
277
|
+
);
|
|
278
|
+
if (this.mipmapped) gl.generateMipmap(gl.TEXTURE_2D);
|
|
279
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Bind to a unit for sampling. Engine-internal: the renderer owns unit assignment. */
|
|
283
|
+
bind(gl: WebGL2RenderingContext, unit: number): void {
|
|
284
|
+
gl.activeTexture(gl.TEXTURE0 + unit);
|
|
285
|
+
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
dispose(gl: WebGL2RenderingContext): void {
|
|
289
|
+
if (this.texture === null) return;
|
|
290
|
+
gl.deleteTexture(this.texture);
|
|
291
|
+
this.texture = null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Set anisotropic filtering when the driver offers it, and stay silent when it does not.
|
|
297
|
+
*
|
|
298
|
+
* Silent because the extension is an enhancement with an exact fallback — the same
|
|
299
|
+
* texture, filtered isotropically — so a machine without it renders a slightly softer
|
|
300
|
+
* floor rather than a broken one. Nothing here should fail init over that.
|
|
301
|
+
*/
|
|
302
|
+
function applyAnisotropy(gl: WebGL2RenderingContext, requested: number): void {
|
|
303
|
+
if (requested <= 1) return;
|
|
304
|
+
const ext =
|
|
305
|
+
gl.getExtension('EXT_texture_filter_anisotropic') ??
|
|
306
|
+
gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic');
|
|
307
|
+
if (ext === null) return;
|
|
308
|
+
const max = gl.getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT) as number;
|
|
309
|
+
gl.texParameterf(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(requested, max));
|
|
310
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { mat4 } from 'gl-matrix';
|
|
2
|
+
import type { ReadonlyMat4 } from 'gl-matrix';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The sub-pixel sequence a temporal resolve samples along, and the state that says whether there
|
|
6
|
+
* is anything to resolve *against* yet.
|
|
7
|
+
*
|
|
8
|
+
* **Antialiasing by moving the camera rather than by taking more samples.** A frame is rasterised
|
|
9
|
+
* with the projection shifted a fraction of a pixel, so an edge that fell one side of a pixel
|
|
10
|
+
* centre falls the other side next frame, and blending the two puts the edge where it actually
|
|
11
|
+
* is. What MSAA buys per frame this buys across frames, at one extra texture and one extra pass
|
|
12
|
+
* instead of a multiplied fill rate — which is the trade a browser target wants.
|
|
13
|
+
*
|
|
14
|
+
* **This file holds only the parts that are arithmetic**, so they can be asserted without a
|
|
15
|
+
* device: where the next sample sits, what that does to a projection matrix, and whether the
|
|
16
|
+
* history is usable this frame. The resolve itself is a shader and belongs to each backend.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* How many frames the sequence takes to come back round.
|
|
21
|
+
*
|
|
22
|
+
* Eight rather than sixteen: the accumulation converges in eight frames instead of sixteen, and
|
|
23
|
+
* every frame of history is a frame of ghosting a moving object has to be clipped out of. The
|
|
24
|
+
* sequence is the deciding factor rather than the count — eight *distinct* low-discrepancy
|
|
25
|
+
* positions beat sixteen that clump.
|
|
26
|
+
*/
|
|
27
|
+
export const JITTER_PERIOD = 8;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* How much of the clipped history each resolved frame keeps.
|
|
31
|
+
*
|
|
32
|
+
* Nine parts history to one part this frame, which gives the accumulation an effective window of
|
|
33
|
+
* about ten frames — a little longer than the eight-frame period, so every offset in the sequence
|
|
34
|
+
* still contributes to what is on screen. Higher holds a ghost for longer wherever the
|
|
35
|
+
* neighbourhood clip does not catch it; lower stops converging before the period is out and leaves
|
|
36
|
+
* the crawl this exists to remove.
|
|
37
|
+
*/
|
|
38
|
+
export const TEMPORAL_HISTORY_BLEND = 0.9;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The radical inverse of `index` in `base`, which is what makes a Halton sequence fill a gap
|
|
42
|
+
* before it fills a corner.
|
|
43
|
+
*
|
|
44
|
+
* Consecutive samples land as far from each other as the base allows, so eight of them cover the
|
|
45
|
+
* pixel evenly where eight random ones would leave holes and pairs.
|
|
46
|
+
*/
|
|
47
|
+
function halton(index: number, base: number): number {
|
|
48
|
+
let result = 0;
|
|
49
|
+
let fraction = 1;
|
|
50
|
+
let i = index;
|
|
51
|
+
while (i > 0) {
|
|
52
|
+
fraction /= base;
|
|
53
|
+
result += fraction * (i % base);
|
|
54
|
+
i = Math.floor(i / base);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The period's offsets, centred so they sum to zero.
|
|
61
|
+
*
|
|
62
|
+
* **Halton's own mean is not the middle of the pixel** — over eight samples base two averages
|
|
63
|
+
* 0.445 rather than 0.5 — and accumulating towards a mean that is off centre resolves to a picture
|
|
64
|
+
* displaced from the depth buffer it was tested against and from every pass that did not jitter.
|
|
65
|
+
* Subtracting the period's own mean costs nothing and makes the property exact rather than
|
|
66
|
+
* approximate, which is what lets the test assert it.
|
|
67
|
+
*/
|
|
68
|
+
const OFFSETS: readonly (readonly [number, number])[] = (() => {
|
|
69
|
+
const raw: [number, number][] = [];
|
|
70
|
+
for (let i = 1; i <= JITTER_PERIOD; i++) raw.push([halton(i, 2), halton(i, 3)]);
|
|
71
|
+
const meanX = raw.reduce((sum, o) => sum + o[0], 0) / JITTER_PERIOD;
|
|
72
|
+
const meanY = raw.reduce((sum, o) => sum + o[1], 0) / JITTER_PERIOD;
|
|
73
|
+
return raw.map(([x, y]) => [x - meanX, y - meanY] as const);
|
|
74
|
+
})();
|
|
75
|
+
|
|
76
|
+
/** Where in its pixel frame `frameIndex` samples, in pixels, centred on zero. */
|
|
77
|
+
export function jitterOffset(frameIndex: number): readonly [number, number] {
|
|
78
|
+
const at = ((frameIndex % JITTER_PERIOD) + JITTER_PERIOD) % JITTER_PERIOD;
|
|
79
|
+
return OFFSETS[at] as readonly [number, number];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* `source` shifted by `offsetX`, `offsetY` pixels on a `width` by `height` target.
|
|
84
|
+
*
|
|
85
|
+
* **A clip-space translation scaled by w, and not an edit to the projection's third column.** The
|
|
86
|
+
* usual trick adds the offset to the third column, where it is multiplied by view z and the
|
|
87
|
+
* perspective divide then cancels it — which is exact, and only for a bare perspective projection.
|
|
88
|
+
* This engine's single funnel for geometry is `viewProjFor`, which carries a *combined*
|
|
89
|
+
* view-projection: there the third column multiplies world z instead of view z, and the jitter
|
|
90
|
+
* would swim with the scene's own depth. An orthographic matrix breaks it too, its w being 1.
|
|
91
|
+
*
|
|
92
|
+
* Adding `offset * w` to clip x and y is what those two cases have in common. It survives the
|
|
93
|
+
* divide as a constant screen offset at every distance, whatever produced the clip position, so
|
|
94
|
+
* this may be handed a projection or a view-projection and is correct for both — which is the
|
|
95
|
+
* property the near-and-far test beside this pins.
|
|
96
|
+
*
|
|
97
|
+
* **A zero offset returns the matrix unchanged, bit for bit.** Every published capture is taken
|
|
98
|
+
* with this off, and a jitter of zero that still ran the arithmetic would move pixels by whatever
|
|
99
|
+
* it rounded to.
|
|
100
|
+
*/
|
|
101
|
+
export function jitterProjection(
|
|
102
|
+
out: mat4,
|
|
103
|
+
source: ReadonlyMat4,
|
|
104
|
+
offsetX: number,
|
|
105
|
+
offsetY: number,
|
|
106
|
+
width: number,
|
|
107
|
+
height: number,
|
|
108
|
+
): mat4 {
|
|
109
|
+
mat4.copy(out, source);
|
|
110
|
+
if (offsetX === 0 && offsetY === 0) return out;
|
|
111
|
+
const ndcX = (2 * offsetX) / width;
|
|
112
|
+
const ndcY = (2 * offsetY) / height;
|
|
113
|
+
/* Row 0 gains `ndcX` times row 3, and row 1 `ndcY` times it, which is `T * source` for a T
|
|
114
|
+
translating in clip space — done in place because that product touches nothing else. */
|
|
115
|
+
for (let column = 0; column < 4; column++) {
|
|
116
|
+
const w = source[column * 4 + 3];
|
|
117
|
+
out[column * 4 + 0] += ndcX * w;
|
|
118
|
+
out[column * 4 + 1] += ndcY * w;
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** A colour the resolve is working on, as three numbers rather than a texture fetch. */
|
|
124
|
+
export type Rgb = [number, number, number];
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* `history` pulled into the box `min`..`max`, along the line towards the box's centre.
|
|
128
|
+
*
|
|
129
|
+
* **This is what separates a temporal resolve from a long exposure.** Reprojection finds where a
|
|
130
|
+
* pixel *was*; nothing in it knows whether what was there is what is there now. A character
|
|
131
|
+
* walking in front of a wall reprojects onto wall, and blending nine parts of that history is a
|
|
132
|
+
* smear that follows them about. The colours actually present around the pixel this frame bound
|
|
133
|
+
* what the history is allowed to be, and anything outside those bounds is a sample of something
|
|
134
|
+
* that has gone.
|
|
135
|
+
*
|
|
136
|
+
* **Clipped towards the centre rather than clamped per channel.** A clamp moves each channel
|
|
137
|
+
* independently, so a history that is merely brighter than its surroundings lands on a corner of
|
|
138
|
+
* the box and comes back a different hue, which reads as coloured fringing along every moving
|
|
139
|
+
* edge. Shortening the whole offset by one ratio keeps the direction and changes only the length.
|
|
140
|
+
*
|
|
141
|
+
* The same arithmetic is in `TEMPORAL_RESOLVE_FRAG`, and the shader test asserts the shader still
|
|
142
|
+
* spells it this way.
|
|
143
|
+
*/
|
|
144
|
+
export function clipToNeighbourhood(
|
|
145
|
+
out: Rgb,
|
|
146
|
+
history: readonly [number, number, number],
|
|
147
|
+
min: readonly [number, number, number],
|
|
148
|
+
max: readonly [number, number, number],
|
|
149
|
+
): Rgb {
|
|
150
|
+
const centre: Rgb = [0, 0, 0];
|
|
151
|
+
const offset: Rgb = [0, 0, 0];
|
|
152
|
+
let ratio = 0;
|
|
153
|
+
|
|
154
|
+
for (let c = 0; c < 3; c++) {
|
|
155
|
+
centre[c] = (min[c] + max[c]) * 0.5;
|
|
156
|
+
offset[c] = history[c] - centre[c];
|
|
157
|
+
const extent = (max[c] - min[c]) * 0.5;
|
|
158
|
+
/*
|
|
159
|
+
* A channel with no extent cannot bound anything, so a history that differs from it at all is
|
|
160
|
+
* infinitely outside and collapses to the neighbourhood — which is the honest answer for a
|
|
161
|
+
* flat region, and the alternative is a division by zero.
|
|
162
|
+
*/
|
|
163
|
+
if (extent > 1e-7) ratio = Math.max(ratio, Math.abs(offset[c]) / extent);
|
|
164
|
+
else if (Math.abs(offset[c]) > 1e-7) ratio = Number.POSITIVE_INFINITY;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!(ratio > 1)) {
|
|
168
|
+
out[0] = history[0];
|
|
169
|
+
out[1] = history[1];
|
|
170
|
+
out[2] = history[2];
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const scale = Number.isFinite(ratio) ? 1 / ratio : 0;
|
|
175
|
+
out[0] = centre[0] + offset[0] * scale;
|
|
176
|
+
out[1] = centre[1] + offset[1] * scale;
|
|
177
|
+
out[2] = centre[2] + offset[2] * scale;
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Whether the last frame left a picture this one may sample, and where the jitter has got to.
|
|
183
|
+
*
|
|
184
|
+
* **Two calls a frame, and the split is the point.** `openFrame` answers a question about the
|
|
185
|
+
* state *before* this frame writes anything, and the resolve needs that answer before it writes;
|
|
186
|
+
* `accumulated` reports that a picture now exists. One call cannot do both.
|
|
187
|
+
*/
|
|
188
|
+
export class TemporalHistory {
|
|
189
|
+
/** How many frames have been opened, which is what indexes the jitter. */
|
|
190
|
+
frameIndex = 0;
|
|
191
|
+
|
|
192
|
+
private picture = false;
|
|
193
|
+
private width = 0;
|
|
194
|
+
private height = 0;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Open a frame at this target size, and answer whether the history may be sampled.
|
|
198
|
+
*
|
|
199
|
+
* **The jitter advances whether or not it may be.** Holding the sequence still on the frames a
|
|
200
|
+
* resize or a cut discarded would sample the same position twice running, which is one sample
|
|
201
|
+
* and not two.
|
|
202
|
+
*/
|
|
203
|
+
openFrame(width: number, height: number): boolean {
|
|
204
|
+
this.frameIndex++;
|
|
205
|
+
const usable = this.picture && width === this.width && height === this.height;
|
|
206
|
+
if (!usable) this.picture = false;
|
|
207
|
+
this.width = width;
|
|
208
|
+
this.height = height;
|
|
209
|
+
return usable;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** A resolved picture is now in the history, at the size the frame was opened with. */
|
|
213
|
+
accumulated(): void {
|
|
214
|
+
this.picture = true;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Forget it — a cut, a teleport, or anything else that makes the last frame a different scene. */
|
|
218
|
+
invalidate(): void {
|
|
219
|
+
this.picture = false;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { compileProgram, uniformLocations } from './shader.ts';
|
|
2
|
+
import { FULLSCREEN_VERT } from './shaders/fullscreen.ts';
|
|
3
|
+
import { TEMPORAL_RESOLVE_FRAG } from './shaders/temporalResolve.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The temporal resolve on WebGL2: this frame blended into where the last one was.
|
|
7
|
+
*
|
|
8
|
+
* **Two targets and a swap, because a pass cannot read the texture it is writing.** The history is
|
|
9
|
+
* sampled at a reprojected coordinate, which is somewhere else in the same image, so reading and
|
|
10
|
+
* writing one texture is a feedback loop — undefined in WebGL2 and in practice whatever the driver
|
|
11
|
+
* left in the cache. So the resolve writes into the one it did not read and the pair swaps, which
|
|
12
|
+
* costs one more full-size texture and nothing per pixel.
|
|
13
|
+
*
|
|
14
|
+
* **What it returns is what the composite must then treat as the scene.** Bloom, occlusion and the
|
|
15
|
+
* grade all read the scene texture, and reading the unresolved one would grade a stable picture
|
|
16
|
+
* from an unstable source and put the crawl back on screen through the bloom.
|
|
17
|
+
*/
|
|
18
|
+
export class TemporalPass {
|
|
19
|
+
private readonly program: WebGLProgram;
|
|
20
|
+
private readonly uniforms: Record<string, WebGLUniformLocation | null>;
|
|
21
|
+
private readonly vao: WebGLVertexArrayObject;
|
|
22
|
+
|
|
23
|
+
/** The pair, and which of them the next resolve writes into. */
|
|
24
|
+
private textures: (WebGLTexture | null)[] = [null, null];
|
|
25
|
+
private framebuffers: (WebGLFramebuffer | null)[] = [null, null];
|
|
26
|
+
private write = 0;
|
|
27
|
+
|
|
28
|
+
private width = 0;
|
|
29
|
+
private height = 0;
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
private readonly gl: WebGL2RenderingContext,
|
|
33
|
+
/**
|
|
34
|
+
* Matched to the scene target's own format, and it has to be.
|
|
35
|
+
*
|
|
36
|
+
* A half-float scene resolved into an eight-bit history is squashed into 0 to 1 on its way in
|
|
37
|
+
* and read back squashed, so the accumulation would pull every value above white *down* over
|
|
38
|
+
* eight frames — a bloom threshold that stopped meaning brightness, and a sunset that faded
|
|
39
|
+
* while the camera held still.
|
|
40
|
+
*/
|
|
41
|
+
private readonly floatColor: boolean,
|
|
42
|
+
) {
|
|
43
|
+
this.program = compileProgram(gl, FULLSCREEN_VERT, TEMPORAL_RESOLVE_FRAG, 'temporalResolve');
|
|
44
|
+
this.uniforms = uniformLocations(gl, this.program, 'temporalPass');
|
|
45
|
+
const vao = gl.createVertexArray();
|
|
46
|
+
if (vao === null) throw new Error('TemporalPass: createVertexArray failed');
|
|
47
|
+
this.vao = vao;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private ensureSize(width: number, height: number): void {
|
|
51
|
+
if (this.width === width && this.height === height && this.textures[0] !== null) return;
|
|
52
|
+
const { gl } = this;
|
|
53
|
+
this.width = width;
|
|
54
|
+
this.height = height;
|
|
55
|
+
|
|
56
|
+
for (let i = 0; i < 2; i++) {
|
|
57
|
+
if (this.textures[i] === null) this.textures[i] = gl.createTexture();
|
|
58
|
+
gl.bindTexture(gl.TEXTURE_2D, this.textures[i]);
|
|
59
|
+
if (this.floatColor) {
|
|
60
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA16F, width, height, 0, gl.RGBA, gl.HALF_FLOAT, null);
|
|
61
|
+
} else {
|
|
62
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
63
|
+
}
|
|
64
|
+
/* Linear, because the history is sampled between texels wherever the reprojection lands;
|
|
65
|
+
clamped, because a sample that wrapped would pull the far edge of the screen into the
|
|
66
|
+
corner — and the shader rejects an off-screen reprojection before it can anyway. */
|
|
67
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
68
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
69
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
70
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
71
|
+
|
|
72
|
+
if (this.framebuffers[i] === null) this.framebuffers[i] = gl.createFramebuffer();
|
|
73
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffers[i]);
|
|
74
|
+
gl.framebufferTexture2D(
|
|
75
|
+
gl.FRAMEBUFFER,
|
|
76
|
+
gl.COLOR_ATTACHMENT0,
|
|
77
|
+
gl.TEXTURE_2D,
|
|
78
|
+
this.textures[i],
|
|
79
|
+
0,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Resolve `scene` against the history and return the texture now holding the resolved frame.
|
|
87
|
+
*
|
|
88
|
+
* `blend` is how much of the clipped history to keep, and **zero is the whole switch**: the
|
|
89
|
+
* first frame, the frame after a resize and the frame after a cut pass zero, and the shader
|
|
90
|
+
* then returns this frame before it touches depth or history at all.
|
|
91
|
+
*/
|
|
92
|
+
temporalResolve(
|
|
93
|
+
scene: WebGLTexture,
|
|
94
|
+
depth: WebGLTexture,
|
|
95
|
+
reprojection: Float32Array,
|
|
96
|
+
width: number,
|
|
97
|
+
height: number,
|
|
98
|
+
blend: number,
|
|
99
|
+
): WebGLTexture {
|
|
100
|
+
const { gl } = this;
|
|
101
|
+
this.ensureSize(width, height);
|
|
102
|
+
|
|
103
|
+
const target = this.write;
|
|
104
|
+
const history = 1 - this.write;
|
|
105
|
+
|
|
106
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffers[target]);
|
|
107
|
+
gl.viewport(0, 0, width, height);
|
|
108
|
+
gl.disable(gl.DEPTH_TEST);
|
|
109
|
+
gl.disable(gl.BLEND);
|
|
110
|
+
gl.disable(gl.CULL_FACE);
|
|
111
|
+
gl.depthMask(false);
|
|
112
|
+
|
|
113
|
+
gl.useProgram(this.program);
|
|
114
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
115
|
+
gl.bindTexture(gl.TEXTURE_2D, scene);
|
|
116
|
+
gl.uniform1i(this.uniforms['uScene'] ?? null, 0);
|
|
117
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
118
|
+
gl.bindTexture(gl.TEXTURE_2D, this.textures[history]);
|
|
119
|
+
gl.uniform1i(this.uniforms['uHistory'] ?? null, 1);
|
|
120
|
+
gl.activeTexture(gl.TEXTURE2);
|
|
121
|
+
gl.bindTexture(gl.TEXTURE_2D, depth);
|
|
122
|
+
gl.uniform1i(this.uniforms['uDepth'] ?? null, 2);
|
|
123
|
+
|
|
124
|
+
gl.uniformMatrix4fv(this.uniforms['uReprojection'] ?? null, false, reprojection);
|
|
125
|
+
gl.uniform2f(this.uniforms['uTexel'] ?? null, 1 / width, 1 / height);
|
|
126
|
+
gl.uniform1f(this.uniforms['uHistoryBlend'] ?? null, blend);
|
|
127
|
+
|
|
128
|
+
gl.bindVertexArray(this.vao);
|
|
129
|
+
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
|
130
|
+
gl.bindVertexArray(null);
|
|
131
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
132
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
133
|
+
|
|
134
|
+
this.write = history;
|
|
135
|
+
const resolved = this.textures[target];
|
|
136
|
+
if (resolved === null) throw new Error('TemporalPass: resolve target missing');
|
|
137
|
+
return resolved;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
dispose(): void {
|
|
141
|
+
const { gl } = this;
|
|
142
|
+
for (let i = 0; i < 2; i++) {
|
|
143
|
+
if (this.textures[i] !== null) gl.deleteTexture(this.textures[i]);
|
|
144
|
+
if (this.framebuffers[i] !== null) gl.deleteFramebuffer(this.framebuffers[i]);
|
|
145
|
+
this.textures[i] = null;
|
|
146
|
+
this.framebuffers[i] = null;
|
|
147
|
+
}
|
|
148
|
+
gl.deleteProgram(this.program);
|
|
149
|
+
gl.deleteVertexArray(this.vao);
|
|
150
|
+
this.width = 0;
|
|
151
|
+
this.height = 0;
|
|
152
|
+
}
|
|
153
|
+
}
|