@viggle/splat-engine-three 0.1.1 → 0.2.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +133 -20
  3. package/dist/chunks/chunk-BHNNSHJG.js +22298 -0
  4. package/dist/chunks/chunk-BHNNSHJG.js.map +7 -0
  5. package/dist/index.js +221 -3
  6. package/dist/types/anim/animation-conversion.d.ts +2 -2
  7. package/dist/types/anim/keyframe-splines.d.ts +17 -41
  8. package/dist/types/animation.d.ts +84 -28
  9. package/dist/types/armature.d.ts +280 -2
  10. package/dist/types/character.d.ts +120 -2
  11. package/dist/types/effects/index.d.ts +12 -0
  12. package/dist/types/effects/outlines/outline-effect.d.ts +98 -0
  13. package/dist/types/effects/outlines/outline-shaders.d.ts +14 -0
  14. package/dist/types/effects/pixelart/pixelart-effect.d.ts +152 -0
  15. package/dist/types/effects/pixelart/pixelart-shaders.d.ts +31 -0
  16. package/dist/types/effects/postfx/base-capturing-pass.d.ts +109 -0
  17. package/dist/types/effects/postfx/camera-frame.d.ts +103 -0
  18. package/dist/types/effects/postfx/frame-renderer.d.ts +32 -0
  19. package/dist/types/effects/postfx/frame-shaders.d.ts +19 -0
  20. package/dist/types/effects/postfx/mask.d.ts +44 -0
  21. package/dist/types/effects/postfx/postfx.d.ts +144 -0
  22. package/dist/types/effects/postfx/program.d.ts +74 -0
  23. package/dist/types/effects/postfx/uniforms.d.ts +24 -0
  24. package/dist/types/effects/postfx/webgl-program.d.ts +6 -0
  25. package/dist/types/effects/postfx/webgpu-program.d.ts +3 -0
  26. package/dist/types/effects/vfx/data-types.d.ts +100 -0
  27. package/dist/types/effects/vfx/index.d.ts +37 -0
  28. package/dist/types/effects/vfx/json-vfx-prefab.d.ts +94 -0
  29. package/dist/types/effects/vfx/layer-renderer.d.ts +118 -0
  30. package/dist/types/effects/vfx/layers/mesh.d.ts +124 -0
  31. package/dist/types/effects/vfx/layers/particle.d.ts +90 -0
  32. package/dist/types/effects/vfx/layers/shader.d.ts +130 -0
  33. package/dist/types/effects/vfx/layers/shared.d.ts +40 -0
  34. package/dist/types/effects/vfx/layers/sprite.d.ts +45 -0
  35. package/dist/types/effects/vfx/pool.d.ts +51 -0
  36. package/dist/types/effects/vfx/prefab.d.ts +48 -0
  37. package/dist/types/effects/vfx/prewarm.d.ts +17 -0
  38. package/dist/types/effects/vfx/stage.d.ts +115 -0
  39. package/dist/types/effects/vfx/webgpu-register.d.ts +2 -0
  40. package/dist/types/effects/webgpu-register.d.ts +2 -0
  41. package/dist/types/engine.d.ts +18 -0
  42. package/dist/types/environment.d.ts +96 -8
  43. package/dist/types/index.d.ts +33 -6
  44. package/dist/types/loader/animation/animation-glb.d.ts +4 -4
  45. package/dist/types/loader/character/load.d.ts +6 -1
  46. package/dist/types/loader/environment/lod-bundle.d.ts +123 -0
  47. package/dist/types/loader/environment/spz-decode.d.ts +88 -0
  48. package/dist/types/loader/environment/spz.d.ts +28 -0
  49. package/dist/types/loader/shared/asset-fetch.d.ts +11 -0
  50. package/dist/types/loader/shared/asset-loader.d.ts +86 -0
  51. package/dist/types/loader/shared/bin-cache.d.ts +41 -14
  52. package/dist/types/loader/shared/decode-worker.d.ts +27 -0
  53. package/dist/types/loader/shared/glb.d.ts +30 -0
  54. package/dist/types/loader/shared/inflate.d.ts +9 -0
  55. package/dist/types/loader/shared/pack-splats-task.d.ts +17 -0
  56. package/dist/types/loader/shared/sog-decode.d.ts +81 -0
  57. package/dist/types/loader/shared/sog.d.ts +17 -0
  58. package/dist/types/math.d.ts +7 -0
  59. package/dist/types/physics/ammo.d.ts +210 -0
  60. package/dist/types/physics/index.d.ts +11 -0
  61. package/dist/types/physics/joints.d.ts +157 -0
  62. package/dist/types/physics/physics-world.d.ts +193 -0
  63. package/dist/types/physics/rigid-body.d.ts +361 -0
  64. package/dist/types/presets/camera/camera-preset.d.ts +43 -0
  65. package/dist/types/presets/camera/third-person-camera.d.ts +63 -0
  66. package/dist/types/presets/character/body-shape.d.ts +109 -0
  67. package/dist/types/presets/character/character-reveal.d.ts +90 -0
  68. package/dist/types/presets/character/socket-loadout.d.ts +61 -0
  69. package/dist/types/presets/index.d.ts +13 -0
  70. package/dist/types/presets/vfx/mesh-flash.d.ts +51 -0
  71. package/dist/types/presets/visual/bone-overlay.d.ts +57 -0
  72. package/dist/types/proxy/environment-input.d.ts +30 -0
  73. package/dist/types/proxy/environment-source.d.ts +39 -0
  74. package/dist/types/proxy/proxy-debug.d.ts +106 -0
  75. package/dist/types/proxy/splat-source.d.ts +42 -0
  76. package/dist/types/proxy/voxelizer.d.ts +383 -0
  77. package/dist/types/relight/backend.d.ts +101 -0
  78. package/dist/types/relight/index.d.ts +6 -0
  79. package/dist/types/relight/relight-pass.d.ts +367 -0
  80. package/dist/types/relight/relight-placeholder.d.ts +2 -0
  81. package/dist/types/relight/relight-shaders.d.ts +4 -0
  82. package/dist/types/relight/shadow-bias.d.ts +26 -0
  83. package/dist/types/relight/splat-relight.d.ts +741 -0
  84. package/dist/types/relight/webgl-backend.d.ts +3 -0
  85. package/dist/types/relight/webgpu/backend.d.ts +3 -0
  86. package/dist/types/relight/webgpu-register.d.ts +2 -0
  87. package/dist/types/scene.d.ts +241 -0
  88. package/dist/types/skeletal/animation-player.d.ts +31 -3
  89. package/dist/types/skeletal/body-parts.d.ts +55 -0
  90. package/dist/types/skeletal/ragdoll-config.d.ts +115 -0
  91. package/dist/types/skeletal/ragdoll.d.ts +283 -0
  92. package/dist/types/skeletal/skeleton.d.ts +9 -2
  93. package/dist/types/splat/backend.d.ts +2 -0
  94. package/dist/types/splat/color-modifier.d.ts +78 -0
  95. package/dist/types/splat/cut-groups.d.ts +27 -0
  96. package/dist/types/splat/relight-binding.d.ts +39 -0
  97. package/dist/types/splat/reveal-bake.d.ts +43 -0
  98. package/dist/types/splat/reveal-look.d.ts +64 -0
  99. package/dist/types/splat/splat-mesh.d.ts +1 -0
  100. package/dist/types/splat/splat.d.ts +154 -0
  101. package/dist/types/splat/webgl/shaders.d.ts +5 -1
  102. package/dist/types/splat/webgl/splat-mesh.d.ts +4 -0
  103. package/dist/types/splat/webgpu/radix-sort.d.ts +3 -0
  104. package/dist/types/splat/webgpu/splat-mesh.d.ts +23 -0
  105. package/dist/types/three/splat-character.d.ts +28 -0
  106. package/dist/types/three/spz-loader.d.ts +35 -0
  107. package/dist/types/types.d.ts +6 -0
  108. package/dist/webgpu.js +1123 -154
  109. package/dist/webgpu.js.map +4 -4
  110. package/package.json +6 -2
  111. package/dist/chunks/chunk-WN5WBKM4.js +0 -8606
  112. package/dist/chunks/chunk-WN5WBKM4.js.map +0 -7
