@threedog/post-effects 1.3.0 → 2.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 CHANGED
@@ -19,7 +19,7 @@ engine.post.add(bloom({ strength: 0.6 })); // game code
19
19
  export default vignette();
20
20
  ```
21
21
 
22
- An added effect is on unless it says `enabled: false`. The heavy ones (`bloom`, `ao`, `dof`, outline `normal` / `both`) are the game's call on weak devices: read `engine.tier` before adding them. `engine.post.add` returns a handle; on / off and tuning go through it: `glow.enabled = false`, `engine.post.get('ao').set({ radius: 0.6 })`.
22
+ An added effect is on unless it says `enabled: false`. The heavy ones (`bloom`, `ao`, `dof`, outline `normal` / `both`) are the game's call on weak devices: `{ ...bloom(), skipOnLowTier: true }` holds one while `engine.tier` is 'low' (known only once `start()` ran). `engine.post.add` returns a handle; on / off and tuning go through it: `glow.enabled = false`, `engine.post.get('ao').set({ radius: 0.6 })`.
23
23
 
24
24
  Six effects exist only as TSL nodes and live in a subpath, for games on WebGPURenderer: `voxelGI`, `reflections`, `temporalAA`, `sunShafts`, `lightVolumes`, `autoExposure`, from `@threedog/post-effects/tsl`. That file imports `three/webgpu`; the main entry does not, so a WebGL game's bundle does not grow.
25
25
 
package/hdr.js CHANGED
@@ -1,4 +1,4 @@
1
- // Bloom and ambient occlusion (GTAO) as engine.post effects (hdr slot). Both are heavy on weak devices: the game reads engine.tier to decide whether to add them.
1
+ // Bloom and ambient occlusion (GTAO) as engine.post effects (hdr slot). Both are heavy on weak devices: the game adds them with skipOnLowTier: true to hold them on a 'low' tier (index.js says why).
2
2
  import * as THREE from 'three';
3
3
  import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
4
4
  import { GTAOPass } from 'three/addons/postprocessing/GTAOPass.js';
@@ -41,11 +41,14 @@ export function ao({ radius = 0.25, intensity = 1, enabled, order = 20 } = {}) {
41
41
  const update = (pass, p) => { pass.updateGtaoMaterial({ radius: p.radius }); pass.blendIntensity = p.intensity; };
42
42
  return { ...declared(ao), name: 'ao', slot: 'hdr', order, enabled, params: { radius, intensity }, update,
43
43
  create: ({ scene, camera, width, height, params }) => { const pass = new GTAOPass(scene, camera, width, height); update(pass, params); return pass; },
44
- // WebGPU: GTAONode on the scene pass's depth (normals reconstructed from depth), its .r darkens the color; intensity mixes toward no AO as blendIntensity does
44
+ // WebGPU: GTAONode on the scene pass's depth (normals reconstructed from depth), its .r darkens the color; intensity mixes toward no AO as blendIntensity does.
45
+ // Denoised as three's AO example does: GTAONode turns its samples by a 5x5 noise tile and leaves the speckle in (GTAOPass on WebGL blurs its own result).
45
46
  node: (input, { display, scenePass, camera, tsl, p }) => {
46
- const n = display.ao(scenePass.getTextureNode('depth'), null, camera);
47
+ const depth = scenePass.getTextureNode('depth'), n = display.ao(depth, null, camera);
47
48
  n.radius = p.radius;
48
- return tsl.vec4(input.rgb.mul(tsl.mix(tsl.float(1), n.getTextureNode().r, p.intensity)), input.a);
49
+ // display.denoise is newer than some engines in this package's peer range: those draw the raw (speckled) AO instead of throwing
50
+ const raw = n.getTextureNode(), occlusion = (display.denoise ? display.denoise(raw, depth, null, camera) : raw).r;
51
+ return tsl.vec4(input.rgb.mul(tsl.mix(tsl.float(1), occlusion, p.intensity)), input.a);
49
52
  } };
50
53
  }
51
54
 
package/index.js CHANGED
@@ -10,7 +10,8 @@
10
10
  // Added = on: an effect given to engine.post.add (or exported by a plugin file) is on unless it says enabled: false (added off for the game to switch on later with
11
11
  // handle.enabled = true); the engine's rule for every effect, so adding one never silently does nothing. Tier rule, the same as at skipOnLowTier in the engine's render/PostFX.js:
12
12
  // an effect declares skipOnLowTier itself, the engine only follows that declaration, and says so in describe() and with one console note when it holds one. None here declare it, so the heavy
13
- // ones (bloom, ao, dof, outline mode normal/both) stay the game's call on weak devices: read engine.tier and leave them out.
13
+ // ones (bloom, ao, dof, outline mode normal/both) stay the game's call on weak devices: engine.post.add({ ...ao(), skipOnLowTier: true }).
14
+ // Not engine.tier read before start(): the real tier is measured there, and only a declaration follows later tier changes and the quality ladder.
14
15
  import * as THREE from 'three';
15
16
  import { codedError } from 'threedog/error-hints';
16
17
  import { declared } from './about.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threedog/post-effects",
3
- "version": "1.3.0",
3
+ "version": "2.0.0",
4
4
  "description": "Optional post effects for threedog: bloom, ambient occlusion, outline, LUT color grading, film grain, vignette, chromatic aberration and depth of field (light ldr effects are fused into one fullscreen pass)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "*.d.ts"
32
32
  ],
33
33
  "peerDependencies": {
34
- "threedog": "^1.3.0",
34
+ "threedog": "^2.0.0",
35
35
  "three": "^0.187.0"
36
36
  }
37
37
  }