@thunderclap-engine/engine 0.0.0-stage → 1.1.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/CHANGELOG.md +390 -0
- package/LICENSE +21 -0
- package/README.md +333 -2
- package/dist/analytics/analytics.d.ts +80 -0
- package/dist/analytics/analytics.js +129 -0
- package/dist/analytics/index.d.ts +1 -0
- package/dist/analytics/index.js +1 -0
- package/dist/anim/aim.d.ts +43 -0
- package/dist/anim/aim.js +157 -0
- package/dist/anim/clip.d.ts +98 -0
- package/dist/anim/clip.js +282 -0
- package/dist/anim/compress.d.ts +65 -0
- package/dist/anim/compress.js +339 -0
- package/dist/anim/foot-ik.d.ts +74 -0
- package/dist/anim/foot-ik.js +241 -0
- package/dist/anim/graph.d.ts +153 -0
- package/dist/anim/graph.js +532 -0
- package/dist/anim/ik.d.ts +105 -0
- package/dist/anim/ik.js +435 -0
- package/dist/anim/index.d.ts +36 -0
- package/dist/anim/index.js +21 -0
- package/dist/anim/match.d.ts +66 -0
- package/dist/anim/match.js +153 -0
- package/dist/anim/mixer.d.ts +113 -0
- package/dist/anim/mixer.js +314 -0
- package/dist/anim/morph.d.ts +41 -0
- package/dist/anim/morph.js +94 -0
- package/dist/anim/pose.d.ts +74 -0
- package/dist/anim/pose.js +254 -0
- package/dist/anim/quat.d.ts +44 -0
- package/dist/anim/quat.js +187 -0
- package/dist/anim/retarget.d.ts +97 -0
- package/dist/anim/retarget.js +366 -0
- package/dist/anim/root-motion.d.ts +44 -0
- package/dist/anim/root-motion.js +224 -0
- package/dist/anim/skin-pose.d.ts +39 -0
- package/dist/anim/skin-pose.js +53 -0
- package/dist/anim/socket.d.ts +47 -0
- package/dist/anim/socket.js +84 -0
- package/dist/anim/spring-chain.d.ts +73 -0
- package/dist/anim/spring-chain.js +294 -0
- package/dist/assets/atlas.d.ts +90 -0
- package/dist/assets/atlas.js +212 -0
- package/dist/assets/baked.d.ts +33 -0
- package/dist/assets/baked.js +38 -0
- package/dist/assets/bundle.d.ts +88 -0
- package/dist/assets/bundle.js +464 -0
- package/dist/assets/cache.d.ts +56 -0
- package/dist/assets/cache.js +123 -0
- package/dist/assets/gltf-load.d.ts +252 -0
- package/dist/assets/gltf-load.js +661 -0
- package/dist/assets/gltf-skin.d.ts +36 -0
- package/dist/assets/gltf-skin.js +109 -0
- package/dist/assets/gltf.d.ts +706 -0
- package/dist/assets/gltf.js +1376 -0
- package/dist/assets/index.d.ts +20 -0
- package/dist/assets/index.js +10 -0
- package/dist/assets/ktx2.d.ts +71 -0
- package/dist/assets/ktx2.js +213 -0
- package/dist/assets/manifest.d.ts +79 -0
- package/dist/assets/manifest.js +7 -0
- package/dist/assets/meshopt.d.ts +23 -0
- package/dist/assets/meshopt.js +403 -0
- package/dist/audio/audio.d.ts +733 -0
- package/dist/audio/audio.js +2013 -0
- package/dist/audio/dsp.d.ts +61 -0
- package/dist/audio/dsp.js +159 -0
- package/dist/audio/duck.d.ts +44 -0
- package/dist/audio/duck.js +101 -0
- package/dist/audio/envelope.d.ts +53 -0
- package/dist/audio/envelope.js +106 -0
- package/dist/audio/index.d.ts +13 -0
- package/dist/audio/index.js +14 -0
- package/dist/audio/music.d.ts +113 -0
- package/dist/audio/music.js +548 -0
- package/dist/audio/occlusion.d.ts +55 -0
- package/dist/audio/occlusion.js +61 -0
- package/dist/audio/persist.d.ts +23 -0
- package/dist/audio/persist.js +27 -0
- package/dist/audio/recipes.d.ts +55 -0
- package/dist/audio/recipes.js +227 -0
- package/dist/audio/send.d.ts +41 -0
- package/dist/audio/send.js +118 -0
- package/dist/audio/sprites.d.ts +59 -0
- package/dist/audio/sprites.js +43 -0
- package/dist/audio/synth.d.ts +103 -0
- package/dist/audio/synth.js +197 -0
- package/dist/audio/variations.d.ts +25 -0
- package/dist/audio/variations.js +55 -0
- package/dist/audio/zones.d.ts +100 -0
- package/dist/audio/zones.js +167 -0
- package/dist/core/detached-surface.d.ts +44 -0
- package/dist/core/detached-surface.js +104 -0
- package/dist/core/events.d.ts +24 -0
- package/dist/core/events.js +43 -0
- package/dist/core/game.d.ts +409 -0
- package/dist/core/game.js +530 -0
- package/dist/core/hash.d.ts +24 -0
- package/dist/core/hash.js +49 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +9 -0
- package/dist/core/loop.d.ts +113 -0
- package/dist/core/loop.js +185 -0
- package/dist/core/math.d.ts +58 -0
- package/dist/core/math.js +210 -0
- package/dist/core/noise.d.ts +40 -0
- package/dist/core/noise.js +247 -0
- package/dist/core/pool.d.ts +42 -0
- package/dist/core/pool.js +85 -0
- package/dist/core/random.d.ts +61 -0
- package/dist/core/random.js +199 -0
- package/dist/core/scene.d.ts +79 -0
- package/dist/core/scene.js +195 -0
- package/dist/core/timer.d.ts +66 -0
- package/dist/core/timer.js +286 -0
- package/dist/fx/billboard-wgsl.d.ts +29 -0
- package/dist/fx/billboard-wgsl.js +158 -0
- package/dist/fx/billboard.d.ts +249 -0
- package/dist/fx/billboard.js +702 -0
- package/dist/fx/debug-draw.d.ts +127 -0
- package/dist/fx/debug-draw.js +523 -0
- package/dist/fx/debug-wgsl.d.ts +7 -0
- package/dist/fx/debug-wgsl.js +32 -0
- package/dist/fx/decals-wgsl.d.ts +15 -0
- package/dist/fx/decals-wgsl.js +173 -0
- package/dist/fx/decals.d.ts +216 -0
- package/dist/fx/decals.js +607 -0
- package/dist/fx/effect.d.ts +129 -0
- package/dist/fx/effect.js +349 -0
- package/dist/fx/effects/hit-spark.json +48 -0
- package/dist/fx/effects/index.d.ts +8 -0
- package/dist/fx/effects/index.js +9 -0
- package/dist/fx/effects/magic-aura.json +47 -0
- package/dist/fx/effects/smoke-puff.json +34 -0
- package/dist/fx/emit-surface.d.ts +40 -0
- package/dist/fx/emit-surface.js +124 -0
- package/dist/fx/flicker.d.ts +30 -0
- package/dist/fx/flicker.js +42 -0
- package/dist/fx/index.d.ts +31 -0
- package/dist/fx/index.js +20 -0
- package/dist/fx/particles-wgsl.d.ts +57 -0
- package/dist/fx/particles-wgsl.js +828 -0
- package/dist/fx/particles.d.ts +566 -0
- package/dist/fx/particles.js +1533 -0
- package/dist/fx/random.d.ts +15 -0
- package/dist/fx/random.js +20 -0
- package/dist/fx/sky-wgsl.d.ts +23 -0
- package/dist/fx/sky-wgsl.js +127 -0
- package/dist/fx/sky.d.ts +96 -0
- package/dist/fx/sky.js +175 -0
- package/dist/fx/text-atlas.d.ts +143 -0
- package/dist/fx/text-atlas.js +327 -0
- package/dist/fx/trail-wgsl.d.ts +11 -0
- package/dist/fx/trail-wgsl.js +42 -0
- package/dist/fx/trail.d.ts +194 -0
- package/dist/fx/trail.js +555 -0
- package/dist/fx/water-wgsl.d.ts +34 -0
- package/dist/fx/water-wgsl.js +197 -0
- package/dist/fx/water.d.ts +176 -0
- package/dist/fx/water.js +371 -0
- package/dist/geom/collide/bvh.d.ts +151 -0
- package/dist/geom/collide/bvh.js +493 -0
- package/dist/geom/collide/debug.d.ts +14 -0
- package/dist/geom/collide/debug.js +74 -0
- package/dist/geom/collide/grid.d.ts +26 -0
- package/dist/geom/collide/grid.js +91 -0
- package/dist/geom/collide/index.d.ts +8 -0
- package/dist/geom/collide/index.js +8 -0
- package/dist/geom/collide/queries.d.ts +70 -0
- package/dist/geom/collide/queries.js +583 -0
- package/dist/geom/collide/serialize.d.ts +14 -0
- package/dist/geom/collide/serialize.js +145 -0
- package/dist/geom/collide/shapes.d.ts +161 -0
- package/dist/geom/collide/shapes.js +686 -0
- package/dist/geom/collide/slide.d.ts +66 -0
- package/dist/geom/collide/slide.js +375 -0
- package/dist/geom/collide/tile-slide.d.ts +88 -0
- package/dist/geom/collide/tile-slide.js +255 -0
- package/dist/geom/geometry.d.ts +95 -0
- package/dist/geom/geometry.js +322 -0
- package/dist/geom/heightfield.d.ts +72 -0
- package/dist/geom/heightfield.js +295 -0
- package/dist/geom/hull.d.ts +27 -0
- package/dist/geom/hull.js +279 -0
- package/dist/geom/index.d.ts +35 -0
- package/dist/geom/index.js +23 -0
- package/dist/geom/iso.d.ts +74 -0
- package/dist/geom/iso.js +89 -0
- package/dist/geom/lod.d.ts +29 -0
- package/dist/geom/lod.js +27 -0
- package/dist/geom/ops.d.ts +47 -0
- package/dist/geom/ops.js +285 -0
- package/dist/geom/primitives.d.ts +97 -0
- package/dist/geom/primitives.js +359 -0
- package/dist/geom/shapes.d.ts +43 -0
- package/dist/geom/shapes.js +88 -0
- package/dist/geom/simplify.d.ts +38 -0
- package/dist/geom/simplify.js +519 -0
- package/dist/geom/split.d.ts +37 -0
- package/dist/geom/split.js +413 -0
- package/dist/geom/sweep.d.ts +83 -0
- package/dist/geom/sweep.js +534 -0
- package/dist/geom/tangents.d.ts +16 -0
- package/dist/geom/tangents.js +124 -0
- package/dist/geom/triangulate.d.ts +19 -0
- package/dist/geom/triangulate.js +147 -0
- package/dist/host/default.d.ts +10 -0
- package/dist/host/default.js +10 -0
- package/dist/host/index.d.ts +4 -0
- package/dist/host/index.js +3 -0
- package/dist/host/types.d.ts +144 -0
- package/dist/host/types.js +1 -0
- package/dist/host/web-links.d.ts +38 -0
- package/dist/host/web-links.js +110 -0
- package/dist/host/web.d.ts +30 -0
- package/dist/host/web.js +216 -0
- package/dist/host/xr.d.ts +24 -0
- package/dist/host/xr.js +59 -0
- package/dist/i18n/i18n.d.ts +59 -0
- package/dist/i18n/i18n.js +241 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/message.d.ts +72 -0
- package/dist/i18n/message.js +369 -0
- package/dist/i18n/negotiate.d.ts +17 -0
- package/dist/i18n/negotiate.js +58 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/input/bindings.d.ts +31 -0
- package/dist/input/bindings.js +141 -0
- package/dist/input/clock.d.ts +44 -0
- package/dist/input/clock.js +49 -0
- package/dist/input/follow.d.ts +133 -0
- package/dist/input/follow.js +218 -0
- package/dist/input/gestures.d.ts +281 -0
- package/dist/input/gestures.js +662 -0
- package/dist/input/glyphs.d.ts +35 -0
- package/dist/input/glyphs.js +216 -0
- package/dist/input/gyro.d.ts +85 -0
- package/dist/input/gyro.js +140 -0
- package/dist/input/index.d.ts +19 -0
- package/dist/input/index.js +16 -0
- package/dist/input/input.d.ts +543 -0
- package/dist/input/input.js +1492 -0
- package/dist/input/look.d.ts +327 -0
- package/dist/input/look.js +681 -0
- package/dist/input/magnify.d.ts +177 -0
- package/dist/input/magnify.js +131 -0
- package/dist/input/pointer-dispatch.d.ts +138 -0
- package/dist/input/pointer-dispatch.js +180 -0
- package/dist/input/pointer-router.d.ts +204 -0
- package/dist/input/pointer-router.js +533 -0
- package/dist/input/pointer-sources.d.ts +164 -0
- package/dist/input/pointer-sources.js +306 -0
- package/dist/input/rays.d.ts +138 -0
- package/dist/input/rays.js +615 -0
- package/dist/input/record.d.ts +209 -0
- package/dist/input/record.js +601 -0
- package/dist/input/touch-zones.d.ts +147 -0
- package/dist/input/touch-zones.js +300 -0
- package/dist/input/types.d.ts +158 -0
- package/dist/input/types.js +1 -0
- package/dist/input/xr-source.d.ts +53 -0
- package/dist/input/xr-source.js +164 -0
- package/dist/nav/astar.d.ts +45 -0
- package/dist/nav/astar.js +182 -0
- package/dist/nav/corridor.d.ts +40 -0
- package/dist/nav/corridor.js +95 -0
- package/dist/nav/crowd.d.ts +94 -0
- package/dist/nav/crowd.js +624 -0
- package/dist/nav/flow.d.ts +61 -0
- package/dist/nav/flow.js +193 -0
- package/dist/nav/grid.d.ts +108 -0
- package/dist/nav/grid.js +210 -0
- package/dist/nav/heap.d.ts +22 -0
- package/dist/nav/heap.js +92 -0
- package/dist/nav/index.d.ts +37 -0
- package/dist/nav/index.js +19 -0
- package/dist/nav/mesh/areas.d.ts +44 -0
- package/dist/nav/mesh/areas.js +98 -0
- package/dist/nav/mesh/bake-options.d.ts +33 -0
- package/dist/nav/mesh/bake-options.js +76 -0
- package/dist/nav/mesh/contour.d.ts +22 -0
- package/dist/nav/mesh/contour.js +323 -0
- package/dist/nav/mesh/flow3.d.ts +35 -0
- package/dist/nav/mesh/flow3.js +229 -0
- package/dist/nav/mesh/links.d.ts +38 -0
- package/dist/nav/mesh/links.js +72 -0
- package/dist/nav/mesh/mesh-path.d.ts +152 -0
- package/dist/nav/mesh/mesh-path.js +643 -0
- package/dist/nav/mesh/mesh-reach.d.ts +78 -0
- package/dist/nav/mesh/mesh-reach.js +450 -0
- package/dist/nav/mesh/navmesh.d.ts +117 -0
- package/dist/nav/mesh/navmesh.js +647 -0
- package/dist/nav/mesh/polymesh.d.ts +24 -0
- package/dist/nav/mesh/polymesh.js +384 -0
- package/dist/nav/mesh/regions.d.ts +12 -0
- package/dist/nav/mesh/regions.js +367 -0
- package/dist/nav/mesh/serialize.d.ts +13 -0
- package/dist/nav/mesh/serialize.js +197 -0
- package/dist/nav/mesh/voxelize.d.ts +111 -0
- package/dist/nav/mesh/voxelize.js +552 -0
- package/dist/nav/obstacles.d.ts +75 -0
- package/dist/nav/obstacles.js +294 -0
- package/dist/nav/path.d.ts +59 -0
- package/dist/nav/path.js +177 -0
- package/dist/nav/query-queue.d.ts +46 -0
- package/dist/nav/query-queue.js +308 -0
- package/dist/nav/reach.d.ts +53 -0
- package/dist/nav/reach.js +148 -0
- package/dist/nav/steer.d.ts +36 -0
- package/dist/nav/steer.js +78 -0
- package/dist/platform/boot.d.ts +28 -0
- package/dist/platform/boot.js +43 -0
- package/dist/platform/device-mode.d.ts +40 -0
- package/dist/platform/device-mode.js +104 -0
- package/dist/platform/device.d.ts +31 -0
- package/dist/platform/device.js +91 -0
- package/dist/platform/environment.d.ts +42 -0
- package/dist/platform/environment.js +82 -0
- package/dist/platform/gpu.d.ts +40 -0
- package/dist/platform/gpu.js +57 -0
- package/dist/platform/index.d.ts +18 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/letterbox.d.ts +43 -0
- package/dist/platform/letterbox.js +57 -0
- package/dist/platform/links.d.ts +20 -0
- package/dist/platform/links.js +43 -0
- package/dist/platform/screens.d.ts +36 -0
- package/dist/platform/screens.js +138 -0
- package/dist/platform/surface.d.ts +72 -0
- package/dist/platform/surface.js +157 -0
- package/dist/platform/xr-fake.d.ts +168 -0
- package/dist/platform/xr-fake.js +434 -0
- package/dist/platform/xr-surface.d.ts +120 -0
- package/dist/platform/xr-surface.js +214 -0
- package/dist/platform/xr-types.d.ts +262 -0
- package/dist/post/ao.d.ts +12 -0
- package/dist/post/ao.js +136 -0
- package/dist/post/blend.d.ts +27 -0
- package/dist/post/blend.js +129 -0
- package/dist/post/depth-pass.d.ts +43 -0
- package/dist/post/depth-pass.js +118 -0
- package/dist/post/dof.d.ts +1 -0
- package/dist/post/dof.js +66 -0
- package/dist/post/exposure.d.ts +80 -0
- package/dist/post/exposure.js +322 -0
- package/dist/post/index.d.ts +12 -0
- package/dist/post/index.js +11 -0
- package/dist/post/lens-dirt.d.ts +13 -0
- package/dist/post/lens-dirt.js +91 -0
- package/dist/post/lut.d.ts +19 -0
- package/dist/post/lut.js +50 -0
- package/dist/post/motion-blur.d.ts +9 -0
- package/dist/post/motion-blur.js +78 -0
- package/dist/post/post-stack.d.ts +302 -0
- package/dist/post/post-stack.js +1137 -0
- package/dist/post/settings.d.ts +485 -0
- package/dist/post/settings.js +416 -0
- package/dist/post/shaders.d.ts +25 -0
- package/dist/post/shaders.js +410 -0
- package/dist/post/ssr.d.ts +16 -0
- package/dist/post/ssr.js +155 -0
- package/dist/post/taa.d.ts +74 -0
- package/dist/post/taa.js +235 -0
- package/dist/post/white-balance.d.ts +25 -0
- package/dist/post/white-balance.js +98 -0
- package/dist/render/bindings.d.ts +98 -0
- package/dist/render/bindings.js +281 -0
- package/dist/render/blend.d.ts +13 -0
- package/dist/render/blend.js +26 -0
- package/dist/render/camera-2d.d.ts +72 -0
- package/dist/render/camera-2d.js +92 -0
- package/dist/render/camera.d.ts +302 -0
- package/dist/render/camera.js +671 -0
- package/dist/render/color.d.ts +16 -0
- package/dist/render/color.js +41 -0
- package/dist/render/compressed.d.ts +104 -0
- package/dist/render/compressed.js +248 -0
- package/dist/render/diagnostics.d.ts +15 -0
- package/dist/render/diagnostics.js +43 -0
- package/dist/render/dynamic-resolution.d.ts +70 -0
- package/dist/render/dynamic-resolution.js +126 -0
- package/dist/render/fake-gpu.d.ts +204 -0
- package/dist/render/fake-gpu.js +426 -0
- package/dist/render/flipbook.d.ts +56 -0
- package/dist/render/flipbook.js +87 -0
- package/dist/render/frame.d.ts +278 -0
- package/dist/render/frame.js +174 -0
- package/dist/render/fullscreen.d.ts +54 -0
- package/dist/render/fullscreen.js +91 -0
- package/dist/render/gpu-timer.d.ts +73 -0
- package/dist/render/gpu-timer.js +186 -0
- package/dist/render/index.d.ts +53 -0
- package/dist/render/index.js +29 -0
- package/dist/render/instance-list.d.ts +185 -0
- package/dist/render/instance-list.js +547 -0
- package/dist/render/lights.d.ts +181 -0
- package/dist/render/lights.js +233 -0
- package/dist/render/lod.d.ts +54 -0
- package/dist/render/lod.js +52 -0
- package/dist/render/material.d.ts +165 -0
- package/dist/render/material.js +292 -0
- package/dist/render/mesh.d.ts +284 -0
- package/dist/render/mesh.js +472 -0
- package/dist/render/mipmap.d.ts +16 -0
- package/dist/render/mipmap.js +121 -0
- package/dist/render/parallax.d.ts +50 -0
- package/dist/render/parallax.js +47 -0
- package/dist/render/pbr-wgsl.d.ts +31 -0
- package/dist/render/pbr-wgsl.js +119 -0
- package/dist/render/ping-pong.d.ts +42 -0
- package/dist/render/ping-pong.js +74 -0
- package/dist/render/renderer.d.ts +741 -0
- package/dist/render/renderer.js +2486 -0
- package/dist/render/scene-pipelines.d.ts +44 -0
- package/dist/render/scene-pipelines.js +92 -0
- package/dist/render/scene-target.d.ts +170 -0
- package/dist/render/scene-target.js +450 -0
- package/dist/render/shadow.d.ts +74 -0
- package/dist/render/shadow.js +208 -0
- package/dist/render/skin.d.ts +112 -0
- package/dist/render/skin.js +240 -0
- package/dist/render/snapshot.d.ts +36 -0
- package/dist/render/snapshot.js +34 -0
- package/dist/render/standard.d.ts +162 -0
- package/dist/render/standard.js +263 -0
- package/dist/render/texture.d.ts +142 -0
- package/dist/render/texture.js +228 -0
- package/dist/render/tile-layer.d.ts +110 -0
- package/dist/render/tile-layer.js +304 -0
- package/dist/render/transform.d.ts +115 -0
- package/dist/render/transform.js +318 -0
- package/dist/render/wgsl.d.ts +131 -0
- package/dist/render/wgsl.js +528 -0
- package/dist/save/codec.d.ts +49 -0
- package/dist/save/codec.js +169 -0
- package/dist/save/index.d.ts +8 -0
- package/dist/save/index.js +8 -0
- package/dist/save/journal.d.ts +24 -0
- package/dist/save/journal.js +102 -0
- package/dist/save/migrate.d.ts +15 -0
- package/dist/save/migrate.js +37 -0
- package/dist/save/schema.d.ts +72 -0
- package/dist/save/schema.js +154 -0
- package/dist/save/settings.d.ts +28 -0
- package/dist/save/settings.js +59 -0
- package/dist/save/slots.d.ts +56 -0
- package/dist/save/slots.js +200 -0
- package/dist/save/storage.d.ts +35 -0
- package/dist/save/storage.js +62 -0
- package/dist/save/store.d.ts +114 -0
- package/dist/save/store.js +269 -0
- package/dist/testing/fake-host.d.ts +103 -0
- package/dist/testing/fake-host.js +163 -0
- package/dist/testing/fixed-clock.d.ts +25 -0
- package/dist/testing/fixed-clock.js +30 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/test-game.d.ts +76 -0
- package/dist/testing/test-game.js +92 -0
- package/dist/tween/ease.d.ts +77 -0
- package/dist/tween/ease.js +192 -0
- package/dist/tween/index.d.ts +8 -0
- package/dist/tween/index.js +7 -0
- package/dist/tween/timeline.d.ts +78 -0
- package/dist/tween/timeline.js +269 -0
- package/dist/tween/tween.d.ts +168 -0
- package/dist/tween/tween.js +320 -0
- package/dist/ui/anchor.d.ts +206 -0
- package/dist/ui/anchor.js +307 -0
- package/dist/ui/caption.d.ts +122 -0
- package/dist/ui/caption.js +286 -0
- package/dist/ui/cursor.d.ts +105 -0
- package/dist/ui/cursor.js +261 -0
- package/dist/ui/dom.d.ts +30 -0
- package/dist/ui/dom.js +92 -0
- package/dist/ui/floats.d.ts +86 -0
- package/dist/ui/floats.js +260 -0
- package/dist/ui/hud.d.ts +198 -0
- package/dist/ui/hud.js +431 -0
- package/dist/ui/index.d.ts +37 -0
- package/dist/ui/index.js +34 -0
- package/dist/ui/inventory-card.d.ts +52 -0
- package/dist/ui/inventory-card.js +173 -0
- package/dist/ui/inventory-context.d.ts +29 -0
- package/dist/ui/inventory-context.js +125 -0
- package/dist/ui/inventory-drag.d.ts +63 -0
- package/dist/ui/inventory-drag.js +394 -0
- package/dist/ui/inventory-grid.d.ts +66 -0
- package/dist/ui/inventory-grid.js +625 -0
- package/dist/ui/inventory-radial.d.ts +39 -0
- package/dist/ui/inventory-radial.js +168 -0
- package/dist/ui/inventory.d.ts +128 -0
- package/dist/ui/inventory.js +154 -0
- package/dist/ui/layout.d.ts +356 -0
- package/dist/ui/layout.js +856 -0
- package/dist/ui/link.d.ts +64 -0
- package/dist/ui/link.js +155 -0
- package/dist/ui/loading.d.ts +40 -0
- package/dist/ui/loading.js +157 -0
- package/dist/ui/loupe.d.ts +74 -0
- package/dist/ui/loupe.js +164 -0
- package/dist/ui/menu-nav.d.ts +33 -0
- package/dist/ui/menu-nav.js +28 -0
- package/dist/ui/minimap-canvas.d.ts +145 -0
- package/dist/ui/minimap-canvas.js +460 -0
- package/dist/ui/notify.d.ts +40 -0
- package/dist/ui/notify.js +141 -0
- package/dist/ui/orb.d.ts +53 -0
- package/dist/ui/orb.js +304 -0
- package/dist/ui/overlay.d.ts +213 -0
- package/dist/ui/overlay.js +394 -0
- package/dist/ui/padnav.d.ts +53 -0
- package/dist/ui/padnav.js +146 -0
- package/dist/ui/perf.d.ts +130 -0
- package/dist/ui/perf.js +329 -0
- package/dist/ui/rotate-card.d.ts +54 -0
- package/dist/ui/rotate-card.js +97 -0
- package/dist/ui/stack.d.ts +128 -0
- package/dist/ui/stack.js +312 -0
- package/dist/ui/styles.d.ts +13 -0
- package/dist/ui/styles.js +200 -0
- package/dist/ui/text-scale.d.ts +67 -0
- package/dist/ui/text-scale.js +102 -0
- package/dist/ui/theme.d.ts +70 -0
- package/dist/ui/theme.js +98 -0
- package/dist/ui/toast.d.ts +23 -0
- package/dist/ui/toast.js +46 -0
- package/dist/ui/tooltip.d.ts +89 -0
- package/dist/ui/tooltip.js +333 -0
- package/dist/ui/widgets-2.d.ts +134 -0
- package/dist/ui/widgets-2.js +399 -0
- package/dist/ui/widgets-3.d.ts +91 -0
- package/dist/ui/widgets-3.js +212 -0
- package/dist/ui/widgets.d.ts +34 -0
- package/dist/ui/widgets.js +50 -0
- package/dist/ui/world-panel/index.d.ts +5 -0
- package/dist/ui/world-panel/index.js +5 -0
- package/dist/ui/world-panel/layout.d.ts +38 -0
- package/dist/ui/world-panel/layout.js +68 -0
- package/dist/ui/world-panel/paint.d.ts +96 -0
- package/dist/ui/world-panel/paint.js +136 -0
- package/dist/ui/world-panel/panel.d.ts +235 -0
- package/dist/ui/world-panel/panel.js +762 -0
- package/dist/ui/world-panel/wgsl.d.ts +10 -0
- package/dist/ui/world-panel/wgsl.js +52 -0
- package/dist/ui/world-panel/widgets.d.ts +207 -0
- package/dist/ui/world-panel/widgets.js +569 -0
- package/dist/voxel/chunks.d.ts +77 -0
- package/dist/voxel/chunks.js +149 -0
- package/dist/voxel/grid.d.ts +84 -0
- package/dist/voxel/grid.js +223 -0
- package/dist/voxel/index.d.ts +22 -0
- package/dist/voxel/index.js +7 -0
- package/dist/voxel/mesher-worker.d.ts +14 -0
- package/dist/voxel/mesher-worker.js +47 -0
- package/dist/voxel/mesher.d.ts +73 -0
- package/dist/voxel/mesher.js +306 -0
- package/dist/voxel/ray.d.ts +32 -0
- package/dist/voxel/ray.js +73 -0
- package/dist/voxel/wgsl.d.ts +16 -0
- package/dist/voxel/wgsl.js +28 -0
- package/dist/voxel/worker-client.d.ts +79 -0
- package/dist/voxel/worker-client.js +122 -0
- package/package.json +177 -3
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporal anti-aliasing (ws/post-3, on camera jitter since ws/post-4). The stack keeps two
|
|
3
|
+
* scene-size `rgba16float` history textures and ping-pongs between them. While TAA runs the
|
|
4
|
+
* stack declares `wantsJitter` and hands `Taa.jitter` (Halton 2, 3) to the renderer's
|
|
5
|
+
* `setJitter` hook (ws/post-6), which offsets the projection of every camera it draws; the
|
|
6
|
+
* frame arrives jittered by `PostInputs.view.jitter`. The resolve un-jitters it (samples the colour and the
|
|
7
|
+
* depth `P.taa2.xy` uv along the jitter, bilinear), reprojects the history through `P.reproj`
|
|
8
|
+
* (`view.previousViewProj × view.invViewProj`: this frame's jittered clip → last frame's
|
|
9
|
+
* unjittered clip), clamps it to the 3×3 neighbourhood of the current colour (min/max box, or
|
|
10
|
+
* mean ± σ) and blends it in by `P.taa.y` (feedback). `P.taa2.z` (reset) copies the current
|
|
11
|
+
* frame instead: the first frame, and the one after a resize.
|
|
12
|
+
*
|
|
13
|
+
* Since ws/post-5 a frame with a velocity target reprojects each pixel by its own motion
|
|
14
|
+
* (`uv - velocity`) instead, so moving and skinned objects keep their history, and drops the
|
|
15
|
+
* history where last frame's depth or velocity there disagree (`TAA_WGSL`, `taaRejects`).
|
|
16
|
+
*
|
|
17
|
+
* Since ws/post-6 the history is read with a 5-tap Catmull-Rom filter by default
|
|
18
|
+
* (`taa.historyFilter`, `P.taa3.z`; `taaCatmullRomWeights` is the CPU twin of its weights), so
|
|
19
|
+
* a surface moving a fraction of a pixel a frame is not re-blurred by a bilinear tap each frame.
|
|
20
|
+
*/
|
|
21
|
+
import { type Mat4 } from '../core/math.js';
|
|
22
|
+
/** Van der Corput radical inverse in `base` of `index` (1-based). */
|
|
23
|
+
export declare function halton(index: number, base: number): number;
|
|
24
|
+
/** Highest history weight: above it the image smears and never settles. */
|
|
25
|
+
export declare const TAA_MAX_FEEDBACK = 0.98;
|
|
26
|
+
/** The history weight the resolve uses for `feedback`: clamped to 0..`TAA_MAX_FEEDBACK`. */
|
|
27
|
+
export declare function taaBlendWeight(feedback: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* The matrix TAA and motion blur reproject by: this frame's clip space to the previous
|
|
30
|
+
* frame's, `out = prevViewProj × invViewProj`. Identity when the camera has not moved.
|
|
31
|
+
*/
|
|
32
|
+
export declare function taaReprojection(out: Mat4, prevViewProj: ArrayLike<number>, invViewProj: ArrayLike<number>): Mat4;
|
|
33
|
+
/** The jitter sequence. `PostStack.taa` is one; the stack feeds it to `Renderer.setJitter`. */
|
|
34
|
+
export declare class Taa {
|
|
35
|
+
/** Points in the cycle (8 or 16). */
|
|
36
|
+
readonly samples: 8 | 16;
|
|
37
|
+
private readonly out;
|
|
38
|
+
constructor(samples?: 8 | 16);
|
|
39
|
+
/**
|
|
40
|
+
* The sub-pixel offset for `frame` in pixel units (each in -0.5..0.5): Halton (2, 3) over
|
|
41
|
+
* the cycle, centred. The returned pair is reused; copy it to keep it.
|
|
42
|
+
*/
|
|
43
|
+
jitter(frame: number): [number, number];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The Catmull-Rom weights of the four texels around a sample at fraction `f` (0..1) past the
|
|
47
|
+
* second one: `out[0..3]` for the texels at -1, 0, 1, 2. They sum to 1; at `f = 0` they are
|
|
48
|
+
* (0, 1, 0, 0), so a sample on a texel centre reads that texel exactly. The resolve folds the
|
|
49
|
+
* middle two into one bilinear tap per axis and drops the four corner taps (5 taps for 16).
|
|
50
|
+
*/
|
|
51
|
+
export declare function taaCatmullRomWeights(f: number, out?: [number, number, number, number]): [number, number, number, number];
|
|
52
|
+
/** Format of the TAA history aux pair (ws/post-5): velocity (uv) in xy, linear depth in z, 1 in w. */
|
|
53
|
+
export declare const TAA_AUX_FORMAT: GPUTextureFormat;
|
|
54
|
+
/**
|
|
55
|
+
* The CPU twin of the resolve's history rejection (ws/post-5): true when the history sample
|
|
56
|
+
* (velocity `hv` in uv, linear depth `hz`) belongs to a different surface than the pixel
|
|
57
|
+
* (velocity `v`, linear depth `z`) on a `width × height` target: the depths differ by more
|
|
58
|
+
* than `depthReject` of the nearer one, or the velocities by more than `velocityReject` px.
|
|
59
|
+
*/
|
|
60
|
+
export declare function taaRejects(v: readonly [number, number], z: number, hv: readonly [number, number], hz: number, width: number, height: number, depthReject: number, velocityReject: number): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The resolve pass (`DepthPass`, two targets: the HDR resolve and its `TAA_AUX_FORMAT` aux;
|
|
63
|
+
* four textures: `@binding(4)` the current scene colour, `@binding(5)` the previous resolve,
|
|
64
|
+
* `@binding(6)` the velocity target (the scene colour stands in without one; unread),
|
|
65
|
+
* `@binding(7)` the previous aux).
|
|
66
|
+
*
|
|
67
|
+
* Velocity reprojection (ws/post-5, `P.taa2.w`): the pixel takes the velocity of the nearest
|
|
68
|
+
* depth in its 3×3 (so an edge moves with the object in front) and finds its history at
|
|
69
|
+
* `uv - velocity`; where the target holds no motion it falls back to `P.reproj`. The history
|
|
70
|
+
* is dropped when its aux (last frame's velocity and linear depth there) disagrees with the
|
|
71
|
+
* pixel's by more than `P.taa3.x` (relative depth) or `P.taa3.y` (px). Without it the resolve
|
|
72
|
+
* is the ws/post-4 one; the aux is written either way so a switch finds a valid one.
|
|
73
|
+
*/
|
|
74
|
+
export declare const TAA_WGSL = "\n\nstruct PostUniforms {\n frame: vec4f, // time, aspect, 1/width, 1/height\n enables: vec4f, // bloom, fog, rays, vignette\n enables2: vec4f, // grade, tonemap (0 none, 1 aces, 2 reinhard), dither, exposure\n bloom: vec4f, // intensity, threshold, knee, emissiveWeight\n bloom2: vec4f, // scatter, -, -, -\n fogColor: vec4f, // rgb, density\n fog: vec4f, // top, bottom, noiseScale, speed\n fog2: vec4f, // lightScatter, falloff, -, -\n rays: vec4f, // light uv x, y, intensity, decay\n rays2: vec4f, // density, weight, source radius (uv-y units), source intensity\n raysColor: vec4f, // rgb, bloomSource\n vignette: vec4f, // intensity, radius, softness, -\n vignetteColor: vec4f,\n lift: vec4f,\n gamma: vec4f,\n gain: vec4f,\n grade: vec4f, // saturation, contrast, -, -\n quality: vec4f, // ray samples, fog octaves, ortho projection (1, ws/post-4), -\n ao: vec4f, // enabled (0 without depth), radius, intensity, bias\n ao2: vec4f, // power, samples, proj x scale, proj y scale\n dof: vec4f, // enabled (0 without depth), focus distance, focus range, max blur (uv of width)\n dof2: vec4f, // near blur, taps, near plane, far plane\n invProj: mat4x4f, // clip -> view\n fxaa: vec4f, // enabled, subpixel, edgeThreshold, -\n lut: vec4f, // enabled, (size-1)/size, intensity, 0.5/size\n grain: vec4f, // intensity, cell size (px), luminanceResponse, seed\n aberration: vec4f, // intensity (px), radialOnly, -, -\n sharpen: vec4f, // amount, -, -, -\n outline: vec4f, // enabled (0 without depth), thickness (scene px), depthThreshold, normalThreshold\n outlineColor: vec4f, // rgb, intensity\n // Post 3 (ws/post-3).\n taa: vec4f, // enabled (0 without depth), feedback, sharpen, clampMode (0 aabb, 1 variance)\n taa2: vec4f, // view jitter x (uv), view jitter y (uv), reset (1 = copy the current frame), velocity reprojection (1, ws/post-5)\n ssr: vec4f, // enabled (0 without depth), maxSteps, thickness, maxDistance\n ssr2: vec4f, // roughnessCutoff, intensity, fadeEdges (uv), rough-metal target (1)\n exposure: vec4f, // auto (1), histogramLow, histogramHigh, keyValue\n wb0: vec4f, // white-balance matrix row 0 (rgb weights), enabled\n wb1: vec4f, // row 1\n wb2: vec4f, // row 2\n motionBlur: vec4f, // enabled (0 without depth), intensity, samples, velocity target (1 = object)\n dirt: vec4f, // enabled, intensity, -, -\n reproj: mat4x4f, // current clip -> previous frame's clip (identity on a reset)\n // Post 5 (ws/post-5).\n taa3: vec4f, // depthReject (fraction), velocityReject (px), history filter (1 = Catmull-Rom, ws/post-6), -\n};\n@group(0) @binding(0) var<uniform> P: PostUniforms;\n\n@group(0) @binding(1) var nearest: sampler;\n@group(0) @binding(2) var linSamp: sampler;\n@group(0) @binding(3) var depthTex: texture_depth_2d;\n@group(0) @binding(4) var colorTex: texture_2d<f32>;\n@group(0) @binding(5) var historyTex: texture_2d<f32>;\n@group(0) @binding(6) var velocityTex: texture_2d<f32>;\n@group(0) @binding(7) var auxTex: texture_2d<f32>;\n\nfn view_pos(uv: vec2f, depth: f32) -> vec3f {\n let ndc = vec3f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, depth);\n let p = P.invProj * vec4f(ndc, 1.0);\n return p.xyz / p.w;\n}\nfn linear_depth(uv: vec2f, depth: f32) -> f32 {\n return -view_pos(uv, depth).z;\n}\n/** The centre of the depth texel under `uv`: positions must be rebuilt where the depth was read. */\nfn texel_uv(uv: vec2f, dim: vec2f) -> vec2f {\n return (floor(clamp(uv, vec2f(0.0), vec2f(0.9999)) * dim) + 0.5) / dim;\n}\n\n\nstruct TaaOut {\n @location(0) color: vec4f,\n @location(1) aux: vec4f,\n};\n\nfn cur(uv: vec2f) -> vec3f { return textureSampleLevel(colorTex, nearest, uv, 0.0).rgb; }\n\nfn hist(uv: vec2f) -> vec3f { return textureSampleLevel(historyTex, linSamp, uv, 0.0).rgb; }\n\n// The history at uv through a Catmull-Rom filter (ws/post-6): the 4\u00D74 texels around it, the\n// middle two of each axis folded into one bilinear tap and the four corners dropped, 5 taps.\n// Normalised by the taps' weight, since the corners are gone.\nfn hist_catmull_rom(uv: vec2f) -> vec3f {\n let dim = vec2f(textureDimensions(historyTex));\n let p = uv * dim;\n let t1 = floor(p - 0.5) + 0.5;\n let f = p - t1;\n let w0 = f * (-0.5 + f * (1.0 - 0.5 * f));\n let w1 = 1.0 + f * f * (-2.5 + 1.5 * f);\n let w2 = f * (0.5 + f * (2.0 - 1.5 * f));\n let w3 = f * f * (-0.5 + 0.5 * f);\n let w12 = w1 + w2;\n let t0 = (t1 - 1.0) / dim;\n let t3 = (t1 + 2.0) / dim;\n let t12 = (t1 + w2 / w12) / dim;\n let a = w12.x * w0.y;\n let b = w0.x * w12.y;\n let c = w12.x * w12.y;\n let d = w3.x * w12.y;\n let e = w12.x * w3.y;\n let sum = hist(vec2f(t12.x, t0.y)) * a + hist(vec2f(t0.x, t12.y)) * b + hist(t12) * c +\n hist(vec2f(t3.x, t12.y)) * d + hist(vec2f(t12.x, t3.y)) * e;\n return sum / (a + b + c + d + e);\n}\n\n@fragment fn fs_main(in: FullscreenIn) -> TaaOut {\n let dim = vec2f(textureDimensions(colorTex));\n let t = 1.0 / dim;\n // The camera drew this frame shifted by the jitter (+x right, +y down): what belongs at this\n // pixel sits that far along in the colour and the depth. Un-jitter by sampling there.\n let uv = in.uv + P.taa2.xy;\n let c = textureSampleLevel(colorTex, linSamp, uv, 0.0).rgb;\n let d = textureSampleLevel(depthTex, nearest, uv, 0u);\n let velocityMode = P.taa2.w > 0.5;\n // 3\u00D73 neighbourhood bounds of the current colour around the un-jittered point, and (velocity\n // mode) the nearest depth's texel.\n var mn = vec3f(1e9);\n var mx = vec3f(-1e9);\n var m1 = vec3f(0.0);\n var m2 = vec3f(0.0);\n var nearD = d;\n var nearUv = uv;\n for (var y = -1; y <= 1; y++) {\n for (var x = -1; x <= 1; x++) {\n let o = uv + vec2f(f32(x), f32(y)) * t;\n let s = cur(o);\n mn = min(mn, s);\n mx = max(mx, s);\n m1 += s;\n m2 += s * s;\n if (velocityMode) {\n let sd = textureSampleLevel(depthTex, nearest, o, 0u);\n if (sd < nearD) {\n nearD = sd;\n nearUv = o;\n }\n }\n }\n }\n let mean = m1 / 9.0;\n if (P.taa.w > 0.5) {\n let sigma = sqrt(max(m2 / 9.0 - mean * mean, vec3f(0.0)));\n mn = max(mn, mean - sigma);\n mx = min(mx, mean + sigma);\n }\n // The target holds where the point is minus where it was (uv).\n var vel = vec2f(0.0);\n if (velocityMode) {\n vel = textureSampleLevel(velocityTex, nearest, nearUv, 0.0).xy;\n }\n let z = linear_depth(uv, d);\n var out = c;\n if (P.taa2.z < 0.5) {\n var puv = in.uv - vel;\n var ahead = true;\n if (dot(vel, vel) < 1e-12) {\n // The jittered frame's clip position of that depth sample: P.reproj starts from it.\n let ndc = vec4f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, d, 1.0);\n let prev = P.reproj * ndc;\n let pn = prev.xy / max(prev.w, 1e-6);\n puv = vec2f(pn.x * 0.5 + 0.5, 0.5 - pn.y * 0.5);\n ahead = prev.w > 0.0;\n }\n var keep = ahead && all(puv >= vec2f(0.0)) && all(puv <= vec2f(1.0));\n if (keep && velocityMode) {\n let a = textureSampleLevel(auxTex, nearest, puv, 0.0);\n let dz = abs(a.z - z) / max(min(a.z, z), 1e-4);\n let dv = length((vel - a.xy) * dim);\n keep = a.w > 0.5 && dz <= P.taa3.x && dv <= P.taa3.y;\n }\n if (keep) {\n var hs: vec3f;\n if (P.taa3.z > 0.5) {\n hs = hist_catmull_rom(puv);\n } else {\n hs = hist(puv);\n }\n let h = clamp(hs, mn, mx);\n out = mix(c, h, P.taa.y);\n }\n }\n // Unsharp against the neighbourhood mean, so the blend's softness comes back as detail.\n out = max(out + (out - mean) * P.taa.z, vec3f(0.0));\n return TaaOut(vec4f(out, 1.0), vec4f(vel, z, 1.0));\n}\n";
|
package/dist/post/taa.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporal anti-aliasing (ws/post-3, on camera jitter since ws/post-4). The stack keeps two
|
|
3
|
+
* scene-size `rgba16float` history textures and ping-pongs between them. While TAA runs the
|
|
4
|
+
* stack declares `wantsJitter` and hands `Taa.jitter` (Halton 2, 3) to the renderer's
|
|
5
|
+
* `setJitter` hook (ws/post-6), which offsets the projection of every camera it draws; the
|
|
6
|
+
* frame arrives jittered by `PostInputs.view.jitter`. The resolve un-jitters it (samples the colour and the
|
|
7
|
+
* depth `P.taa2.xy` uv along the jitter, bilinear), reprojects the history through `P.reproj`
|
|
8
|
+
* (`view.previousViewProj × view.invViewProj`: this frame's jittered clip → last frame's
|
|
9
|
+
* unjittered clip), clamps it to the 3×3 neighbourhood of the current colour (min/max box, or
|
|
10
|
+
* mean ± σ) and blends it in by `P.taa.y` (feedback). `P.taa2.z` (reset) copies the current
|
|
11
|
+
* frame instead: the first frame, and the one after a resize.
|
|
12
|
+
*
|
|
13
|
+
* Since ws/post-5 a frame with a velocity target reprojects each pixel by its own motion
|
|
14
|
+
* (`uv - velocity`) instead, so moving and skinned objects keep their history, and drops the
|
|
15
|
+
* history where last frame's depth or velocity there disagree (`TAA_WGSL`, `taaRejects`).
|
|
16
|
+
*
|
|
17
|
+
* Since ws/post-6 the history is read with a 5-tap Catmull-Rom filter by default
|
|
18
|
+
* (`taa.historyFilter`, `P.taa3.z`; `taaCatmullRomWeights` is the CPU twin of its weights), so
|
|
19
|
+
* a surface moving a fraction of a pixel a frame is not re-blurred by a bilinear tap each frame.
|
|
20
|
+
*/
|
|
21
|
+
import { mat4 } from '../core/math.js';
|
|
22
|
+
import { WGSL_DEPTH_VIEW } from './ao.js';
|
|
23
|
+
import { WGSL_POST_UNIFORMS } from './settings.js';
|
|
24
|
+
/** Van der Corput radical inverse in `base` of `index` (1-based). */
|
|
25
|
+
export function halton(index, base) {
|
|
26
|
+
let f = 1;
|
|
27
|
+
let r = 0;
|
|
28
|
+
let i = index;
|
|
29
|
+
while (i > 0) {
|
|
30
|
+
f /= base;
|
|
31
|
+
r += f * (i % base);
|
|
32
|
+
i = Math.floor(i / base);
|
|
33
|
+
}
|
|
34
|
+
return r;
|
|
35
|
+
}
|
|
36
|
+
/** Highest history weight: above it the image smears and never settles. */
|
|
37
|
+
export const TAA_MAX_FEEDBACK = 0.98;
|
|
38
|
+
/** The history weight the resolve uses for `feedback`: clamped to 0..`TAA_MAX_FEEDBACK`. */
|
|
39
|
+
export function taaBlendWeight(feedback) {
|
|
40
|
+
if (!Number.isFinite(feedback))
|
|
41
|
+
return 0;
|
|
42
|
+
return Math.min(TAA_MAX_FEEDBACK, Math.max(0, feedback));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The matrix TAA and motion blur reproject by: this frame's clip space to the previous
|
|
46
|
+
* frame's, `out = prevViewProj × invViewProj`. Identity when the camera has not moved.
|
|
47
|
+
*/
|
|
48
|
+
export function taaReprojection(out, prevViewProj, invViewProj) {
|
|
49
|
+
return mat4.multiply(out, prevViewProj, invViewProj);
|
|
50
|
+
}
|
|
51
|
+
/** The jitter sequence. `PostStack.taa` is one; the stack feeds it to `Renderer.setJitter`. */
|
|
52
|
+
export class Taa {
|
|
53
|
+
/** Points in the cycle (8 or 16). */
|
|
54
|
+
samples;
|
|
55
|
+
out = [0, 0];
|
|
56
|
+
constructor(samples = 8) {
|
|
57
|
+
this.samples = samples;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The sub-pixel offset for `frame` in pixel units (each in -0.5..0.5): Halton (2, 3) over
|
|
61
|
+
* the cycle, centred. The returned pair is reused; copy it to keep it.
|
|
62
|
+
*/
|
|
63
|
+
jitter(frame) {
|
|
64
|
+
const i = (Math.max(0, Math.floor(frame)) % this.samples) + 1;
|
|
65
|
+
this.out[0] = halton(i, 2) - 0.5;
|
|
66
|
+
this.out[1] = halton(i, 3) - 0.5;
|
|
67
|
+
return this.out;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The Catmull-Rom weights of the four texels around a sample at fraction `f` (0..1) past the
|
|
72
|
+
* second one: `out[0..3]` for the texels at -1, 0, 1, 2. They sum to 1; at `f = 0` they are
|
|
73
|
+
* (0, 1, 0, 0), so a sample on a texel centre reads that texel exactly. The resolve folds the
|
|
74
|
+
* middle two into one bilinear tap per axis and drops the four corner taps (5 taps for 16).
|
|
75
|
+
*/
|
|
76
|
+
export function taaCatmullRomWeights(f, out = [0, 0, 0, 0]) {
|
|
77
|
+
out[0] = f * (-0.5 + f * (1 - 0.5 * f));
|
|
78
|
+
out[1] = 1 + f * f * (-2.5 + 1.5 * f);
|
|
79
|
+
out[2] = f * (0.5 + f * (2 - 1.5 * f));
|
|
80
|
+
out[3] = f * f * (-0.5 + 0.5 * f);
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
/** Format of the TAA history aux pair (ws/post-5): velocity (uv) in xy, linear depth in z, 1 in w. */
|
|
84
|
+
export const TAA_AUX_FORMAT = 'rgba16float';
|
|
85
|
+
/**
|
|
86
|
+
* The CPU twin of the resolve's history rejection (ws/post-5): true when the history sample
|
|
87
|
+
* (velocity `hv` in uv, linear depth `hz`) belongs to a different surface than the pixel
|
|
88
|
+
* (velocity `v`, linear depth `z`) on a `width × height` target: the depths differ by more
|
|
89
|
+
* than `depthReject` of the nearer one, or the velocities by more than `velocityReject` px.
|
|
90
|
+
*/
|
|
91
|
+
export function taaRejects(v, z, hv, hz, width, height, depthReject, velocityReject) {
|
|
92
|
+
const dz = Math.abs(hz - z) / Math.max(Math.min(hz, z), 1e-4);
|
|
93
|
+
const dv = Math.hypot((v[0] - hv[0]) * width, (v[1] - hv[1]) * height);
|
|
94
|
+
return dz > depthReject || dv > velocityReject;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The resolve pass (`DepthPass`, two targets: the HDR resolve and its `TAA_AUX_FORMAT` aux;
|
|
98
|
+
* four textures: `@binding(4)` the current scene colour, `@binding(5)` the previous resolve,
|
|
99
|
+
* `@binding(6)` the velocity target (the scene colour stands in without one; unread),
|
|
100
|
+
* `@binding(7)` the previous aux).
|
|
101
|
+
*
|
|
102
|
+
* Velocity reprojection (ws/post-5, `P.taa2.w`): the pixel takes the velocity of the nearest
|
|
103
|
+
* depth in its 3×3 (so an edge moves with the object in front) and finds its history at
|
|
104
|
+
* `uv - velocity`; where the target holds no motion it falls back to `P.reproj`. The history
|
|
105
|
+
* is dropped when its aux (last frame's velocity and linear depth there) disagrees with the
|
|
106
|
+
* pixel's by more than `P.taa3.x` (relative depth) or `P.taa3.y` (px). Without it the resolve
|
|
107
|
+
* is the ws/post-4 one; the aux is written either way so a switch finds a valid one.
|
|
108
|
+
*/
|
|
109
|
+
export const TAA_WGSL = /* wgsl */ `
|
|
110
|
+
${WGSL_POST_UNIFORMS}
|
|
111
|
+
@group(0) @binding(1) var nearest: sampler;
|
|
112
|
+
@group(0) @binding(2) var linSamp: sampler;
|
|
113
|
+
@group(0) @binding(3) var depthTex: texture_depth_2d;
|
|
114
|
+
@group(0) @binding(4) var colorTex: texture_2d<f32>;
|
|
115
|
+
@group(0) @binding(5) var historyTex: texture_2d<f32>;
|
|
116
|
+
@group(0) @binding(6) var velocityTex: texture_2d<f32>;
|
|
117
|
+
@group(0) @binding(7) var auxTex: texture_2d<f32>;
|
|
118
|
+
${WGSL_DEPTH_VIEW}
|
|
119
|
+
|
|
120
|
+
struct TaaOut {
|
|
121
|
+
@location(0) color: vec4f,
|
|
122
|
+
@location(1) aux: vec4f,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
fn cur(uv: vec2f) -> vec3f { return textureSampleLevel(colorTex, nearest, uv, 0.0).rgb; }
|
|
126
|
+
|
|
127
|
+
fn hist(uv: vec2f) -> vec3f { return textureSampleLevel(historyTex, linSamp, uv, 0.0).rgb; }
|
|
128
|
+
|
|
129
|
+
// The history at uv through a Catmull-Rom filter (ws/post-6): the 4×4 texels around it, the
|
|
130
|
+
// middle two of each axis folded into one bilinear tap and the four corners dropped, 5 taps.
|
|
131
|
+
// Normalised by the taps' weight, since the corners are gone.
|
|
132
|
+
fn hist_catmull_rom(uv: vec2f) -> vec3f {
|
|
133
|
+
let dim = vec2f(textureDimensions(historyTex));
|
|
134
|
+
let p = uv * dim;
|
|
135
|
+
let t1 = floor(p - 0.5) + 0.5;
|
|
136
|
+
let f = p - t1;
|
|
137
|
+
let w0 = f * (-0.5 + f * (1.0 - 0.5 * f));
|
|
138
|
+
let w1 = 1.0 + f * f * (-2.5 + 1.5 * f);
|
|
139
|
+
let w2 = f * (0.5 + f * (2.0 - 1.5 * f));
|
|
140
|
+
let w3 = f * f * (-0.5 + 0.5 * f);
|
|
141
|
+
let w12 = w1 + w2;
|
|
142
|
+
let t0 = (t1 - 1.0) / dim;
|
|
143
|
+
let t3 = (t1 + 2.0) / dim;
|
|
144
|
+
let t12 = (t1 + w2 / w12) / dim;
|
|
145
|
+
let a = w12.x * w0.y;
|
|
146
|
+
let b = w0.x * w12.y;
|
|
147
|
+
let c = w12.x * w12.y;
|
|
148
|
+
let d = w3.x * w12.y;
|
|
149
|
+
let e = w12.x * w3.y;
|
|
150
|
+
let sum = hist(vec2f(t12.x, t0.y)) * a + hist(vec2f(t0.x, t12.y)) * b + hist(t12) * c +
|
|
151
|
+
hist(vec2f(t3.x, t12.y)) * d + hist(vec2f(t12.x, t3.y)) * e;
|
|
152
|
+
return sum / (a + b + c + d + e);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@fragment fn fs_main(in: FullscreenIn) -> TaaOut {
|
|
156
|
+
let dim = vec2f(textureDimensions(colorTex));
|
|
157
|
+
let t = 1.0 / dim;
|
|
158
|
+
// The camera drew this frame shifted by the jitter (+x right, +y down): what belongs at this
|
|
159
|
+
// pixel sits that far along in the colour and the depth. Un-jitter by sampling there.
|
|
160
|
+
let uv = in.uv + P.taa2.xy;
|
|
161
|
+
let c = textureSampleLevel(colorTex, linSamp, uv, 0.0).rgb;
|
|
162
|
+
let d = textureSampleLevel(depthTex, nearest, uv, 0u);
|
|
163
|
+
let velocityMode = P.taa2.w > 0.5;
|
|
164
|
+
// 3×3 neighbourhood bounds of the current colour around the un-jittered point, and (velocity
|
|
165
|
+
// mode) the nearest depth's texel.
|
|
166
|
+
var mn = vec3f(1e9);
|
|
167
|
+
var mx = vec3f(-1e9);
|
|
168
|
+
var m1 = vec3f(0.0);
|
|
169
|
+
var m2 = vec3f(0.0);
|
|
170
|
+
var nearD = d;
|
|
171
|
+
var nearUv = uv;
|
|
172
|
+
for (var y = -1; y <= 1; y++) {
|
|
173
|
+
for (var x = -1; x <= 1; x++) {
|
|
174
|
+
let o = uv + vec2f(f32(x), f32(y)) * t;
|
|
175
|
+
let s = cur(o);
|
|
176
|
+
mn = min(mn, s);
|
|
177
|
+
mx = max(mx, s);
|
|
178
|
+
m1 += s;
|
|
179
|
+
m2 += s * s;
|
|
180
|
+
if (velocityMode) {
|
|
181
|
+
let sd = textureSampleLevel(depthTex, nearest, o, 0u);
|
|
182
|
+
if (sd < nearD) {
|
|
183
|
+
nearD = sd;
|
|
184
|
+
nearUv = o;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
let mean = m1 / 9.0;
|
|
190
|
+
if (P.taa.w > 0.5) {
|
|
191
|
+
let sigma = sqrt(max(m2 / 9.0 - mean * mean, vec3f(0.0)));
|
|
192
|
+
mn = max(mn, mean - sigma);
|
|
193
|
+
mx = min(mx, mean + sigma);
|
|
194
|
+
}
|
|
195
|
+
// The target holds where the point is minus where it was (uv).
|
|
196
|
+
var vel = vec2f(0.0);
|
|
197
|
+
if (velocityMode) {
|
|
198
|
+
vel = textureSampleLevel(velocityTex, nearest, nearUv, 0.0).xy;
|
|
199
|
+
}
|
|
200
|
+
let z = linear_depth(uv, d);
|
|
201
|
+
var out = c;
|
|
202
|
+
if (P.taa2.z < 0.5) {
|
|
203
|
+
var puv = in.uv - vel;
|
|
204
|
+
var ahead = true;
|
|
205
|
+
if (dot(vel, vel) < 1e-12) {
|
|
206
|
+
// The jittered frame's clip position of that depth sample: P.reproj starts from it.
|
|
207
|
+
let ndc = vec4f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, d, 1.0);
|
|
208
|
+
let prev = P.reproj * ndc;
|
|
209
|
+
let pn = prev.xy / max(prev.w, 1e-6);
|
|
210
|
+
puv = vec2f(pn.x * 0.5 + 0.5, 0.5 - pn.y * 0.5);
|
|
211
|
+
ahead = prev.w > 0.0;
|
|
212
|
+
}
|
|
213
|
+
var keep = ahead && all(puv >= vec2f(0.0)) && all(puv <= vec2f(1.0));
|
|
214
|
+
if (keep && velocityMode) {
|
|
215
|
+
let a = textureSampleLevel(auxTex, nearest, puv, 0.0);
|
|
216
|
+
let dz = abs(a.z - z) / max(min(a.z, z), 1e-4);
|
|
217
|
+
let dv = length((vel - a.xy) * dim);
|
|
218
|
+
keep = a.w > 0.5 && dz <= P.taa3.x && dv <= P.taa3.y;
|
|
219
|
+
}
|
|
220
|
+
if (keep) {
|
|
221
|
+
var hs: vec3f;
|
|
222
|
+
if (P.taa3.z > 0.5) {
|
|
223
|
+
hs = hist_catmull_rom(puv);
|
|
224
|
+
} else {
|
|
225
|
+
hs = hist(puv);
|
|
226
|
+
}
|
|
227
|
+
let h = clamp(hs, mn, mx);
|
|
228
|
+
out = mix(c, h, P.taa.y);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// Unsharp against the neighbourhood mean, so the blend's softness comes back as detail.
|
|
232
|
+
out = max(out + (out - mean) * P.taa.z, vec3f(0.0));
|
|
233
|
+
return TaaOut(vec4f(out, 1.0), vec4f(vel, z, 1.0));
|
|
234
|
+
}
|
|
235
|
+
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* White balance (ws/post-3): the 3×3 linear-sRGB matrix that tints an image toward the colour
|
|
3
|
+
* of a black body at a temperature, shifted green–magenta by a tint.
|
|
4
|
+
*
|
|
5
|
+
* Method: the target white's CIE 1931 chromaticity comes from the Kim et al. (2002) cubic
|
|
6
|
+
* approximation of the Planckian locus (valid 1667..25000 K); `tint` moves its `y` by 0.05 per
|
|
7
|
+
* unit (negative `y` shift = magenta). The matrix is the Bradford chromatic adaptation
|
|
8
|
+
* transform (Lam 1985, as used by ICC) from the 6500 K white to that target, wrapped in the
|
|
9
|
+
* sRGB (D65) ↔ XYZ matrices. At 6500 K / tint 0 source and target coincide and the matrix is
|
|
10
|
+
* the identity, so the default setting leaves every pixel as it was.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* CIE 1931 `xy` of a black body at `kelvin` (clamped to 1667..25000), written to `out[0..1]`
|
|
14
|
+
* (Kim et al. 2002).
|
|
15
|
+
*/
|
|
16
|
+
export declare function planckianXy(out: {
|
|
17
|
+
[i: number]: number;
|
|
18
|
+
}, kelvin: number): void;
|
|
19
|
+
/**
|
|
20
|
+
* Write the 3×3 row-major linear-sRGB white-balance matrix for `kelvin` and `tint` into `out`
|
|
21
|
+
* (9 numbers): `rgb' = M × rgb`. 6500 / 0 gives the identity. No allocation.
|
|
22
|
+
*/
|
|
23
|
+
export declare function whiteBalanceMatrix(out: {
|
|
24
|
+
[i: number]: number;
|
|
25
|
+
}, kelvin: number, tint: number): typeof out;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* White balance (ws/post-3): the 3×3 linear-sRGB matrix that tints an image toward the colour
|
|
3
|
+
* of a black body at a temperature, shifted green–magenta by a tint.
|
|
4
|
+
*
|
|
5
|
+
* Method: the target white's CIE 1931 chromaticity comes from the Kim et al. (2002) cubic
|
|
6
|
+
* approximation of the Planckian locus (valid 1667..25000 K); `tint` moves its `y` by 0.05 per
|
|
7
|
+
* unit (negative `y` shift = magenta). The matrix is the Bradford chromatic adaptation
|
|
8
|
+
* transform (Lam 1985, as used by ICC) from the 6500 K white to that target, wrapped in the
|
|
9
|
+
* sRGB (D65) ↔ XYZ matrices. At 6500 K / tint 0 source and target coincide and the matrix is
|
|
10
|
+
* the identity, so the default setting leaves every pixel as it was.
|
|
11
|
+
*/
|
|
12
|
+
/** Bradford cone response matrix (row-major 3×3) and its inverse. */
|
|
13
|
+
const BRADFORD = [0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296];
|
|
14
|
+
const BRADFORD_INV = [
|
|
15
|
+
0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428,
|
|
16
|
+
0.9684867,
|
|
17
|
+
];
|
|
18
|
+
/** Linear sRGB → XYZ (D65) and back, row-major. */
|
|
19
|
+
const XYZ_FROM_SRGB = [
|
|
20
|
+
0.4124564, 0.3575761, 0.1804375, 0.2126729, 0.7151522, 0.072175, 0.0193339, 0.119192, 0.9503041,
|
|
21
|
+
];
|
|
22
|
+
const SRGB_FROM_XYZ = [
|
|
23
|
+
3.2404542, -1.5371385, -0.4985314, -0.969266, 1.8760108, 0.041556, 0.0556434, -0.2040259,
|
|
24
|
+
1.0572252,
|
|
25
|
+
];
|
|
26
|
+
const scratchA = new Float64Array(9);
|
|
27
|
+
const scratchB = new Float64Array(9);
|
|
28
|
+
const srcLms = new Float64Array(3);
|
|
29
|
+
const dstLms = new Float64Array(3);
|
|
30
|
+
const srcWhite = new Float64Array(3);
|
|
31
|
+
const dstWhite = new Float64Array(3);
|
|
32
|
+
/**
|
|
33
|
+
* CIE 1931 `xy` of a black body at `kelvin` (clamped to 1667..25000), written to `out[0..1]`
|
|
34
|
+
* (Kim et al. 2002).
|
|
35
|
+
*/
|
|
36
|
+
export function planckianXy(out, kelvin) {
|
|
37
|
+
const t = Math.min(25000, Math.max(1667, kelvin));
|
|
38
|
+
const t2 = t * t;
|
|
39
|
+
const t3 = t2 * t;
|
|
40
|
+
const x = t <= 4000
|
|
41
|
+
? -0.2661239e9 / t3 - 0.2343589e6 / t2 + 0.8776956e3 / t + 0.17991
|
|
42
|
+
: -3.0258469e9 / t3 + 2.1070379e6 / t2 + 0.2226347e3 / t + 0.24039;
|
|
43
|
+
const x2 = x * x;
|
|
44
|
+
const x3 = x2 * x;
|
|
45
|
+
let y;
|
|
46
|
+
if (t <= 2222)
|
|
47
|
+
y = -1.1063814 * x3 - 1.3481102 * x2 + 2.18555832 * x - 0.20219683;
|
|
48
|
+
else if (t <= 4000)
|
|
49
|
+
y = -0.9549476 * x3 - 1.37418593 * x2 + 2.09137015 * x - 0.16748867;
|
|
50
|
+
else
|
|
51
|
+
y = 3.081758 * x3 - 5.8733867 * x2 + 3.75112997 * x - 0.37001483;
|
|
52
|
+
out[0] = x;
|
|
53
|
+
out[1] = y;
|
|
54
|
+
}
|
|
55
|
+
function xyToXyz(out, x, y) {
|
|
56
|
+
const yy = Math.max(y, 1e-4);
|
|
57
|
+
out[0] = x / yy;
|
|
58
|
+
out[1] = 1;
|
|
59
|
+
out[2] = (1 - x - yy) / yy;
|
|
60
|
+
}
|
|
61
|
+
function mul3(out, a, b) {
|
|
62
|
+
for (let r = 0; r < 3; r++) {
|
|
63
|
+
for (let c = 0; c < 3; c++) {
|
|
64
|
+
out[r * 3 + c] = a[r * 3] * b[c] + a[r * 3 + 1] * b[3 + c] + a[r * 3 + 2] * b[6 + c];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
function apply3(out, m, v) {
|
|
70
|
+
out[0] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2];
|
|
71
|
+
out[1] = m[3] * v[0] + m[4] * v[1] + m[5] * v[2];
|
|
72
|
+
out[2] = m[6] * v[0] + m[7] * v[1] + m[8] * v[2];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Write the 3×3 row-major linear-sRGB white-balance matrix for `kelvin` and `tint` into `out`
|
|
76
|
+
* (9 numbers): `rgb' = M × rgb`. 6500 / 0 gives the identity. No allocation.
|
|
77
|
+
*/
|
|
78
|
+
export function whiteBalanceMatrix(out, kelvin, tint) {
|
|
79
|
+
planckianXy(srcWhite, 6500);
|
|
80
|
+
xyToXyz(srcWhite, srcWhite[0], srcWhite[1]);
|
|
81
|
+
planckianXy(dstWhite, kelvin);
|
|
82
|
+
xyToXyz(dstWhite, dstWhite[0], dstWhite[1] - 0.05 * Math.min(1, Math.max(-1, tint)));
|
|
83
|
+
apply3(srcLms, BRADFORD, srcWhite);
|
|
84
|
+
apply3(dstLms, BRADFORD, dstWhite);
|
|
85
|
+
// A = Bradford⁻¹ × diag(dst / src) × Bradford.
|
|
86
|
+
for (let r = 0; r < 3; r++) {
|
|
87
|
+
const k = dstLms[r] / srcLms[r];
|
|
88
|
+
scratchA[r * 3] = BRADFORD[r * 3] * k;
|
|
89
|
+
scratchA[r * 3 + 1] = BRADFORD[r * 3 + 1] * k;
|
|
90
|
+
scratchA[r * 3 + 2] = BRADFORD[r * 3 + 2] * k;
|
|
91
|
+
}
|
|
92
|
+
mul3(scratchB, BRADFORD_INV, scratchA); // A in XYZ
|
|
93
|
+
mul3(scratchA, scratchB, XYZ_FROM_SRGB); // A × XYZ_from_sRGB
|
|
94
|
+
mul3(scratchB, SRGB_FROM_XYZ, scratchA); // sRGB_from_XYZ × ...
|
|
95
|
+
for (let i = 0; i < 9; i++)
|
|
96
|
+
out[i] = scratchB[i];
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type SamplerKind, type TextureLike } from './texture.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shared "uniform + sampler + N textures" binding convention used by materials (group 1) and
|
|
4
|
+
* fullscreen passes (group 0):
|
|
5
|
+
*
|
|
6
|
+
* - `@binding(0)` `var<uniform>`: present when `uniformBytes > 0`
|
|
7
|
+
* - `@binding(1)` `sampler`: present when `textures > 0`
|
|
8
|
+
* - `@binding(2 + i)` `texture_2d<f32>`: one per texture slot (`texture_2d_array<f32>` for a
|
|
9
|
+
* slot whose `viewDimension` is `'2d-array'`)
|
|
10
|
+
* - `@binding(16 + i)` (`BUFFER_BINDING_BASE`) `var<storage, read>`: one per `buffers` entry
|
|
11
|
+
*/
|
|
12
|
+
export interface BindingDesc {
|
|
13
|
+
uniformBytes?: number;
|
|
14
|
+
textures?: number;
|
|
15
|
+
sampler?: SamplerKind;
|
|
16
|
+
/**
|
|
17
|
+
* View dimension of the texture slots: one value for every slot, or one per slot. Default
|
|
18
|
+
* `'2d'`. Use `'2d-array'` to bind a texture array (`createTextureArray` /
|
|
19
|
+
* `loadTextureArray`) as `texture_2d_array<f32>`; an array slot left unbound reads a
|
|
20
|
+
* 1-layer white array.
|
|
21
|
+
*/
|
|
22
|
+
viewDimension?: GPUTextureViewDimension | readonly GPUTextureViewDimension[];
|
|
23
|
+
/** Which stages see the bindings. Default fragment + vertex. */
|
|
24
|
+
visibility?: GPUShaderStageFlags;
|
|
25
|
+
/**
|
|
26
|
+
* Read-only storage buffers, bound whole at `@binding(BUFFER_BINDING_BASE + i)` (a
|
|
27
|
+
* `SkinPalette.buffer`, a lookup table). Swap one later with `BindingSet.setBuffer`.
|
|
28
|
+
*/
|
|
29
|
+
buffers?: readonly GPUBuffer[];
|
|
30
|
+
}
|
|
31
|
+
/** First binding of `BindingDesc.buffers` (textures stop at 15, so up to 14 texture slots). */
|
|
32
|
+
export declare const BUFFER_BINDING_BASE = 16;
|
|
33
|
+
/** Extra `BindingSet` behaviour. */
|
|
34
|
+
export interface BindingSetOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Per-draw uniform blocks: the uniform binding uses a dynamic offset into a growable buffer.
|
|
37
|
+
* Slot 0 holds the shared block (`setUniforms`); `pushDrawUniforms` appends one block per
|
|
38
|
+
* draw for the current frame. Needs `uniformBytes > 0`.
|
|
39
|
+
*/
|
|
40
|
+
perDraw?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function hasBindings(desc: BindingDesc): boolean;
|
|
43
|
+
/** The view dimension of texture slot `slot` under `desc.viewDimension` (default `'2d'`). */
|
|
44
|
+
export declare function slotViewDimension(desc: BindingDesc, slot: number): GPUTextureViewDimension;
|
|
45
|
+
export declare function createBindingLayout(device: GPUDevice, desc: BindingDesc, label: string, dynamicUniform?: boolean): GPUBindGroupLayout;
|
|
46
|
+
/**
|
|
47
|
+
* Owns the uniform buffer + bind group for one binding set; rebuilds the group lazily.
|
|
48
|
+
* Bind groups for the last few texture sets are cached, so alternating textures (ping-pong)
|
|
49
|
+
* allocates nothing after the first round. Every texture slot starts bound to a 1×1 white
|
|
50
|
+
* texture (`defaultView`, or `defaultTextures(device).white` when none is given; a 1-layer white
|
|
51
|
+
* array for `'2d-array'` slots), so a material with four slots draws with none of them set;
|
|
52
|
+
* `setTexture` later rebuilds the group.
|
|
53
|
+
*/
|
|
54
|
+
export declare class BindingSet {
|
|
55
|
+
private readonly device;
|
|
56
|
+
private readonly sampler;
|
|
57
|
+
private readonly label;
|
|
58
|
+
readonly layout: GPUBindGroupLayout;
|
|
59
|
+
/** Replaced when a per-draw set grows. */
|
|
60
|
+
uniformBuffer: GPUBuffer | null;
|
|
61
|
+
/** True when the uniform binding takes a dynamic offset (see `BindingSetOptions.perDraw`). */
|
|
62
|
+
readonly perDraw: boolean;
|
|
63
|
+
/** Uniform block size in bytes (rounded up to 16), 0 when there is none. */
|
|
64
|
+
readonly blockBytes: number;
|
|
65
|
+
/** Byte distance between per-draw blocks (block size rounded up to the offset alignment). */
|
|
66
|
+
readonly stride: number;
|
|
67
|
+
private readonly views;
|
|
68
|
+
private readonly buffers;
|
|
69
|
+
private group;
|
|
70
|
+
private readonly cache;
|
|
71
|
+
private staging;
|
|
72
|
+
private stagingF32;
|
|
73
|
+
private drawSlots;
|
|
74
|
+
constructor(device: GPUDevice, desc: BindingDesc, sampler: GPUSampler, defaultView: GPUTextureView | null | undefined, label: string, opts?: BindingSetOptions);
|
|
75
|
+
setUniforms(data: BufferSource, byteOffset?: number): void;
|
|
76
|
+
/** Per-draw blocks recorded since the last flush. */
|
|
77
|
+
get drawCount(): number;
|
|
78
|
+
/**
|
|
79
|
+
* Stage one per-draw uniform block (f32s; the rest of the block reads 0) and return its
|
|
80
|
+
* dynamic offset. Uploaded by `flushDrawUniforms`, normally called by the renderer.
|
|
81
|
+
*/
|
|
82
|
+
pushDrawUniforms(data: ArrayLike<number>): number;
|
|
83
|
+
/** Upload this frame's per-draw blocks (growing the buffer if needed) and reset the count. */
|
|
84
|
+
flushDrawUniforms(): void;
|
|
85
|
+
/** Drop this frame's per-draw blocks without uploading. */
|
|
86
|
+
discardDrawUniforms(): void;
|
|
87
|
+
setTexture(slot: number, tex: TextureLike | GPUTextureView): void;
|
|
88
|
+
/** Rebind storage buffer slot `i` (`@binding(BUFFER_BINDING_BASE + i)`); groups rebuild lazily. */
|
|
89
|
+
setBuffer(slot: number, buffer: GPUBuffer): void;
|
|
90
|
+
/** Build a bind group for an explicit set of views (callers cache it). */
|
|
91
|
+
createGroup(views?: readonly GPUTextureView[]): GPUBindGroup;
|
|
92
|
+
get bindGroup(): GPUBindGroup;
|
|
93
|
+
destroy(): void;
|
|
94
|
+
private cachedGroup;
|
|
95
|
+
private stageShared;
|
|
96
|
+
private invalidateGroups;
|
|
97
|
+
private makeUniformBuffer;
|
|
98
|
+
}
|