@@ -0,0 +1,98 @@
1
+ import type { Camera, RenderTarget, Texture } from 'three';
2
+ import type { Scene } from '../../scene';
3
+ import type { EffectColor } from '../postfx/camera-frame';
4
+ import { type MaskTarget } from '../postfx/mask';
5
+ import type { PostFXOverlay } from '../postfx/postfx';
6
+ /**
7
+ * Options for {@link OutlineEffect}.
8
+ *
9
+ * @group Outlines
10
+ */
11
+ export interface OutlineEffectOptions {
12
+ /** Line colour; alpha is how strongly it covers the scene. Default purple (0.6, 0.2, 1, 1). */
13
+ color?: EffectColor;
14
+ /** Line thickness in pixels, constant across zoom. Default 3. */
15
+ thicknessPx?: number;
16
+ /** The camera the silhouettes are drawn from. Default: the scene's camera. */
17
+ mainCamera?: Camera;
18
+ }
19
+ /**
20
+ * Options for {@link OutlineEffect.add}.
21
+ *
22
+ * @group Outlines
23
+ */
24
+ export interface OutlineAddOptions {
25
+ /** Outline the object's descendants too, such as a held weapon. Default `true`. */
26
+ recursive?: boolean;
27
+ }
28
+ /**
29
+ * Per-object outlines: a line of one colour around everything tagged, drawn
30
+ * over the scene and through anything in front of it.
31
+ *
32
+ * ```ts
33
+ * const outlines = new OutlineEffect(scene, { color: { r: 1, g: 1, b: 1, a: 1 }, thicknessPx: 3 });
34
+ * outlines.add(hero); // a Character, or any Object3D
35
+ * outlines.remove(hero);
36
+ * outlines.destroy();
37
+ * ```
38
+ *
39
+ * Each frame something is tagged, the tagged objects render alone into a
40
+ * silhouette mask, then a fullscreen pass draws the ring around it onto the
41
+ * scene, before the {@link CameraFrame} (if any) composes it. That is a
42
+ * second draw of every tagged object; untag rather than set the strength to
43
+ * 0 to save it.
44
+ *
45
+ * @group Outlines
46
+ */
47
+ export declare class OutlineEffect implements PostFXOverlay {
48
+ private readonly _scene;
49
+ private readonly _camera;
50
+ private _color;
51
+ private _thickness;
52
+ private _strength;
53
+ private _shimmer;
54
+ private _time;
55
+ private _mask;
56
+ private _program;
57
+ private readonly _tags;
58
+ private _destroyed;
59
+ constructor(scene: Scene, opts?: OutlineEffectOptions);
60
+ /** Line colour; alpha is the blend. Takes effect next frame. */
61
+ get outlineColor(): EffectColor;
62
+ set outlineColor(c: EffectColor);
63
+ /** Line thickness in pixels. */
64
+ get outlineThickness(): number;
65
+ set outlineThickness(px: number);
66
+ /** The silhouette mask of everything tagged, coverage in alpha; null before the first frame. */
67
+ get maskTexture(): Texture | null;
68
+ /**
69
+ * Outline `target`: a `Character` (every level of detail), or any
70
+ * `Object3D` and, unless `recursive: false`, its subtree. Re-tagging
71
+ * replaces the tag.
72
+ */
73
+ add(target: MaskTarget, opts?: OutlineAddOptions): void;
74
+ /** Whether `target` is outlined. */
75
+ has(target: MaskTarget): boolean;
76
+ /** Stop outlining `target`. No-op when it is not outlined. */
77
+ remove(target: MaskTarget): void;
78
+ /** Stop outlining everything. */
79
+ clear(): void;
80
+ /**
81
+ * Change the line's look, per frame if wanted: `color` (alpha the base
82
+ * blend), `thicknessPx`, `strength` 0..1 multiplying the alpha (0 draws
83
+ * nothing, so a hover can fade the line in), and `shimmer` 0..1, a soft
84
+ * band travelling up the screen at `time` seconds.
85
+ */
86
+ setLook(look: {
87
+ color?: EffectColor;
88
+ thicknessPx?: number;
89
+ strength?: number;
90
+ shimmer?: number;
91
+ time?: number;
92
+ }): void;
93
+ /** Tear everything down. Safe to call more than once. */
94
+ destroy(): void;
95
+ /** @internal */
96
+ renderOverlay(target: RenderTarget | null, width: number, height: number): void;
97
+ private _maskRoots;
98
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Outline expand shader, GLSL and WGSL, ported from the PlayCanvas build.
3
+ *
4
+ * A fullscreen fragment over the scene: it samples the silhouette mask in an
5
+ * 8-tap ring `uThicknessPx` pixels wide, discards pixels inside the
6
+ * silhouette (the line is the ring, not the fill) and pixels whose ring never
7
+ * reaches it, and writes the outline colour on the rest, alpha-blended.
8
+ *
9
+ * Uniforms: uMask (coverage in alpha), uTexelSize, uOutlineColor (alpha is the
10
+ * blend), uThicknessPx, uStrength (multiplies alpha), uShimmer (how much a
11
+ * band travelling up the screen modulates the line), uTime (seconds).
12
+ */
13
+ export declare const expandFragmentGLSL = "\nprecision mediump float;\nvarying vec2 vUv0;\nuniform sampler2D uMask;\nuniform vec2 uTexelSize; // (1/w, 1/h) of the mask RT\nuniform vec4 uOutlineColor; // rgba - a = blend strength\nuniform float uThicknessPx;\nuniform float uStrength; // 0..1, multiplies the alpha\nuniform float uShimmer; // 0..1, how much the travelling band modulates\nuniform float uTime; // seconds\n\nvoid main() {\n // Use integer pixel coordinates instead of vUv0 so mask and present\n // stay in the same screen-space orientation on both WebGL and WebGPU.\n // Sampling the mask RT with vUv0 was visually Y-flipped under WebGPU\n // (render-target origin convention differs), which made the outline\n // render upside-down relative to the character.\n ivec2 texel = ivec2(gl_FragCoord.xy);\n float center = texelFetch(uMask, texel, 0).a;\n // Inside the silhouette \u2192 the outline belongs on the boundary, not\n // the fill. Discard so the scene underneath shows through.\n if (center > 0.5) discard;\n\n int off = int(uThicknessPx + 0.5);\n\n // 8-tap ring. Hard step - any ring sample inside the silhouette\n // means this pixel is within thicknessPx of the silhouette\n // boundary, so we emit the outline colour.\n float s = 0.0;\n s = max(s, texelFetch(uMask, texel + ivec2( off, 0), 0).a);\n s = max(s, texelFetch(uMask, texel + ivec2(-off, 0), 0).a);\n s = max(s, texelFetch(uMask, texel + ivec2( 0, off), 0).a);\n s = max(s, texelFetch(uMask, texel + ivec2( 0, -off), 0).a);\n s = max(s, texelFetch(uMask, texel + ivec2( off, off), 0).a);\n s = max(s, texelFetch(uMask, texel + ivec2(-off, off), 0).a);\n s = max(s, texelFetch(uMask, texel + ivec2( off, -off), 0).a);\n s = max(s, texelFetch(uMask, texel + ivec2(-off, -off), 0).a);\n\n if (s < 0.5) discard;\n\n // A soft band travelling up the screen while selected: the line breathes\n // along the body instead of sitting dead on it.\n float band = 0.5 + 0.5 * sin(vUv0.y * 18.0 - uTime * 1.6);\n float shimmer = mix(1.0, 0.55 + 0.45 * band, uShimmer);\n gl_FragColor = vec4(uOutlineColor.rgb, uOutlineColor.a * uStrength * shimmer);\n}\n";
14
+ export declare const expandFragmentWGSL = "\nvar uMask: texture_2d<f32>;\nuniform uTexelSize: vec2f;\nuniform uOutlineColor: vec4f;\nuniform uThicknessPx: f32;\nuniform uStrength: f32;\nuniform uShimmer: f32;\nuniform uTime: f32;\n\n\n@fragment\nfn fragmentMain(input: FragmentInput) -> FragmentOutput {\n var output: FragmentOutput;\n // Use integer pixel coordinates (from @builtin(position)) so mask and\n // present stay in the same screen-space orientation. Sampling the mask\n // RT via UV was visually Y-flipped under WebGPU (render-target origin\n // convention differs), producing an upside-down outline.\n let texel = vec2i(input.position.xy);\n let center = textureLoad(uMask, texel, 0).a;\n if (center > 0.5) { discard; }\n\n let off = i32(uniform.uThicknessPx + 0.5);\n\n var s: f32 = 0.0;\n s = max(s, textureLoad(uMask, texel + vec2i( off, 0), 0).a);\n s = max(s, textureLoad(uMask, texel + vec2i(-off, 0), 0).a);\n s = max(s, textureLoad(uMask, texel + vec2i( 0, off), 0).a);\n s = max(s, textureLoad(uMask, texel + vec2i( 0, -off), 0).a);\n s = max(s, textureLoad(uMask, texel + vec2i( off, off), 0).a);\n s = max(s, textureLoad(uMask, texel + vec2i(-off, off), 0).a);\n s = max(s, textureLoad(uMask, texel + vec2i( off, -off), 0).a);\n s = max(s, textureLoad(uMask, texel + vec2i(-off, -off), 0).a);\n\n if (s < 0.5) { discard; }\n\n let band = 0.5 + 0.5 * sin(input.vUv0.y * 18.0 - uniform.uTime * 1.6);\n let shimmer = mix(1.0, 0.55 + 0.45 * band, uniform.uShimmer);\n output.color = vec4f(uniform.uOutlineColor.rgb, uniform.uOutlineColor.a * uniform.uStrength * shimmer);\n return output;\n}\n";
@@ -0,0 +1,152 @@
1
+ import type { Scene } from '../../scene';
2
+ import type { EffectColor, FrameColor } from '../postfx/camera-frame';
3
+ import { type MaskTarget } from '../postfx/mask';
4
+ import type { PostFXFrameConfig, PostFXInstallContext, PostFXPass, PostFXRenderContext } from '../postfx/postfx';
5
+ /**
6
+ * Options for {@link PixelartEffect}. The same as the PlayCanvas build's.
7
+ *
8
+ * @group Pixelart
9
+ */
10
+ export interface PixelartEffectOptions {
11
+ /** Integer downscale factor for tagged characters, and for everything when `environmentScale` is unset. Default 4. */
12
+ scale?: number;
13
+ /**
14
+ * Integer downscale factor for everything but tagged characters, a multiple
15
+ * of `scale`. Larger gives the world chunkier pixels than the characters.
16
+ * Default: `scale`.
17
+ */
18
+ environmentScale?: number;
19
+ /** Per-channel colour quantisation into `levels` steps. Default off. */
20
+ quantize?: {
21
+ levels: number;
22
+ } | null;
23
+ /**
24
+ * Bayer 4x4 ordered dither before quantisation, `strength` in quant steps
25
+ * (1 breaks banding into the classic dot pattern). Needs `quantize`. Default off.
26
+ */
27
+ dither?: {
28
+ strength: number;
29
+ } | null;
30
+ /**
31
+ * A line around tagged characters, from the same mask: `thicknessPx` in
32
+ * canvas pixels (at least about `scale`), `mode` where it sits relative to
33
+ * the silhouette, `smoothness` 0 (hard) to ~0.5 (soft). Default off.
34
+ */
35
+ outline?: {
36
+ color: EffectColor;
37
+ thicknessPx?: number;
38
+ mode?: 'outer' | 'inner' | 'both';
39
+ smoothness?: number;
40
+ } | null;
41
+ /** Whole-frame grade, last: `clamp(c * gain + lift)`. Default identity. */
42
+ colorGrade?: {
43
+ lift?: FrameColor;
44
+ gain?: FrameColor;
45
+ } | null;
46
+ /**
47
+ * Whether adding the effect realizes the scene's {@link CameraFrame}, as the
48
+ * PlayCanvas build's scene-depth prepass did. Default `true`.
49
+ */
50
+ requireSceneDepth?: boolean;
51
+ }
52
+ /**
53
+ * Pixel-art post-process: the scene renders at a fraction of the canvas size
54
+ * and is scaled back up with nearest-neighbour sampling, so splat edges become
55
+ * clean pixel blocks. Optionally quantises and dithers colour, grades the
56
+ * frame, and gives tagged characters a finer pixel than the world plus a
57
+ * crisp outline.
58
+ *
59
+ * ```ts
60
+ * const pixelart = scene.postfx.add(new PixelartEffect({ scale: 2, environmentScale: 4 }));
61
+ * pixelart.addCharacter(hero); // finer pixels, outlined
62
+ * pixelart.pixelScale = 3; // live
63
+ * pixelart.destroy();
64
+ * ```
65
+ *
66
+ * Characters are told apart from the world by a silhouette mask: tagged
67
+ * objects render a second time, alone, into a small target at the scene's
68
+ * resolution. That costs one more draw of each tagged character a frame.
69
+ *
70
+ * @group Pixelart
71
+ */
72
+ export declare class PixelartEffect implements PostFXPass {
73
+ readonly capturesScene = true;
74
+ private _scale;
75
+ private _envSnap;
76
+ private _quantLevels;
77
+ private _ditherStrength;
78
+ private _outlineColor;
79
+ private _outlineThickness;
80
+ private _outlineMode;
81
+ private _outlineSmoothness;
82
+ private _gradeLift;
83
+ private _gradeGain;
84
+ private _envDarken;
85
+ private readonly _requireFrame;
86
+ private _scene;
87
+ private _program;
88
+ private _mask;
89
+ /** Tagged targets and whether each covers its subtree. */
90
+ private readonly _tags;
91
+ private _destroyed;
92
+ /** Shorthand for `scene.postfx.add(new PixelartEffect(opts))`. */
93
+ static create(scene: Scene, opts?: PixelartEffectOptions): PixelartEffect;
94
+ /** A detached effect; add it with `scene.postfx.add`. */
95
+ constructor(opts?: PixelartEffectOptions);
96
+ configureFrame(scene: Scene, config: PostFXFrameConfig): void;
97
+ getSceneCaptureSize(width: number, height: number): {
98
+ width: number;
99
+ height: number;
100
+ };
101
+ install(scene: Scene, _ctx: PostFXInstallContext): void;
102
+ uninstall(_scene: Scene): void;
103
+ render(ctx: PostFXRenderContext): void;
104
+ /** The fine (character) downscale factor. Takes effect next frame. */
105
+ get pixelScale(): number;
106
+ set pixelScale(s: number);
107
+ /** Environment snap factor, >= 1: environment pixels are this many character pixels wide. */
108
+ get environmentSnap(): number;
109
+ set environmentSnap(s: number);
110
+ /** Levels per channel, or 0 for no quantisation. */
111
+ get quantizationLevels(): number;
112
+ set quantizationLevels(levels: number);
113
+ /** Dither amplitude in quant steps; 0 turns it off. */
114
+ get ditherStrength(): number;
115
+ set ditherStrength(v: number);
116
+ /** Outline thickness in canvas pixels; 0 turns it off. */
117
+ get outlineThickness(): number;
118
+ set outlineThickness(px: number);
119
+ getOutlineColor(): EffectColor;
120
+ setOutlineColor(c: EffectColor): void;
121
+ get outlineMode(): 'outer' | 'inner' | 'both';
122
+ set outlineMode(m: 'outer' | 'inner' | 'both');
123
+ /** Outline softness, 0 (hard) to about 0.5. */
124
+ get outlineSmoothness(): number;
125
+ set outlineSmoothness(v: number);
126
+ getColorGradeLift(): FrameColor;
127
+ setColorGradeLift(c: FrameColor): void;
128
+ getColorGradeGain(): FrameColor;
129
+ setColorGradeGain(c: FrameColor): void;
130
+ /** Darken everything but tagged characters, 0 (off) to 1 (black): a death-cutscene fade. */
131
+ getEnvDarken(): number;
132
+ setEnvDarken(v: number): void;
133
+ /** Whether `target` is tagged by {@link addCharacter}. */
134
+ hasCharacter(target: MaskTarget): boolean;
135
+ /**
136
+ * Tag a character: it samples at the fine scale, takes the outline, and is
137
+ * spared {@link setEnvDarken}. Pass a `Character` (every level of detail is
138
+ * tagged) or any `Object3D` (its subtree too, unless `recursive: false`);
139
+ * a mesh paints its silhouette the same way a splat does. Re-tagging
140
+ * replaces the tag.
141
+ */
142
+ addCharacter(target: MaskTarget, opts?: {
143
+ recursive?: boolean;
144
+ }): void;
145
+ /** Untag a character. No-op when it is not tagged. */
146
+ removeCharacter(target: MaskTarget): void;
147
+ /** Untag every character. */
148
+ clearCharacters(): void;
149
+ /** Remove the effect for good: out of the chain, every tag dropped. */
150
+ destroy(): void;
151
+ private _maskRoots;
152
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Pixel-art upscale shader, GLSL and WGSL. Ported from the PlayCanvas build
3
+ * unchanged: it was already written to PostFX's dialect.
4
+ *
5
+ * Samples the low-resolution scene with integer pixel coordinates, one output
6
+ * pixel per canvas pixel. Fragment coordinates and the source share an origin
7
+ * on each backend, so texelFetch / textureLoad by `gl_FragCoord` /
8
+ * `input.position` reads the right way up on both, where UV sampling would
9
+ * have to know which way each backend stores a render target.
10
+ *
11
+ * A mask the size of the low-res scene says which pixels belong to a tagged
12
+ * character (alpha > 0.5). Character pixels sample at the fine scale;
13
+ * environment pixels snap to a grid `uEnvSnap` source pixels wide, which is
14
+ * what gives two pixel sizes from one scene render.
15
+ *
16
+ * Uniforms:
17
+ * uSourceTex low-res scene, display colour.
18
+ * uMaskTex character silhouettes, coverage in alpha.
19
+ * uScale (srcW / dstW, srcH / dstH): output pixel to source texel.
20
+ * uEnvSnap environment snap factor, >= 1.
21
+ * uQuantLevels 0 = off, else steps per channel.
22
+ * uDitherStrength Bayer 4x4 amplitude in quant steps (with quantize only),
23
+ * indexed by the perceptual pixel so dither cells match the
24
+ * pixel blocks of each region.
25
+ * uOutlineColor / uOutlineThicknessPx / uOutlineMode / uOutlineSmoothness
26
+ * an 8-tap ring on the mask: 0 outer, 1 inner, 2 both.
27
+ * uEnvDarken 0..1 multiplies environment pixels by (1 - v).
28
+ * uGradeLift / uGradeGain c * gain + lift, last.
29
+ */
30
+ export declare const upscaleFragmentGLSL = "\nprecision highp float;\nuniform highp sampler2D uSourceTex;\nuniform highp sampler2D uMaskTex;\nuniform vec2 uScale;\nuniform float uEnvSnap;\nuniform float uQuantLevels;\nuniform float uDitherStrength; // 0 disables. 1 = \u00B10.5 step amplitude (paired with uQuantLevels).\nuniform vec4 uOutlineColor;\nuniform float uOutlineThicknessPx;\nuniform float uOutlineMode; // 0 outer, 1 inner, 2 both\nuniform float uOutlineSmoothness; // 0 = hard step. Larger = wider smoothstep window on ring alpha.\nuniform vec3 uGradeLift; // Added to final colour. Default (0,0,0).\nuniform vec3 uGradeGain; // Multiplied with final colour. Default (1,1,1).\nuniform float uEnvDarken; // 0 = no-op, 1 = env pixels fully black. Char pixels untouched.\n\nvoid main() {\n ivec2 srcFine = ivec2(gl_FragCoord.xy * uScale);\n float maskAlpha = texelFetch(uMaskTex, srcFine, 0).a;\n bool isChar = maskAlpha > 0.5;\n\n // Perceptual pixel index - equals srcFine for char, srcFine/snap for\n // env. Used both as the source-sample coord (\u00D7snap) and as the Bayer\n // index for dither, so dither cells match the apparent pixel size\n // of whichever region we're in.\n int snap = 1;\n if (!isChar && uEnvSnap > 1.0) snap = int(uEnvSnap + 0.5);\n ivec2 perceptCoord = srcFine / snap;\n ivec2 src = perceptCoord * snap;\n\n // Scene color first - outline blends on top of it (smoothstep needs\n // both colors to mix). Tiny perf cost vs the old hard-early-return\n // path but the unified path keeps the smooth path clean.\n vec3 c = texelFetch(uSourceTex, src, 0).rgb;\n if (uQuantLevels > 0.5) {\n float lv = uQuantLevels - 1.0;\n if (uDitherStrength > 0.0) {\n // Bayer 4\u00D74 - classic ordered dither. Threshold in [-0.5, +0.5)\n // is added to the colour before snapping to the quant grid, so\n // neighbouring perceptual pixels land on different rungs.\n const float bayer[16] = float[16](\n 0.0, 8.0, 2.0, 10.0,\n 12.0, 4.0, 14.0, 6.0,\n 3.0, 11.0, 1.0, 9.0,\n 15.0, 7.0, 13.0, 5.0\n );\n int bx = perceptCoord.x & 3;\n int by = perceptCoord.y & 3;\n float threshold = (bayer[by * 4 + bx] / 16.0) - 0.5;\n c += vec3(threshold / lv * uDitherStrength);\n c = clamp(c, 0.0, 1.0);\n }\n c = floor(c * lv + 0.5) / lv;\n }\n\n // Outline. Ring max \u2192 \"ring touches char\", ring min \u2192 \"ring touches\n // env\". For OUTER on env pixels: amt rises as ringMax approaches 1.\n // For INNER on char pixels: amt rises as (1-ringMin) approaches 1\n // (i.e. ring leaks out of silhouette). smoothstep window width is\n // uOutlineSmoothness - when 0 it collapses to a hard step.\n if (uOutlineThicknessPx > 0.5) {\n bool wantOuter = (uOutlineMode < 0.5 || uOutlineMode > 1.5) && !isChar;\n bool wantInner = (uOutlineMode > 0.5) && isChar;\n if (wantOuter || wantInner) {\n ivec2 off = ivec2(uOutlineThicknessPx * uScale + 0.5);\n off = ivec2(max(off.x, 1), max(off.y, 1));\n float ringMax = 0.0;\n float ringMin = 1.0;\n float s;\n s = texelFetch(uMaskTex, srcFine + ivec2( off.x, 0), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = texelFetch(uMaskTex, srcFine + ivec2(-off.x, 0), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = texelFetch(uMaskTex, srcFine + ivec2( 0, off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = texelFetch(uMaskTex, srcFine + ivec2( 0, -off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = texelFetch(uMaskTex, srcFine + ivec2( off.x, off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = texelFetch(uMaskTex, srcFine + ivec2(-off.x, off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = texelFetch(uMaskTex, srcFine + ivec2( off.x, -off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = texelFetch(uMaskTex, srcFine + ivec2(-off.x, -off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n float t = max(uOutlineSmoothness, 0.001);\n float amt = 0.0;\n if (wantOuter) amt = max(amt, smoothstep(0.5 - t, 0.5 + t, ringMax));\n if (wantInner) amt = max(amt, smoothstep(0.5 - t, 0.5 + t, 1.0 - ringMin));\n c = mix(c, uOutlineColor.rgb, amt * uOutlineColor.a);\n }\n }\n\n // Env-only darken - multiplies env pixels by (1 - uEnvDarken). Used\n // by the death cutscene to fade the map (and untagged enemies) to\n // black while the player (still char-tagged) stays at full intensity.\n // Applied AFTER outline so outline colour fades with env, BEFORE\n // colour grade so the warm ambient still tints the dying frame.\n if (!isChar && uEnvDarken > 0.0) c *= (1.0 - uEnvDarken);\n\n // Colour grade - gain \u25E6 c + lift, clamped. Applied last so it acts\n // as a whole-frame LUT on top of scene + outline. Identity by default\n // (gain=(1,1,1), lift=(0,0,0)).\n c = clamp(c * uGradeGain + uGradeLift, 0.0, 1.0);\n\n gl_FragColor = vec4(c, 1.0);\n}\n";
31
+ export declare const upscaleFragmentWGSL = "\nvar uSourceTex: texture_2d<f32>;\nvar uMaskTex: texture_2d<f32>;\nuniform uScale: vec2f;\nuniform uEnvSnap: f32;\nuniform uQuantLevels: f32;\nuniform uDitherStrength: f32;\nuniform uOutlineColor: vec4f;\nuniform uOutlineThicknessPx: f32;\nuniform uOutlineMode: f32;\nuniform uOutlineSmoothness: f32;\nuniform uGradeLift: vec3f;\nuniform uGradeGain: vec3f;\nuniform uEnvDarken: f32;\n\n@fragment\nfn fragmentMain(input: FragmentInput) -> FragmentOutput {\n var output: FragmentOutput;\n let srcFine = vec2i(input.position.xy * uniform.uScale);\n let maskAlpha = textureLoad(uMaskTex, srcFine, 0).a;\n let isChar = maskAlpha > 0.5;\n\n // Perceptual pixel index - see GLSL twin for details.\n var snap: i32 = 1;\n if (!isChar && uniform.uEnvSnap > 1.0) { snap = i32(uniform.uEnvSnap + 0.5); }\n let perceptCoord = srcFine / snap;\n let src = perceptCoord * snap;\n\n // Scene first - outline blends on top so smooth and hard share the path.\n var c = textureLoad(uSourceTex, src, 0).rgb;\n if (uniform.uQuantLevels > 0.5) {\n let lv = uniform.uQuantLevels - 1.0;\n if (uniform.uDitherStrength > 0.0) {\n var bayer = array<f32, 16>(\n 0.0, 8.0, 2.0, 10.0,\n 12.0, 4.0, 14.0, 6.0,\n 3.0, 11.0, 1.0, 9.0,\n 15.0, 7.0, 13.0, 5.0\n );\n let bx = perceptCoord.x & 3;\n let by = perceptCoord.y & 3;\n let threshold = (bayer[by * 4 + bx] / 16.0) - 0.5;\n c = c + vec3f(threshold / lv * uniform.uDitherStrength);\n c = clamp(c, vec3f(0.0), vec3f(1.0));\n }\n c = floor(c * lv + 0.5) / lv;\n }\n\n if (uniform.uOutlineThicknessPx > 0.5) {\n let wantOuter = (uniform.uOutlineMode < 0.5 || uniform.uOutlineMode > 1.5) && !isChar;\n let wantInner = (uniform.uOutlineMode > 0.5) && isChar;\n if (wantOuter || wantInner) {\n var off = vec2i(uniform.uOutlineThicknessPx * uniform.uScale + 0.5);\n off = vec2i(max(off.x, 1), max(off.y, 1));\n var ringMax: f32 = 0.0;\n var ringMin: f32 = 1.0;\n var s: f32;\n s = textureLoad(uMaskTex, srcFine + vec2i( off.x, 0), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = textureLoad(uMaskTex, srcFine + vec2i(-off.x, 0), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = textureLoad(uMaskTex, srcFine + vec2i( 0, off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = textureLoad(uMaskTex, srcFine + vec2i( 0, -off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = textureLoad(uMaskTex, srcFine + vec2i( off.x, off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = textureLoad(uMaskTex, srcFine + vec2i(-off.x, off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = textureLoad(uMaskTex, srcFine + vec2i( off.x, -off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n s = textureLoad(uMaskTex, srcFine + vec2i(-off.x, -off.y), 0).a; ringMax = max(ringMax, s); ringMin = min(ringMin, s);\n let t = max(uniform.uOutlineSmoothness, 0.001);\n var amt: f32 = 0.0;\n if (wantOuter) { amt = max(amt, smoothstep(0.5 - t, 0.5 + t, ringMax)); }\n if (wantInner) { amt = max(amt, smoothstep(0.5 - t, 0.5 + t, 1.0 - ringMin)); }\n c = mix(c, uniform.uOutlineColor.rgb, amt * uniform.uOutlineColor.a);\n }\n }\n\n // Env-only darken - see GLSL twin.\n if (!isChar && uniform.uEnvDarken > 0.0) { c = c * (1.0 - uniform.uEnvDarken); }\n\n // Colour grade - see GLSL twin. Identity by default.\n c = clamp(c * uniform.uGradeGain + uniform.uGradeLift, vec3f(0.0), vec3f(1.0));\n\n output.color = vec4f(c, 1.0);\n return output;\n}\n";
@@ -0,0 +1,109 @@
1
+ import type { Scene } from '../../scene';
2
+ import type { PostFXFrameConfig, PostFXInstallContext, PostFXPass, PostFXRenderContext } from './postfx';
3
+ import type { PostFXUniformValue } from './uniforms';
4
+ /**
5
+ * Construction options for a {@link BaseCapturingPass}.
6
+ *
7
+ * @group PostFX
8
+ */
9
+ export interface BaseCapturingPassOptions {
10
+ /** Debug and cache name, e.g. `'film-v1'`. */
11
+ readonly shaderName: string;
12
+ /**
13
+ * GLSL fragment for `THREE.WebGLRenderer`, in PlayCanvas's dialect:
14
+ * `uniform sampler2D uSourceTex;`, `gl_FragCoord`, `gl_FragColor`. Read the
15
+ * source with `texelFetch(uSourceTex, ivec2(gl_FragCoord.xy), 0)`.
16
+ */
17
+ readonly fragmentGLSL: string;
18
+ /**
19
+ * WGSL fragment for `WebGPURenderer`, in PlayCanvas's dialect:
20
+ * `var uSourceTex: texture_2d<f32>;`, `uniform name: type;` read as
21
+ * `uniform.name`, `fn fragmentMain(input: FragmentInput) -> FragmentOutput`
22
+ * writing `output.color`. Read the source with
23
+ * `textureLoad(uSourceTex, vec2i(input.position.xy), 0)`. Helper functions
24
+ * may sit above `fragmentMain`, but take uniforms as arguments.
25
+ */
26
+ readonly fragmentWGSL: string;
27
+ /** Kept for PlayCanvas parity: asks for the frame through `sceneDepthMap` instead of `requireFrame`. */
28
+ readonly needsSceneDepth?: boolean;
29
+ }
30
+ /**
31
+ * Sets a pass's shader uniforms by name, the way PlayCanvas's `ScopeSpace`
32
+ * does: `scope.resolve('uTint').setValue([1, 0.5, 0.5])`.
33
+ *
34
+ * @group PostFX
35
+ */
36
+ export interface PostFXUniformScope {
37
+ resolve(name: string): {
38
+ setValue(value: PostFXUniformValue): void;
39
+ };
40
+ }
41
+ /**
42
+ * Base for a capturing {@link PostFXPass} that is one fullscreen shader: it
43
+ * reads the picture so far as `uSourceTex` and writes the next one. Give it
44
+ * the shader in GLSL and WGSL; the GLSL runs under `THREE.WebGLRenderer`, the
45
+ * WGSL under `WebGPURenderer`. Fragment coordinates and the source texture
46
+ * share an origin on each backend, so sample by pixel coordinate as below and
47
+ * the image comes out the right way up on both.
48
+ *
49
+ * ```ts
50
+ * class TintPass extends BaseCapturingPass {
51
+ * constructor(private tint = [1, 0.5, 0.5]) {
52
+ * super({
53
+ * shaderName: 'tint-v1',
54
+ * fragmentGLSL: `
55
+ * uniform sampler2D uSourceTex;
56
+ * uniform vec3 uTint;
57
+ * void main() {
58
+ * vec3 c = texelFetch(uSourceTex, ivec2(gl_FragCoord.xy), 0).rgb;
59
+ * gl_FragColor = vec4(c * uTint, 1.0);
60
+ * }`,
61
+ * fragmentWGSL: `
62
+ * var uSourceTex: texture_2d<f32>;
63
+ * uniform uTint: vec3f;
64
+ * @fragment
65
+ * fn fragmentMain(input: FragmentInput) -> FragmentOutput {
66
+ * var output: FragmentOutput;
67
+ * let c = textureLoad(uSourceTex, vec2i(input.position.xy), 0).rgb;
68
+ * output.color = vec4f(c * uniform.uTint, 1.0);
69
+ * return output;
70
+ * }`,
71
+ * });
72
+ * }
73
+ * protected bindUniforms(scope: PostFXUniformScope): void {
74
+ * scope.resolve('uTint').setValue(this.tint);
75
+ * }
76
+ * }
77
+ * scene.postfx.add(new TintPass());
78
+ * ```
79
+ *
80
+ * @group PostFX
81
+ */
82
+ export declare abstract class BaseCapturingPass implements PostFXPass {
83
+ readonly capturesScene = true;
84
+ /** The options given at construction. */
85
+ protected readonly options: BaseCapturingPassOptions;
86
+ /** Set from {@link configureFrame} on; kept across uninstall and install. */
87
+ protected _scene: Scene | null;
88
+ private _program;
89
+ private readonly _scope;
90
+ constructor(options: BaseCapturingPassOptions);
91
+ /**
92
+ * Set the shader's own uniforms; `uSourceTex` is already bound. `target` is
93
+ * the output's size in pixels (the canvas's, for the last pass), the way
94
+ * PlayCanvas passes read `device.width` / `device.height`.
95
+ */
96
+ protected bindUniforms(_scope: PostFXUniformScope, _target: {
97
+ width: number;
98
+ height: number;
99
+ }, _ctx: PostFXRenderContext): void;
100
+ /** Size to compose the scene at when this pass is first in the chain. Default: the canvas size. */
101
+ getSceneCaptureSize(width: number, height: number): {
102
+ width: number;
103
+ height: number;
104
+ };
105
+ configureFrame(scene: Scene, config: PostFXFrameConfig): void;
106
+ install(scene: Scene, _ctx: PostFXInstallContext): void;
107
+ uninstall(_scene: Scene): void;
108
+ render(ctx: PostFXRenderContext): void;
109
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Tone-mapping curves for {@link CameraFrame.rendering}. The values match
3
+ * PlayCanvas's `TONEMAP_*` constants, so a number carried over from a
4
+ * PlayCanvas game means the same curve here.
5
+ *
6
+ * @group PostFX
7
+ */
8
+ export declare const TONEMAP_LINEAR = 0;
9
+ export declare const TONEMAP_FILMIC = 1;
10
+ export declare const TONEMAP_HEJL = 2;
11
+ export declare const TONEMAP_ACES = 3;
12
+ export declare const TONEMAP_ACES2 = 4;
13
+ export declare const TONEMAP_NEUTRAL = 5;
14
+ export declare const TONEMAP_NONE = 6;
15
+ /**
16
+ * An RGB colour as the frame reads it: a three.js `Color`, or any object with
17
+ * `r`, `g`, `b` (a PlayCanvas `Color` carried over from a game works).
18
+ *
19
+ * @group PostFX
20
+ */
21
+ export interface FrameColor {
22
+ r: number;
23
+ g: number;
24
+ b: number;
25
+ }
26
+ /**
27
+ * A colour with optional alpha, as the effects take it: a three.js `Color`
28
+ * (alpha 1), a PlayCanvas `Color`, or a plain `{ r, g, b, a }`.
29
+ *
30
+ * @group PostFX
31
+ */
32
+ export type EffectColor = FrameColor & {
33
+ a?: number;
34
+ };
35
+ /**
36
+ * The scene camera's built-in post-processing: tone mapping, bloom, colour
37
+ * grading and vignette, in the shape of PlayCanvas's `CameraFrame` so a game's
38
+ * settings carry over field for field. Get it with
39
+ * `scene.getOrCreateCameraFrame()` and change fields.
40
+ *
41
+ * With a frame, the scene renders into a linear half-float target and a
42
+ * compose pass applies, in PlayCanvas's order: bloom, grading, tone mapping
43
+ * (scaled by the renderer's `toneMappingExposure`), vignette, then the encode
44
+ * to display colour. Splats blend in linear light there, as they do under
45
+ * PlayCanvas's frame. Without one the scene draws straight to the canvas.
46
+ *
47
+ * @group PostFX
48
+ */
49
+ export declare class CameraFrame {
50
+ readonly rendering: {
51
+ /** One of the `TONEMAP_*` constants. */
52
+ toneMapping: number;
53
+ /** MSAA samples for the scene target. 1 = none. */
54
+ samples: number;
55
+ /** Resolution of the scene target relative to the canvas. */
56
+ renderTargetScale: number;
57
+ /** Kept for PlayCanvas parity: three.js always composes meshes and splats by depth. */
58
+ sceneDepthMap: boolean;
59
+ /** Contrast-adaptive sharpening of the scene before tone mapping, 0..1. */
60
+ sharpness: number;
61
+ };
62
+ /**
63
+ * Kept for PlayCanvas parity, so a game that tunes ambient occlusion runs:
64
+ * nothing here renders it.
65
+ */
66
+ readonly ssao: {
67
+ type: string;
68
+ blurEnabled: boolean;
69
+ randomize: boolean;
70
+ intensity: number;
71
+ radius: number;
72
+ samples: number;
73
+ power: number;
74
+ minAngle: number;
75
+ scale: number;
76
+ };
77
+ readonly bloom: {
78
+ /** Amount of bloom mixed in. 0 turns it off. */
79
+ intensity: number;
80
+ /** How wide the bloom spreads: the number of blur levels, 1..16. */
81
+ blurLevel: number;
82
+ };
83
+ readonly grading: {
84
+ enabled: boolean;
85
+ brightness: number;
86
+ contrast: number;
87
+ saturation: number;
88
+ tint: FrameColor;
89
+ };
90
+ readonly vignette: {
91
+ /** 0 turns it off. */
92
+ intensity: number;
93
+ inner: number;
94
+ outer: number;
95
+ curvature: number;
96
+ color: FrameColor;
97
+ };
98
+ /**
99
+ * Kept for PlayCanvas parity, where changes wait for this call: here the
100
+ * settings are read every frame, so they apply with or without it.
101
+ */
102
+ update(): void;
103
+ }
@@ -0,0 +1,32 @@
1
+ import type { Camera, RenderTarget, Scene as ThreeScene, WebGLRenderer } from 'three';
2
+ import type { CameraFrame } from './camera-frame';
3
+ /**
4
+ * The GPU half of a {@link CameraFrame}: the linear scene target, the bloom
5
+ * chain and the compose pass, laid out as PlayCanvas's frame lays them out.
6
+ * @internal
7
+ */
8
+ export declare class FrameRenderer {
9
+ private readonly _renderer;
10
+ private _scene;
11
+ private _half;
12
+ private readonly _levels;
13
+ private readonly _compose;
14
+ private _prefilter;
15
+ private _down;
16
+ private _up;
17
+ constructor(renderer: WebGLRenderer);
18
+ /** Draw the scene into the linear scene target and return it. */
19
+ renderScene(scene: ThreeScene, camera: Camera, width: number, height: number, samples: number): RenderTarget;
20
+ /** Bloom, grade, tone map, vignette and encode the scene target into `target` (`null`: the canvas). */
21
+ compose(frame: CameraFrame, exposure: number, target: RenderTarget | null): void;
22
+ /**
23
+ * PlayCanvas's bloom: a half-size copy of the scene, `levels` 13-tap
24
+ * downsamples each half the last, then 9-tap upsamples added back up the
25
+ * chain. Returns the top level, a quarter of the scene's size.
26
+ */
27
+ private _bloom;
28
+ /** Free the render targets, keeping the compiled programs for when the frame is back. */
29
+ releaseTargets(): void;
30
+ dispose(): void;
31
+ private _releaseBloom;
32
+ }
@@ -0,0 +1,19 @@
1
+ import type { PostFXShaderSource } from './program';
2
+ /** The parts of the compose shader a frame's settings switch on. @internal */
3
+ export interface ComposeVariant {
4
+ toneMapping: number;
5
+ bloom: boolean;
6
+ grading: boolean;
7
+ vignette: boolean;
8
+ sharpen: boolean;
9
+ }
10
+ /** A stable key for a {@link ComposeVariant}, for caching its program. @internal */
11
+ export declare function composeVariantKey(v: ComposeVariant): string;
12
+ /** The compose pass for `v`: scene (+ bloom) → grading → tone map → vignette → sRGB. @internal */
13
+ export declare function composeSource(v: ComposeVariant): PostFXShaderSource;
14
+ /** Half-resolution copy of the scene that feeds the bloom chain, negatives removed. @internal */
15
+ export declare const BLOOM_PREFILTER: PostFXShaderSource;
16
+ /** One 13-tap downsample of the bloom chain. @internal */
17
+ export declare const BLOOM_DOWNSAMPLE: PostFXShaderSource;
18
+ /** One 9-tap tent upsample, added onto the level below it. @internal */
19
+ export declare const BLOOM_UPSAMPLE: PostFXShaderSource;
@@ -0,0 +1,44 @@
1
+ import type { Camera, Object3D, RenderTarget } from 'three';
2
+ import type { Scene } from '../../scene';
3
+ /**
4
+ * three.js layers the effects' silhouette masks render on. Tagged objects are
5
+ * on them only while their mask draws, so a game's own use of layers, or a
6
+ * character re-layering its splats, never meets them; nothing else may use
7
+ * these two.
8
+ * @internal
9
+ */
10
+ export declare const PIXELART_MASK_LAYER = 31;
11
+ /** @internal */
12
+ export declare const OUTLINE_MASK_LAYER = 30;
13
+ /**
14
+ * A tagged object: anything with an `Object3D`, or a character (an object with
15
+ * `splats`, each with an `object3D`), whose every level of detail is tagged so
16
+ * the mask follows whichever level is drawing.
17
+ *
18
+ * @group PostFX
19
+ */
20
+ export type MaskTarget = Object3D | {
21
+ splats: ReadonlyArray<{
22
+ object3D: Object3D;
23
+ }>;
24
+ };
25
+ /** The objects a {@link MaskTarget} stands for. @internal */
26
+ export declare function maskRoots(target: MaskTarget): Object3D[];
27
+ /**
28
+ * Render the silhouettes of `roots` (their subtrees too where `recursive`)
29
+ * into `target`, cleared to transparent black: alpha is the coverage, which is
30
+ * all the effects read. Everything draws with its own material, so a splat's
31
+ * mask follows its pose and opacity with no shader of its own; it does not
32
+ * re-sort either, as the camera is the scene's own. Lights are not on the
33
+ * layer, so meshes draw unlit, which leaves their alpha as it is.
34
+ *
35
+ * With `occlude`, the rest of the scene's depth is laid down first, so the
36
+ * silhouettes are hidden where something stands in front of them - the
37
+ * PlayCanvas build's pixel-art mask, which shares the scene's depth. Its
38
+ * outline mask does not: an outline shows through walls.
39
+ * @internal
40
+ */
41
+ export declare function renderMask(scene: Scene, camera: Camera, roots: Iterable<{
42
+ root: Object3D;
43
+ recursive: boolean;
44
+ }>, layer: number, target: RenderTarget, occlude?: boolean): void;