Skip to content

fix(N8AO): use the EffectComposer's camera and scene - #396

Merged
kvvasuu merged 1 commit into
pmndrs:masterfrom
RaphaelFakhri:fix/n8ao-composer-camera
Oct 19, 2026
Merged

kvvasuu merged 1 commit into
pmndrs:masterfrom
RaphaelFakhri:fix/n8ao-composer-camera

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Summary

<N8AO> read camera and scene from useThree(), so it ignored the camera and scene props of <EffectComposer>. Every other component (LensFlare, Outline, SelectiveBloom, GodRays, DepthOfField, useDepthPicking) reads them from EffectComposerContext.

N8AOPostPass uses its camera for all AO math (projection and view matrices, depth reconstruction) and renders its scene with it. When the composer renders a different camera than the canvas default, the depth buffer comes from one camera and the AO is reconstructed with another, so the occlusion is misplaced. Switching the composer's camera also left N8AO on the old one.

<EffectComposer camera={otherCamera}>
  <N8AO />
</EffectComposer>

Changes

  • src/passes/N8AO.tsx: take camera and scene from EffectComposerContext. invalidate still comes from useThree.
  • src/tests/N8AO.test.tsx: add a test that checks the pass gets the composer's camera and scene, and follows a camera change.

Testing

  • pnpm vitest run src/tests/N8AO.test.tsx: the new test fails without the fix (1 failed, 3 passed) and passes with it (4 passed).
  • pnpm test: 29 files, 221 tests passed.
  • pnpm typecheck, pnpm eslint:ci and Prettier are clean.

@kvvasuu
kvvasuu merged commit c79a29e into pmndrs:master Oct 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants