melonjs 19.9.0 → 20.0.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/README.md +25 -14
- package/build/application/application.d.ts +70 -16
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +2 -2
- package/build/application/resize.d.ts.map +1 -1
- package/build/application/settings.d.ts +150 -53
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +13 -11
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/const.d.ts +55 -26
- package/build/const.d.ts.map +1 -1
- package/build/geometries/box3d.d.ts +156 -0
- package/build/geometries/box3d.d.ts.map +1 -0
- package/build/index.d.ts +33 -23
- package/build/index.d.ts.map +1 -1
- package/build/index.js +21696 -7831
- package/build/index.js.map +4 -4
- package/build/lang/deprecated.d.ts +4 -4
- package/build/lang/deprecated.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts +4 -0
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts +42 -6
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/gltf/srgb.d.ts +20 -0
- package/build/level/gltf/srgb.d.ts.map +1 -0
- package/build/level/level.d.ts +21 -2
- package/build/level/level.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts +61 -13
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/loader.d.ts +49 -21
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts.map +1 -1
- package/build/loader/parsers/mtl.d.ts +18 -0
- package/build/loader/parsers/mtl.d.ts.map +1 -1
- package/build/loader/parsers/obj.d.ts +49 -0
- package/build/loader/parsers/obj.d.ts.map +1 -1
- package/build/loader/parsers/pbr.d.ts +63 -0
- package/build/loader/parsers/pbr.d.ts.map +1 -0
- package/build/loader/parsers/shader.d.ts +32 -24
- package/build/loader/parsers/shader.d.ts.map +1 -1
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +3 -1
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +12 -1
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/broadphase/octree.d.ts +35 -0
- package/build/physics/broadphase/octree.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +123 -6
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts +12 -0
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/raycast.d.ts.map +1 -1
- package/build/physics/builtin/sat3d.d.ts +59 -0
- package/build/physics/builtin/sat3d.d.ts.map +1 -0
- package/build/physics/response.d.ts +32 -0
- package/build/physics/response.d.ts.map +1 -1
- package/build/physics/world.d.ts +1 -0
- package/build/physics/world.d.ts.map +1 -1
- package/build/renderable/container.d.ts +1 -0
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts.map +1 -1
- package/build/renderable/groundshadow.d.ts +92 -0
- package/build/renderable/groundshadow.d.ts.map +1 -0
- package/build/renderable/instanced_mesh.d.ts +286 -0
- package/build/renderable/instanced_mesh.d.ts.map +1 -0
- package/build/renderable/mesh.d.ts +242 -23
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/nineslicesprite.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +6 -4
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +3 -1
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +17 -6
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/state/stage.d.ts.map +1 -1
- package/build/system/device.d.ts +11 -40
- package/build/system/device.d.ts.map +1 -1
- package/build/system/platform.d.ts +0 -16
- package/build/system/platform.d.ts.map +1 -1
- package/build/utils/utils.d.ts +2 -0
- package/build/utils/utils.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +22 -16
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/{webgl/effects → effects}/blur.d.ts +2 -2
- package/build/video/effects/blur.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/chromaticAberration.d.ts +2 -2
- package/build/video/effects/chromaticAberration.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/colorMatrix.d.ts +3 -3
- package/build/video/effects/colorMatrix.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/desaturate.d.ts +1 -1
- package/build/video/effects/desaturate.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/dissolve.d.ts +2 -2
- package/build/video/effects/dissolve.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/dropShadow.d.ts +2 -2
- package/build/video/effects/dropShadow.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/flash.d.ts +2 -2
- package/build/video/effects/flash.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/glow.d.ts +2 -2
- package/build/video/effects/glow.d.ts.map +1 -0
- package/build/video/effects/glsl_realization.d.ts +18 -0
- package/build/video/effects/glsl_realization.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/hologram.d.ts +2 -2
- package/build/video/effects/hologram.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/invert.d.ts +1 -1
- package/build/video/effects/invert.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/outline.d.ts +2 -2
- package/build/video/effects/outline.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/pixelate.d.ts +2 -2
- package/build/video/effects/pixelate.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/radialGradient.d.ts +3 -4
- package/build/video/effects/radialGradient.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/scanline.d.ts +2 -2
- package/build/video/effects/scanline.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/sepia.d.ts +1 -1
- package/build/video/effects/sepia.d.ts.map +1 -0
- package/build/video/{webgl → effects}/shadereffect.d.ts +133 -25
- package/build/video/effects/shadereffect.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/shine.d.ts +2 -2
- package/build/video/effects/shine.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/tintPulse.d.ts +2 -2
- package/build/video/effects/tintPulse.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/vignette.d.ts +2 -2
- package/build/video/effects/vignette.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/wave.d.ts +2 -2
- package/build/video/effects/wave.d.ts.map +1 -0
- package/build/video/effects/wgsl/layout.d.ts +28 -0
- package/build/video/effects/wgsl/layout.d.ts.map +1 -0
- package/build/video/effects/wgsl/parse.d.ts +9 -0
- package/build/video/effects/wgsl/parse.d.ts.map +1 -0
- package/build/video/effects/wgsl/scaffold.d.ts +43 -0
- package/build/video/effects/wgsl/scaffold.d.ts.map +1 -0
- package/build/video/effects/wgsl_realization.d.ts +83 -0
- package/build/video/effects/wgsl_realization.d.ts.map +1 -0
- package/build/video/gpu/batcher.d.ts +71 -0
- package/build/video/gpu/batcher.d.ts.map +1 -0
- package/build/video/gpu/instancerecord.d.ts +164 -0
- package/build/video/gpu/instancerecord.d.ts.map +1 -0
- package/build/video/gpu/meshchunk.d.ts +49 -0
- package/build/video/gpu/meshchunk.d.ts.map +1 -0
- package/build/video/gpu/meshvertex.d.ts +54 -0
- package/build/video/gpu/meshvertex.d.ts.map +1 -0
- package/build/video/gpu/primitives.d.ts +60 -0
- package/build/video/gpu/primitives.d.ts.map +1 -0
- package/build/video/gpu/quadcorners.d.ts +11 -0
- package/build/video/gpu/quadcorners.d.ts.map +1 -0
- package/build/video/gpu/textureslots.d.ts +122 -0
- package/build/video/gpu/textureslots.d.ts.map +1 -0
- package/build/video/gpu/texturestore.d.ts +139 -0
- package/build/video/gpu/texturestore.d.ts.map +1 -0
- package/build/video/gpu/topology.d.ts +43 -0
- package/build/video/gpu/topology.d.ts.map +1 -0
- package/build/video/gpu/vertexformat.d.ts +72 -0
- package/build/video/gpu/vertexformat.d.ts.map +1 -0
- package/build/video/gradient.d.ts +14 -5
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +153 -8
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +7 -6
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +2 -2
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
- package/build/video/rendertarget/webglrendertarget.d.ts +38 -2
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webgpurendertarget.d.ts +83 -0
- package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -0
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +20 -2
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +2 -2
- package/build/video/utils/autodetect.d.ts.map +1 -1
- package/build/video/video.d.ts +1 -55
- package/build/video/video.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts +132 -35
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +14 -0
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +63 -36
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +29 -20
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +308 -14
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/primitive_batcher.d.ts +2 -2
- package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +1 -1
- package/build/video/webgl/buffer/instance_buffer.d.ts +54 -0
- package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -0
- package/build/video/webgl/buffer/retained_geometry.d.ts +83 -0
- package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -0
- package/build/video/webgl/buffer/uniformblock.d.ts +81 -0
- package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -0
- package/build/video/webgl/buffer/vertexstate.d.ts +101 -0
- package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -0
- package/build/video/webgl/glshader.d.ts +101 -8
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/lighting/constants.d.ts +20 -8
- package/build/video/webgl/lighting/constants.d.ts.map +1 -1
- package/build/video/webgl/lighting/pack.d.ts +1 -1
- package/build/video/webgl/lighting/pack3d.d.ts +27 -11
- package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
- package/build/video/webgl/lighting/std140.d.ts +110 -0
- package/build/video/webgl/lighting/std140.d.ts.map +1 -0
- package/build/video/webgl/shaders/multitexture-lit.d.ts +7 -3
- package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
- package/build/video/webgl/texture/store.d.ts +52 -0
- package/build/video/webgl/texture/store.d.ts.map +1 -0
- package/build/video/webgl/utils/maxtextures.d.ts +37 -0
- package/build/video/webgl/utils/maxtextures.d.ts.map +1 -0
- package/build/video/webgl/utils/samplercache.d.ts +69 -0
- package/build/video/webgl/utils/samplercache.d.ts.map +1 -0
- package/build/video/webgl/utils/string.d.ts +16 -0
- package/build/video/webgl/utils/string.d.ts.map +1 -1
- package/build/video/webgl/utils/topology.d.ts +24 -0
- package/build/video/webgl/utils/topology.d.ts.map +1 -0
- package/build/video/webgl/utils/vertexformat.d.ts +27 -0
- package/build/video/webgl/utils/vertexformat.d.ts.map +1 -0
- package/build/video/webgl/webgl_renderer.d.ts +148 -30
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +40 -0
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +82 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +301 -0
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/primitive_batcher.d.ts +39 -0
- package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts +143 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts +70 -0
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -0
- package/build/video/webgpu/buffer/arena.d.ts +64 -0
- package/build/video/webgpu/buffer/arena.d.ts.map +1 -0
- package/build/video/webgpu/buffer/instance_buffer.d.ts +65 -0
- package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -0
- package/build/video/webgpu/buffer/retained_geometry.d.ts +55 -0
- package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -0
- package/build/video/webgpu/buffer/uniformring.d.ts +68 -0
- package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -0
- package/build/video/webgpu/effect_binding.d.ts +17 -0
- package/build/video/webgpu/effect_binding.d.ts.map +1 -0
- package/build/video/webgpu/pipeline/bindgroups.d.ts +36 -0
- package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -0
- package/build/video/webgpu/pipeline/cache.d.ts +173 -0
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -0
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +90 -0
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -0
- package/build/video/webgpu/shaders/mesh-instanced.d.ts +60 -0
- package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -0
- package/build/video/webgpu/texture/compressed.d.ts +33 -0
- package/build/video/webgpu/texture/compressed.d.ts.map +1 -0
- package/build/video/webgpu/texture/frametexture.d.ts +65 -0
- package/build/video/webgpu/texture/frametexture.d.ts.map +1 -0
- package/build/video/webgpu/texture/store.d.ts +149 -0
- package/build/video/webgpu/texture/store.d.ts.map +1 -0
- package/build/video/webgpu/webgpu_renderer.d.ts +536 -0
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -0
- package/package.json +5 -5
- package/build/video/webgl/effects/blur.d.ts.map +0 -1
- package/build/video/webgl/effects/chromaticAberration.d.ts.map +0 -1
- package/build/video/webgl/effects/colorMatrix.d.ts.map +0 -1
- package/build/video/webgl/effects/desaturate.d.ts.map +0 -1
- package/build/video/webgl/effects/dissolve.d.ts.map +0 -1
- package/build/video/webgl/effects/dropShadow.d.ts.map +0 -1
- package/build/video/webgl/effects/flash.d.ts.map +0 -1
- package/build/video/webgl/effects/glow.d.ts.map +0 -1
- package/build/video/webgl/effects/hologram.d.ts.map +0 -1
- package/build/video/webgl/effects/invert.d.ts.map +0 -1
- package/build/video/webgl/effects/outline.d.ts.map +0 -1
- package/build/video/webgl/effects/pixelate.d.ts.map +0 -1
- package/build/video/webgl/effects/radialGradient.d.ts.map +0 -1
- package/build/video/webgl/effects/scanline.d.ts.map +0 -1
- package/build/video/webgl/effects/sepia.d.ts.map +0 -1
- package/build/video/webgl/effects/shine.d.ts.map +0 -1
- package/build/video/webgl/effects/tintPulse.d.ts.map +0 -1
- package/build/video/webgl/effects/vignette.d.ts.map +0 -1
- package/build/video/webgl/effects/wave.d.ts.map +0 -1
- package/build/video/webgl/shadereffect.d.ts.map +0 -1
|
@@ -2,9 +2,90 @@
|
|
|
2
2
|
* A simplified shader class for applying custom fragment effects to renderables.
|
|
3
3
|
* Only requires a fragment `apply()` function — the vertex shader, uniforms, and
|
|
4
4
|
* texture sampling boilerplate are handled automatically.
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* ## Dual-language bodies
|
|
7
|
+
*
|
|
8
|
+
* An effect body is written in the active renderer's shading language:
|
|
9
|
+
* GLSL on the WebGL renderer, WGSL on the WebGPU renderer. Pass a plain
|
|
10
|
+
* string for a GLSL-only effect (the historical form), or one body per
|
|
11
|
+
* language for an effect that runs on both backends:
|
|
12
|
+
*
|
|
13
|
+
* ```js
|
|
14
|
+
* new ShaderEffect(renderer, { glsl: glslBody, wgsl: wgslBody });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The renderer compiles the body matching its
|
|
18
|
+
* {@link Renderer#shaderLanguage}. When no matching body exists — a
|
|
19
|
+
* GLSL-only effect on the WebGPU renderer, any effect on the Canvas
|
|
20
|
+
* renderer — the effect warns once and stays **disabled**
|
|
21
|
+
* (`enabled === false`, every method a safe no-op): the scene renders
|
|
22
|
+
* without the effect, it never breaks.
|
|
23
|
+
*
|
|
24
|
+
* ## The WGSL convention
|
|
25
|
+
*
|
|
26
|
+
* A WGSL body mirrors the GLSL one — declarations plus an apply function,
|
|
27
|
+
* compiled verbatim inside engine boilerplate:
|
|
28
|
+
*
|
|
29
|
+
* - `fn apply(color : vec4f, uv : vec2f) -> vec4f` — required; receives
|
|
30
|
+
* the sampled, tinted pixel and its UV, returns the modified color.
|
|
31
|
+
* - Uniforms are the members of ONE struct bound as
|
|
32
|
+
* `@group(3) @binding(0) var<uniform> fx : MyUniforms;` — member names
|
|
33
|
+
* are the {@link ShaderEffect#setUniform} names, so a dual-language
|
|
34
|
+
* effect uses the same uniform names in both bodies and one
|
|
35
|
+
* `setUniform` call serves both. Supported member types: `f32`, `i32`,
|
|
36
|
+
* `u32`, `vec2f`, `vec3f`, `vec4f`, `mat3x3f`, `mat4x4f`,
|
|
37
|
+
* `array<vec4f, N>`.
|
|
38
|
+
* - Extra {@link ShaderEffect#setTexture} samplers are texture/sampler
|
|
39
|
+
* pairs at explicit consecutive group-3 bindings (from 1):
|
|
40
|
+
* `@group(3) @binding(1) var uNoise : texture_2d<f32>;`
|
|
41
|
+
* `@group(3) @binding(2) var uNoiseSampler : sampler;`
|
|
42
|
+
* - The source texture is available as `uTexture` with `uSampler`
|
|
43
|
+
* (`textureSample(uTexture, uSampler, uv)` — the WGSL spelling of
|
|
44
|
+
* GLSL's `texture2D(uSampler, uv)`), and the interpolated tint as
|
|
45
|
+
* `vColor`, under the same names as the GLSL side.
|
|
46
|
+
* - The shader builtins keep their names: `screen_uv`, `noise_uv`, and
|
|
47
|
+
* `screen_texture` — sampled through `screen_sampler` (clamped) or
|
|
48
|
+
* `screen_sampler_repeat` (wrapping), replacing the GLSL
|
|
49
|
+
* `: screen_texture(repeat)` annotation.
|
|
50
|
+
* - Porting note: a texture sampled after a non-uniform `return` or
|
|
51
|
+
* inside a varying branch must use
|
|
52
|
+
* `textureSampleLevel(uTexture, uSampler, uv, 0.0)` (a WGSL
|
|
53
|
+
* uniform-control-flow rule; identical output for sprite textures).
|
|
54
|
+
*
|
|
55
|
+
* ## Directional UV arithmetic (`uUVYDir`)
|
|
56
|
+
*
|
|
57
|
+
* The vertical orientation of `apply()`'s UV space depends on the draw
|
|
58
|
+
* path: sampling the sprite directly, `uv.y` grows downward, but the
|
|
59
|
+
* WebGL multi-effect (pooled) path composites through capture FBOs whose
|
|
60
|
+
* rows are bottom-up — there `uv.y` grows upward. A body that offsets its
|
|
61
|
+
* sampling coordinate vertically (a drop shadow, a directional smear)
|
|
62
|
+
* would render mirrored on that path. Declare a `float uUVYDir` uniform
|
|
63
|
+
* (WGSL: `uUVYDir : f32` in the uniform struct) and multiply vertical UV
|
|
64
|
+
* offsets by it: the renderer feeds `+1` where `uv.y` grows downward —
|
|
65
|
+
* including every WebGPU path — and `-1` on the WebGL pooled path, so
|
|
66
|
+
* "down" stays down everywhere. Initialize it to `1.0` with `setUniform`;
|
|
67
|
+
* bodies that don't declare it are unaffected. The built-in
|
|
68
|
+
* {@link DropShadowEffect} is the reference use.
|
|
6
69
|
* @category Rendering
|
|
7
70
|
* @example
|
|
71
|
+
* // one effect, both backends: dual-language body
|
|
72
|
+
* mySprite.shader = new ShaderEffect(renderer, {
|
|
73
|
+
* glsl: `
|
|
74
|
+
* uniform float uStrength;
|
|
75
|
+
* vec4 apply(vec4 color, vec2 uv) {
|
|
76
|
+
* return vec4(color.rgb * uStrength, color.a);
|
|
77
|
+
* }
|
|
78
|
+
* `,
|
|
79
|
+
* wgsl: `
|
|
80
|
+
* struct Fx { uStrength : f32, };
|
|
81
|
+
* @group(3) @binding(0) var<uniform> fx : Fx;
|
|
82
|
+
* fn apply(color : vec4f, uv : vec2f) -> vec4f {
|
|
83
|
+
* return vec4f(color.rgb * fx.uStrength, color.a);
|
|
84
|
+
* }
|
|
85
|
+
* `,
|
|
86
|
+
* });
|
|
87
|
+
* mySprite.shader.setUniform("uStrength", 0.5); // sets either backend
|
|
88
|
+
* @example
|
|
8
89
|
* // create a grayscale effect
|
|
9
90
|
* mySprite.shader = new ShaderEffect(renderer, `
|
|
10
91
|
* vec4 apply(vec4 color, vec2 uv) {
|
|
@@ -44,13 +125,21 @@
|
|
|
44
125
|
*/
|
|
45
126
|
export default class ShaderEffect {
|
|
46
127
|
/**
|
|
47
|
-
* @param {WebGLRenderer|CanvasRenderer} renderer - the current renderer instance
|
|
48
|
-
* @param {string
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
128
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
129
|
+
* @param {string|{glsl?: string, wgsl?: string}} body - the effect body:
|
|
130
|
+
* a GLSL string (containing a `vec4 apply(vec4 color, vec2 uv)` function —
|
|
131
|
+
* unchanged from previous versions), or an object carrying one body per
|
|
132
|
+
* shading language (`glsl` and/or `wgsl`, the WGSL body defining
|
|
133
|
+
* `fn apply(color : vec4f, uv : vec2f) -> vec4f`). The renderer picks the
|
|
134
|
+
* body matching its {@link Renderer#shaderLanguage}; when no matching body
|
|
135
|
+
* exists the effect warns once and stays disabled (`enabled === false`),
|
|
136
|
+
* exactly like the Canvas renderer.
|
|
137
|
+
* @param {string} [precision=auto detected] - float precision ('lowp', 'mediump' or 'highp'), GLSL only
|
|
52
138
|
*/
|
|
53
|
-
constructor(renderer: WebGLRenderer | CanvasRenderer,
|
|
139
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, body: string | {
|
|
140
|
+
glsl?: string;
|
|
141
|
+
wgsl?: string;
|
|
142
|
+
}, precision?: string);
|
|
54
143
|
/**
|
|
55
144
|
* whether this effect is active (false in Canvas mode, false after
|
|
56
145
|
* {@link destroy}, and false while the WebGL context is suspended
|
|
@@ -89,14 +178,25 @@ export default class ShaderEffect {
|
|
|
89
178
|
*/
|
|
90
179
|
_renderer: any;
|
|
91
180
|
/**
|
|
92
|
-
* the construction "recipe" (
|
|
181
|
+
* the construction "recipe" (body + precision), kept VERBATIM so
|
|
93
182
|
* {@link clone} can compile an independent copy. Stored before the
|
|
94
|
-
*
|
|
183
|
+
* disabled-stub early return so cloning behaves consistently there too.
|
|
95
184
|
* @ignore
|
|
96
185
|
*/
|
|
97
|
-
_fragmentBody: string
|
|
186
|
+
_fragmentBody: string | {
|
|
187
|
+
glsl?: string;
|
|
188
|
+
wgsl?: string;
|
|
189
|
+
};
|
|
98
190
|
/** @ignore */
|
|
99
191
|
_precision: string | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* extra texture samplers bound via {@link setTexture}, keyed by the
|
|
194
|
+
* uniform name → `{ image, repeat, tex }` (`tex` is the uploaded GL
|
|
195
|
+
* texture, created lazily on first draw; unused on WebGPU, where the
|
|
196
|
+
* bind group is built lazily instead)
|
|
197
|
+
* @ignore
|
|
198
|
+
*/
|
|
199
|
+
_extraTextures: Map<any, any> | undefined;
|
|
100
200
|
/**
|
|
101
201
|
* samplers annotated `: screen_texture` — the renderer checks this to
|
|
102
202
|
* know when to refresh the shared frame capture before the effect draws
|
|
@@ -108,16 +208,11 @@ export default class ShaderEffect {
|
|
|
108
208
|
repeat: string;
|
|
109
209
|
}>;
|
|
110
210
|
/** @ignore */
|
|
111
|
-
_hasNoiseUV:
|
|
211
|
+
_hasNoiseUV: any;
|
|
112
212
|
/** @ignore */
|
|
113
213
|
_shader: GLShader | undefined;
|
|
114
|
-
/**
|
|
115
|
-
|
|
116
|
-
* uniform name → `{ image, repeat, tex }` (`tex` is the uploaded GL
|
|
117
|
-
* texture, created lazily on first draw)
|
|
118
|
-
* @ignore
|
|
119
|
-
*/
|
|
120
|
-
_extraTextures: Map<any, any> | undefined;
|
|
214
|
+
/** @ignore */
|
|
215
|
+
wgslRealization: WGSLEffectRealization | undefined;
|
|
121
216
|
/** @private */
|
|
122
217
|
private _onContextLost;
|
|
123
218
|
_enabledBeforeSuspend: boolean | undefined;
|
|
@@ -153,6 +248,20 @@ export default class ShaderEffect {
|
|
|
153
248
|
* flow.setTime(me.timer.getTime() / 1000);
|
|
154
249
|
*/
|
|
155
250
|
setTime(seconds: number): ShaderEffect;
|
|
251
|
+
/**
|
|
252
|
+
* Feed the UV y-direction of the space `apply()` is about to run in:
|
|
253
|
+
* `+1` where `uv.y` grows downward (direct sprite sampling, and every
|
|
254
|
+
* WebGPU path), `-1` on the WebGL pooled-blit path, whose capture FBOs
|
|
255
|
+
* are bottom-up — there, y-directional UV arithmetic inside a body
|
|
256
|
+
* runs vertically mirrored unless compensated. Directional bodies
|
|
257
|
+
* (DropShadow) declare a `uUVYDir` uniform and multiply their y
|
|
258
|
+
* offsets with it, so "down" means down on every path of every
|
|
259
|
+
* backend. A silent no-op for bodies that don't declare the uniform.
|
|
260
|
+
* @param {number} dir - +1 (uv.y grows downward) or -1 (upward)
|
|
261
|
+
* @ignore
|
|
262
|
+
*/
|
|
263
|
+
_setUVYDir(dir: number): void;
|
|
264
|
+
_uvYDir: any;
|
|
156
265
|
/**
|
|
157
266
|
* Feed the `noise_uv` builtin's frame rect for the object about to draw:
|
|
158
267
|
* the source texture dimensions, the destination (object) dimensions, and
|
|
@@ -170,14 +279,12 @@ export default class ShaderEffect {
|
|
|
170
279
|
_setNoiseUVRect(sourceWidth: number, sourceHeight: number, objectWidth: number, objectHeight: number, u0: number, v0: number): void;
|
|
171
280
|
/**
|
|
172
281
|
* Apply the wrap mode a `: screen_texture(<repeat>)` annotation asked for
|
|
173
|
-
* onto the live capture handle.
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* redundant while the GL active unit points elsewhere.
|
|
282
|
+
* onto the live capture handle. The unit is force-activated first: the
|
|
283
|
+
* batcher's bind may have been skipped as redundant while the GL active
|
|
284
|
+
* unit points elsewhere.
|
|
177
285
|
* @ignore
|
|
178
286
|
*/
|
|
179
287
|
_applyCaptureWrap(batcher: any, glTex: any, entry: any): void;
|
|
180
|
-
_captureWrapWarned: boolean | undefined;
|
|
181
288
|
/**
|
|
182
289
|
* Bind an **extra** texture to a named `sampler2D` uniform in this shader, so
|
|
183
290
|
* a custom effect can read a *second* texture — a noise map, mask, gradient,
|
|
@@ -192,7 +299,7 @@ export default class ShaderEffect {
|
|
|
192
299
|
* drawable source. No-op in Canvas mode.
|
|
193
300
|
* @param {string} name - the `sampler2D` uniform name declared in the fragment
|
|
194
301
|
* @param {Texture2d|HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - the texture: an engine texture asset, or a raw drawable source
|
|
195
|
-
* @param {"repeat"|"repeat-x"|"repeat-y"|"no-repeat"} [repeat="no-repeat"] - wrap mode; use `"repeat"` for a tiled/scrolled texture
|
|
302
|
+
* @param {"repeat"|"repeat-x"|"repeat-y"|"no-repeat"} [repeat="no-repeat"] - wrap mode; use `"repeat"` for a tiled/scrolled texture
|
|
196
303
|
* @returns {ShaderEffect} this effect for chaining
|
|
197
304
|
* @example
|
|
198
305
|
* // "water": distort the sprite by a static noise texture scrolled over time
|
|
@@ -269,6 +376,7 @@ export default class ShaderEffect {
|
|
|
269
376
|
*/
|
|
270
377
|
destroy(): void;
|
|
271
378
|
}
|
|
272
|
-
import GLShader from "
|
|
379
|
+
import GLShader from "../webgl/glshader.js";
|
|
380
|
+
import WGSLEffectRealization from "./wgsl_realization.js";
|
|
273
381
|
import Texture2d from "../texture/texture2d.ts";
|
|
274
382
|
//# sourceMappingURL=shadereffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadereffect.d.ts","sourceRoot":"","sources":["../../../src/video/effects/shadereffect.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4HG;AACH;IAiCC;;;;;;;;;;;OAWG;IACH,sBAXW,aAAa,GAAC,cAAc,GAAC,cAAc,QAC3C,MAAM,GAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,cAQrC,MAAM,EAqHhB;IA/JD;;;;;;OAMG;IACH,SAFU,OAAO,CAED;IAEhB;;;;;;;OAOG;IACH,oBAHU,OAAO,CAGC;IAElB;;;;;;;;;;OAUG;IACH,QAHU,OAAO,CAGF;IAed;;;;;;OAMG;IACH,eAAyB;IAEzB;;;;;OAKG;IACH;eA1ByB,MAAM;eAAS,MAAM;MA0BrB;IACzB,cAAc;IACd,+BAA2B;IAoB3B;;;;;;OAMG;IACH,0CAA+B;IAQ9B;;;;;OAKG;IACH,wBAHU,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAGK;IACpD,cAAc;IACd,iBAAkC;IAElC,cAAc;IACd,8BAKC;IAyBD,cAAc;IACd,mDAAkC;IAsBpC,eAAe;IACf,uBAkBC;IAbA,2CAAyC;IAe1C,eAAe;IACf,2BAQC;IAED;;;;OAIG;IACH,iBAHW,MAAM,SACN,MAAM,GAAC,YAAY,QAmB7B;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,iBAbW,MAAM,GACJ,YAAY,CAuCxB;IAED;;;;;;;;;;;OAWG;IACH,gBAHW,MAAM,QAqBhB;IATC,aAAkB;IAWpB;;;;;;;;;;;;;OAaG;IACH,6BARW,MAAM,gBACN,MAAM,eACN,MAAM,gBACN,MAAM,MACN,MAAM,MACN,MAAM,QAoDhB;IAED;;;;;;OAMG;IACH,8DAaC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,iBAnBW,MAAM,SACN,SAAS,GAAC,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,WACxE,QAAQ,GAAC,UAAU,GAAC,UAAU,GAAC,WAAW,GACxC,YAAY,CA0GxB;IAED;;;;;;;;OAQG;IACH,0BAHW,MAAM,QA2FhB;IA3DI,4CAAkC;IA6DvC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,SARa,YAAY,CAqDxB;IAKD,cAAc;IACd,aAIC;IAED,cAAc;IACd,qCAIC;IAED,cAAc;IACd,iEAIC;IAED,cAAc;IACd,mCAEC;IAED,cAAc;IACd,kBAEC;IAED,cAAc;IACd,oBAEC;IAED,cAAc;IACd,qBAEC;IAED,cAAc;IACd,uBAEC;IAED;;;;OAIG;IACH,gBAyCC;CACD;qBA34BoB,sBAAsB;kCAET,uBAAuB;sBAHnC,yBAAyB"}
|
|
@@ -47,7 +47,7 @@ export default class ShineEffect extends ShaderEffect {
|
|
|
47
47
|
* @param {number} [options.pulseDepth=0.0] - subtle base-brightness pulse amplitude (0 disables the pulse)
|
|
48
48
|
* @param {number} [options.pulseSpeed=3.0] - pulse oscillation rate (radians/second)
|
|
49
49
|
*/
|
|
50
|
-
constructor(renderer:
|
|
50
|
+
constructor(renderer: any, options?: {
|
|
51
51
|
color?: number[] | undefined;
|
|
52
52
|
speed?: number | undefined;
|
|
53
53
|
width?: number | undefined;
|
|
@@ -78,5 +78,5 @@ export default class ShineEffect extends ShaderEffect {
|
|
|
78
78
|
*/
|
|
79
79
|
setBands(value: number): void;
|
|
80
80
|
}
|
|
81
|
-
import ShaderEffect from "
|
|
81
|
+
import ShaderEffect from "./shadereffect.js";
|
|
82
82
|
//# sourceMappingURL=shine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shine.d.ts","sourceRoot":"","sources":["../../../src/video/effects/shine.js"],"names":[],"mappings":"AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;IACC;;;;;;;;;;;OAWG;IACH,qCATG;QAA2B,KAAK;QACP,KAAK;QACL,KAAK;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,UAAU;QACV,UAAU;KACrC,EAgEA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,oBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;CACD;yBA5LwB,mBAAmB"}
|
|
@@ -23,7 +23,7 @@ export default class TintPulseEffect extends ShaderEffect {
|
|
|
23
23
|
* @param {number} [options.speed=2.0] - pulse speed (oscillations per second)
|
|
24
24
|
* @param {number} [options.intensity=0.3] - maximum tint strength (0.0–1.0)
|
|
25
25
|
*/
|
|
26
|
-
constructor(renderer:
|
|
26
|
+
constructor(renderer: any, options?: {
|
|
27
27
|
color?: number[] | undefined;
|
|
28
28
|
speed?: number | undefined;
|
|
29
29
|
intensity?: number | undefined;
|
|
@@ -39,5 +39,5 @@ export default class TintPulseEffect extends ShaderEffect {
|
|
|
39
39
|
*/
|
|
40
40
|
setColor(color: number[]): void;
|
|
41
41
|
}
|
|
42
|
-
import ShaderEffect from "
|
|
42
|
+
import ShaderEffect from "./shadereffect.js";
|
|
43
43
|
//# sourceMappingURL=tintPulse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tintPulse.d.ts","sourceRoot":"","sources":["../../../src/video/effects/tintPulse.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;;;;;OAMG;IACH,qCAJG;QAA2B,KAAK;QACP,KAAK;QACL,SAAS;KACpC,EAqBA;IAED;;;OAGG;IACH,cAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBAjFwB,mBAAmB"}
|
|
@@ -21,7 +21,7 @@ export default class VignetteEffect extends ShaderEffect {
|
|
|
21
21
|
* @param {number} [options.strength=0.15] - edge darkening power (lower = stronger darkening, higher = softer falloff)
|
|
22
22
|
* @param {number} [options.size=25.0] - vignette spread multiplier (higher = smaller dark area)
|
|
23
23
|
*/
|
|
24
|
-
constructor(renderer:
|
|
24
|
+
constructor(renderer: any, options?: {
|
|
25
25
|
strength?: number | undefined;
|
|
26
26
|
size?: number | undefined;
|
|
27
27
|
});
|
|
@@ -38,5 +38,5 @@ export default class VignetteEffect extends ShaderEffect {
|
|
|
38
38
|
*/
|
|
39
39
|
setSize(size: number): void;
|
|
40
40
|
}
|
|
41
|
-
import ShaderEffect from "
|
|
41
|
+
import ShaderEffect from "./shadereffect.js";
|
|
42
42
|
//# sourceMappingURL=vignette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vignette.d.ts","sourceRoot":"","sources":["../../../src/video/effects/vignette.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;;;OAKG;IACH,qCAHG;QAAyB,QAAQ;QACR,IAAI;KAC/B,EASA;IALA,iBAAwC;IACxC,aAAgC;IAMjC;;;OAGG;IACH,sBAFW,MAAM,QAKhB;IAED;;;OAGG;IACH,cAFW,MAAM,QAKhB;CACD;yBA/EwB,mBAAmB"}
|
|
@@ -18,7 +18,7 @@ export default class WaveEffect extends ShaderEffect {
|
|
|
18
18
|
* @param {number} [options.frequency=10.0] - number of waves across the sprite
|
|
19
19
|
* @param {number} [options.speed=2.0] - wave animation speed
|
|
20
20
|
*/
|
|
21
|
-
constructor(renderer:
|
|
21
|
+
constructor(renderer: any, options?: {
|
|
22
22
|
amplitude?: number | undefined;
|
|
23
23
|
frequency?: number | undefined;
|
|
24
24
|
speed?: number | undefined;
|
|
@@ -39,5 +39,5 @@ export default class WaveEffect extends ShaderEffect {
|
|
|
39
39
|
*/
|
|
40
40
|
setFrequency(frequency: number): void;
|
|
41
41
|
}
|
|
42
|
-
import ShaderEffect from "
|
|
42
|
+
import ShaderEffect from "./shadereffect.js";
|
|
43
43
|
//# sourceMappingURL=wave.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wave.d.ts","sourceRoot":"","sources":["../../../src/video/effects/wave.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;GAWG;AACH;IACC;;;;;;OAMG;IACH,qCAJG;QAAyB,SAAS;QACT,SAAS;QACT,KAAK;KAChC,EAqBA;IAED;;;OAGG;IACH,cAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAIhB;CACD;yBArFwB,mBAAmB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* normalize the `vecN<f32>` / `matCxR<f32>` spellings onto the short forms
|
|
3
|
+
* used as TYPE_LAYOUT keys
|
|
4
|
+
* @param {string} type - a WGSL type token
|
|
5
|
+
* @returns {string} the canonical spelling
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeWGSLType(type: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Compute the uniform-buffer layout for a parsed struct member list.
|
|
11
|
+
* @param {Array<{name: string, type: string}>} members - struct members in declaration order
|
|
12
|
+
* @returns {{map: Map<string, {offset: number, size: number, type: string}>, size: number}|null}
|
|
13
|
+
* the name → placement map and the total (16-byte-rounded) struct size,
|
|
14
|
+
* or `null` when a member type is unsupported
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
export function computeUniformLayout(members: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
}>): {
|
|
21
|
+
map: Map<string, {
|
|
22
|
+
offset: number;
|
|
23
|
+
size: number;
|
|
24
|
+
type: string;
|
|
25
|
+
}>;
|
|
26
|
+
size: number;
|
|
27
|
+
} | null;
|
|
28
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../src/video/effects/wgsl/layout.js"],"names":[],"mappings":"AAqCA;;;;;;GAMG;AACH,wCAJW,MAAM,GACJ,MAAM,CAQlB;AAUD;;;;;;;GAOG;AACH,8CANW,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,GACjC;IAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAC,IAAI,CAuB/F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a WGSL effect body's declarations.
|
|
3
|
+
* @param {string} body - the user WGSL body
|
|
4
|
+
* @returns {object} `{ok: true, layout, structSize, uniformVar, textures, builtins, maxUserBinding}`
|
|
5
|
+
* or `{ok: false, error}`
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
export function parseWGSLBody(body: string): object;
|
|
9
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../src/video/effects/wgsl/parse.js"],"names":[],"mappings":"AAoHA;;;;;;GAMG;AACH,oCALW,MAAM,GACJ,MAAM,CAqKlB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WGSL module assembly for a ShaderEffect body — the WGSL counterpart of
|
|
3
|
+
* `glsl_realization.js`'s source templating. The user body is embedded
|
|
4
|
+
* VERBATIM (WGSL module-scope declarations are order-independent); the
|
|
5
|
+
* scaffold contributes the vertex/fragment entry points over the frozen
|
|
6
|
+
* 28-byte quad layout, the frame-globals and material groups, and the
|
|
7
|
+
* builtin declarations the parser detected.
|
|
8
|
+
*
|
|
9
|
+
* Frozen conventions carried over from the core quad shader:
|
|
10
|
+
* - clip-z remap `(z + w) * 0.5` (GL-convention [-w, w] → WebGPU [0, w])
|
|
11
|
+
* - packed-ARGB attribute read as (B,G,R,A) → `.bgr * .a` premultiply
|
|
12
|
+
* - `screen_uv` is y-down (`0.5 - ndc.y * 0.5`): WebGPU texture row 0 is
|
|
13
|
+
* the top, so the capture is sampled without any flip
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* builtin group-3 bindings are assigned ABOVE the highest user binding so
|
|
18
|
+
* they can never collide: ME uniform first, then the capture texture and
|
|
19
|
+
* its sampler variants
|
|
20
|
+
* @param {object} parsed - the parseWGSLBody result
|
|
21
|
+
* @returns {{me: number, screenTexture: number, screenSamplerClamp: number, screenSamplerRepeat: number}}
|
|
22
|
+
* assigned binding indices (-1 when the builtin is unused)
|
|
23
|
+
* @ignore
|
|
24
|
+
*/
|
|
25
|
+
export function assignBuiltinBindings(parsed: object): {
|
|
26
|
+
me: number;
|
|
27
|
+
screenTexture: number;
|
|
28
|
+
screenSamplerClamp: number;
|
|
29
|
+
screenSamplerRepeat: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Assemble the complete WGSL module for an effect body.
|
|
33
|
+
* @param {string} body - the user WGSL body (embedded verbatim)
|
|
34
|
+
* @param {object} parsed - the parseWGSLBody result
|
|
35
|
+
* @returns {{code: string, bindings: object}} the module text and the
|
|
36
|
+
* builtin binding assignment (consumed when building the bind group)
|
|
37
|
+
* @ignore
|
|
38
|
+
*/
|
|
39
|
+
export function buildWGSLModule(body: string, parsed: object): {
|
|
40
|
+
code: string;
|
|
41
|
+
bindings: object;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=scaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../../../src/video/effects/wgsl/scaffold.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;GAQG;AACH,8CALW,MAAM,GACJ;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAC,CA0BxG;AAED;;;;;;;GAOG;AACH,sCANW,MAAM,UACN,MAAM,GACJ;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAyG5C"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WGSL realization of a ShaderEffect — the WebGPU counterpart of the
|
|
3
|
+
* GLShader the GLSL branch compiles.
|
|
4
|
+
*
|
|
5
|
+
* WebGPU has no uniform reflection, so this object carries everything the
|
|
6
|
+
* backend needs to drive the effect: the parsed uniform layout (name →
|
|
7
|
+
* byte placement), a CPU-side mirror of the uniform block that
|
|
8
|
+
* `setUniform` writes into, the texture binding table, and the assembled
|
|
9
|
+
* module text. GPU objects (shader module, bind group layout, bind group)
|
|
10
|
+
* are built lazily by the renderer's effect path — uniform VALUES are
|
|
11
|
+
* snapshotted from the mirror into a per-frame arena at every bind, so a
|
|
12
|
+
* shared effect bound twice in a frame with different values stays
|
|
13
|
+
* correct under WebGPU's queue-write-before-draws ordering.
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
export default class WGSLEffectRealization {
|
|
17
|
+
/**
|
|
18
|
+
* Parse + assemble; on any parse failure `valid` is false and `error`
|
|
19
|
+
* carries the reason (the effect then warns and stays disabled).
|
|
20
|
+
* @param {string} body - the user WGSL body
|
|
21
|
+
*/
|
|
22
|
+
constructor(body: string);
|
|
23
|
+
/**
|
|
24
|
+
* whether the body parsed into a realizable shape
|
|
25
|
+
* @type {boolean}
|
|
26
|
+
*/
|
|
27
|
+
valid: boolean;
|
|
28
|
+
/** @type {string|null} */
|
|
29
|
+
error: string | null;
|
|
30
|
+
/** name → {offset, size, type} placement in the uniform block */
|
|
31
|
+
layout: any;
|
|
32
|
+
/** total uniform block byte size (0 = no uniform struct) */
|
|
33
|
+
structSize: any;
|
|
34
|
+
/** user texture/sampler pairs (binding table) */
|
|
35
|
+
textures: any;
|
|
36
|
+
/** builtin usage flags */
|
|
37
|
+
builtins: any;
|
|
38
|
+
/** the complete assembled WGSL module text */
|
|
39
|
+
code: string | undefined;
|
|
40
|
+
/** builtin binding assignment (ME / capture texture / samplers) */
|
|
41
|
+
builtinBindings: object | undefined;
|
|
42
|
+
cpu: ArrayBuffer | undefined;
|
|
43
|
+
f32: Float32Array<ArrayBuffer> | undefined;
|
|
44
|
+
i32: Int32Array<ArrayBuffer> | undefined;
|
|
45
|
+
u32: Uint32Array<ArrayBuffer> | undefined;
|
|
46
|
+
meMirror: Float32Array<ArrayBuffer> | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* last user-set value per uniform name — the clone-replay source
|
|
49
|
+
* (exact values, not mirror read-back)
|
|
50
|
+
* @type {Map<string, number|number[]>}
|
|
51
|
+
*/
|
|
52
|
+
values: Map<string, number | number[]>;
|
|
53
|
+
warned: Set<any> | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* device-scoped GPU state, built lazily by the renderer's effect
|
|
56
|
+
* path and invalidated via the pipeline-cache epoch (device loss)
|
|
57
|
+
* @type {object|null}
|
|
58
|
+
*/
|
|
59
|
+
gpu: object | null;
|
|
60
|
+
/**
|
|
61
|
+
* Write a uniform value into the CPU mirror.
|
|
62
|
+
* @param {string} name - a struct member name of the body's uniform block
|
|
63
|
+
* @param {number|number[]|Float32Array|{val: Float32Array}} value - the value
|
|
64
|
+
* (objects exposing `.val` — Matrix2d/3d, ColorMatrix — are unwrapped)
|
|
65
|
+
* @returns {boolean} true when the name exists and the value was written
|
|
66
|
+
*/
|
|
67
|
+
setUniform(name: string, value: number | number[] | Float32Array | {
|
|
68
|
+
val: Float32Array;
|
|
69
|
+
}): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* whether the uniform block declares the given member (the WGSL
|
|
72
|
+
* counterpart of the GLSL active-uniform check `setTime` relies on)
|
|
73
|
+
* @param {string} name - member name
|
|
74
|
+
* @returns {boolean} true when present
|
|
75
|
+
*/
|
|
76
|
+
hasUniform(name: string): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* drop device-scoped state (device loss / destroy) — the CPU mirror
|
|
79
|
+
* and values survive, so nothing needs replaying on restore
|
|
80
|
+
*/
|
|
81
|
+
releaseGPU(): void;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=wgsl_realization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgsl_realization.d.ts","sourceRoot":"","sources":["../../../src/video/effects/wgsl_realization.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;OAIG;IACH,kBAFW,MAAM,EA2DhB;IAtDA;;;OAGG;IACH,OAFU,OAAO,CAEc;IAC/B,0BAA0B;IAC1B,OADW,MAAM,GAAC,IAAI,CAC+B;IAMrD,iEAAiE;IACjE,YAA2B;IAC3B,4DAA4D;IAC5D,gBAAmC;IACnC,iDAAiD;IACjD,cAA+B;IAC/B,0BAA0B;IAC1B,cAA+B;IAG/B,8CAA8C;IAC9C,yBAAuB;IACvB,mEAAmE;IACnE,oCAAsC;IAGtC,6BAAwD;IACxD,2CAAqC;IACrC,yCAAmC;IACnC,0CAAoC;IAIpC,gDAAmC;IAEnC;;;;OAIG;IACH,QAFU,GAAG,CAAC,MAAM,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,CAEf;IAIvB,6BAAuB;IAEvB;;;;OAIG;IACH,KAFU,MAAM,GAAC,IAAI,CAEN;IAGhB;;;;;;OAMG;IACH,iBALW,MAAM,SACN,MAAM,GAAC,MAAM,EAAE,GAAC,YAAY,GAAC;QAAC,GAAG,EAAE,YAAY,CAAA;KAAC,GAE9C,OAAO,CAwDnB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,mBAEC;CACD"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* additional import for TypeScript
|
|
3
|
+
* @import Renderer from "../renderer.js";
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Default maximum number of vertices per batch.
|
|
7
|
+
* At 4096 vertices (1024 quads), the vertex buffer is ~80 KB (5 floats × 4 bytes × 4096),
|
|
8
|
+
* which balances draw call reduction with safe buffer upload sizes on mobile tile-based GPUs.
|
|
9
|
+
* Within the Uint16 index limit (65,535) — a deliberate capacity choice
|
|
10
|
+
* (smaller index uploads), not an API constraint.
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_MAX_VERTICES: 4096;
|
|
14
|
+
/**
|
|
15
|
+
* Backend-neutral base class for renderer batchers.
|
|
16
|
+
*
|
|
17
|
+
* A batcher accumulates vertices into a CPU staging buffer and turns them
|
|
18
|
+
* into GPU work in batches — one draw call for many shapes/sprites. This
|
|
19
|
+
* class defines the lifecycle contract shared by every backend:
|
|
20
|
+
*
|
|
21
|
+
* - `init(renderer, settings)` — build (or rebuild after a context/device
|
|
22
|
+
* loss) the batcher's GPU-facing state; called by the constructor
|
|
23
|
+
* - `bind()` / `unbind()` — the renderer switches the active batcher
|
|
24
|
+
* - `flush()` — turn the pending vertices into GPU work
|
|
25
|
+
* - `reset()` — drop transient state (game reset / context restore)
|
|
26
|
+
* - `destroy()` — release every GPU resource the batcher owns
|
|
27
|
+
*
|
|
28
|
+
* Custom batchers extend the class matching the renderer they target —
|
|
29
|
+
* {@link WebGLBatcher} for the WebGL renderer, `WebGPUBatcher` for the
|
|
30
|
+
* WebGPU renderer — and are registered through `renderer.addBatcher()`,
|
|
31
|
+
* which accepts any Batcher subclass.
|
|
32
|
+
* @category Rendering
|
|
33
|
+
*/
|
|
34
|
+
export class Batcher {
|
|
35
|
+
/**
|
|
36
|
+
* Initialize (or re-initialize after a context/device loss) this batcher.
|
|
37
|
+
* Derived classes override this with their full `(renderer, settings)`
|
|
38
|
+
* signature and own the whole body; the base implementation only stores
|
|
39
|
+
* the renderer reference.
|
|
40
|
+
* @param {Renderer} renderer - the owning renderer
|
|
41
|
+
*/
|
|
42
|
+
init(renderer: Renderer): void;
|
|
43
|
+
/**
|
|
44
|
+
* the renderer this batcher is bound to
|
|
45
|
+
* @type {Renderer}
|
|
46
|
+
*/
|
|
47
|
+
renderer: Renderer | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* called by the renderer when this batcher becomes the current one
|
|
50
|
+
*/
|
|
51
|
+
bind(): void;
|
|
52
|
+
/**
|
|
53
|
+
* called by the renderer when this batcher is being replaced by another
|
|
54
|
+
*/
|
|
55
|
+
unbind(): void;
|
|
56
|
+
/**
|
|
57
|
+
* turn the pending vertices into GPU work
|
|
58
|
+
*/
|
|
59
|
+
flush(): void;
|
|
60
|
+
/**
|
|
61
|
+
* reset the batcher's transient state (game reset / context restore)
|
|
62
|
+
*/
|
|
63
|
+
reset(): void;
|
|
64
|
+
/**
|
|
65
|
+
* release every GPU resource this batcher owns
|
|
66
|
+
*/
|
|
67
|
+
destroy(): void;
|
|
68
|
+
}
|
|
69
|
+
export default Batcher;
|
|
70
|
+
import type Renderer from "../renderer.js";
|
|
71
|
+
//# sourceMappingURL=batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/batcher.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AACH,mCAAoC,IAAI,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAMC;;;;;;OAMG;IACH,eAFW,QAAQ,QAQlB;IALA;;;OAGG;IACH,+BAAwB;IAGzB;;OAEG;IACH,aAAS;IAET;;OAEG;IACH,eAAW;IAEX;;OAEG;IACH,cAAU;IAEV;;OAEG;IACH,cAAU;IAEV;;OAEG;IACH,gBAAY;CACZ;;0BA9EwB,gBAAgB"}
|