Skip to content

GodRaysEffect stops compositing its light source in 6.39.4 (works in 6.39.1) #750

Closed

Description

@wowlegend

Description of the bug

Upgrading postprocessing from 6.39.1 → 6.39.4 makes GodRaysEffect stop compositing its light source entirely. The sun disc that the effect renders is simply absent from the final image; everything else in the scene renders normally.

The light source mesh itself is fine — with the effect removed, the mesh renders. It is the effect's compositing of it that produces nothing.

I have not bisected 6.39.2 vs 6.39.3 (see Scope of testing below), but the plausible candidate is the 6.39.3 change — "EffectComposer: fix depth buffer format mismatch when depth-aware passes are added after the composer has already rendered" (#745) — since that is the release that reworks how depth textures are allocated and handed to passes. GodRaysEffect's own render path is byte-identical between 6.39.1 and 6.39.4 (diffed build/index.js), so the change is beneath it, not in it.

To be clear: that depth fix looks correct on its own terms. In our app it also removed a glBlitFramebuffer: Read and write depth stencil attachments cannot be the same image warning that 6.39.1 emits continuously. We'd like to take it — the missing sun is what blocks us.

To reproduce

An <EffectComposer> containing <GodRays sun={mesh} /> (via @react-three/[email protected]), with a camera-tracked sphere as the light source:

<GodRays sun={sunMesh} samples={100} density={0.97} decay={0.95}
         weight={1.1} exposure={0.88} clampMax={1} blur />

Canvas is created with gl={{ antialias: false, alpha: false, depth: true, stencil: false }}. Other effects in the same composer: N8AO, HueSaturation, BrightnessContrast, Bloom, SMAA, ToneMapping.

On 6.39.1 the sun disc renders. On 6.39.4 it does not. No console error accompanies the disappearance.

Expected behavior

GodRaysEffect composites its light source as it did in 6.39.1.

Evidence

Measured on gated screenshots rather than by eye — blue channel sampled at y=4, x=95..165 (the disc is warm, so its blue is lower than the surrounding sky). Identical values across two independent scenes:

6.39.1, GodRays ON    213,214,215,195,196,197,198,198,199,200,200,201,223,224,224   deep dip  → disc present
6.39.4, GodRays ON    214,215,215,216,217,217,218,219,220,220,221,222,223,224,225   NO dip    → disc absent
6.39.4, GodRays OFF   214,215,215,213,212,212,213,213,214,216,217,219,223,224,225   shallow   → bare mesh only

The third row is the ablation: disabling the effect (nothing else changed) brings the mesh back. That is what localises the fault to the effect's compositing rather than to the mesh, its material, or scene setup.

Ruled out — the light source's material. Our material violates the documented contract (meshBasicMaterial defaults to depthWrite: true, transparent: false, whereas the JSDoc says "Must not write depth and has to be flagged as transparent"). We fixed that, and separately tried depthTest/depthWrite false. Both produced byte-identical output to the unfixed version — same fifteen sample values, both scenes. So the contract violation is real and worth us fixing, but it is not this bug.

Library versions used

  • postprocessing 6.39.1 (working) → 6.39.4 (broken); 6.39.4 is current latest
  • three 0.172.0
  • @react-three/fiber 9.5.0, @react-three/postprocessing 3.0.4, react 19.2.8
  • HeadlessChrome 151 (--use-angle=swiftshader), macOS arm64. Also reproduces on Chrome 147.

Scope of testing

Honest about what I did and didn't do: I tested 6.39.1 and 6.39.4 only — the intermediate versions are inferred from the changelog, not measured. Each test cycle here is a ~33-minute deterministic screenshot capture, which is why I stopped at the boundary rather than bisecting.

Happy to bisect 6.39.2/6.39.3 or put together a minimal standalone reproduction if either would help — just say which is more useful.

Activity

  1. vanruesc commented on Aug 13, 2026

    @vanruesc
    Member

    Hey, thanks for the report!

    I can't reproduce this exact issue on my machine - the god rays demo renders as expected with three r172. However, I am seeing gl errors with that version:

    GL_INVALID_OPERATION: glBlitFramebuffer: Read and write depth stencil attachments cannot be the same image.
    

    This error disappears when using r174 and higher which points to a change regarding depth texture cloning: mrdoob/three.js#30585. The recent changes in e19bfa3 seem to trigger that bug in older versions of three.

    @wowlegend can you upgrade to r174 to verify if this fixes the issue on your end?

  2. added a commit that references this issue on Aug 16, 2026
    078a6d1
  3. atirna commented on Aug 16, 2026

    @atirna

    I traced the version interaction a little further. e19bfa3 clones the input depth texture for the output and stable targets. In three r172, DepthTexture.copy() inherits Texture.copy() and the clones share the same Source/image; r174 changes that in three.js#30585. That matches the feedback error and leaves r172 inside this package's declared peer range.

    I'd like to prepare a focused EffectComposer change that creates independently configured depth textures instead of relying on clone() for that path, with a regression check for the r172 contract. Is keeping r172 working the right scope, or should the supported minimum move to r174?

  4. vanruesc commented on Aug 16, 2026

    @vanruesc
    Member

    👉 can you upgrade to r174 to verify if this fixes the issue on your end?

    I'd like to prepare a focused EffectComposer change [...]

    No need. See 078a6d1.

  5. vanruesc commented on Sep 9, 2026

    @vanruesc
    Member

    Should be fixed in v6.39.5

  6. added
    bugSomething isn't working
    compatibilityA problem that affects compatibility with external libraries
    and removed
    investigatingA potential bug that requires further research
    on Sep 9, 2026
  7. wowlegend commented on Sep 22, 2026

    @wowlegend
    Author

    Confirming the fix on three r172 — you asked me to verify and I never did, so here is the measurement.

    You asked "can you upgrade to r174 to verify if this fixes the issue on your end?" and the thread moved on before that was answered. It is answered now, and on the version you originally asked about rather than the upgrade.

    6.39.5 clears it on r172. Zero glBlitFramebuffer errors.

    postprocessing 6.39.5 (pinned exact)
    three 0.172.0
    @react-three/postprocessing 3.0.4
    @react-three/fiber 9.5.0
    renderer ANGLE (Apple, ANGLE Metal Renderer: Apple M3 Max)
    MAX_SAMPLES 4
    chain RenderPass → N8AO (halfRes) → GodRays → HueSaturation → BrightnessContrast → Bloom → SMAA → ToneMapping → Noise → Vignette

    Method: production build, real GPU (not SwiftShader), gl.getError() drained per frame rather than scraped from the console — the console undercounts by construction here, since Chrome mutes the context after ~256 errors and the storm exceeds that.

    frames: 1672   GL errors: 0 (0.00/frame)   codes: []   console blitFramebuffer hits: 0
    

    I also ran a controlled pair, because we had changed multisampling on our side and I did not want to credit your fix for something of ours:

    <EffectComposer multisampling> frames GL errors
    0 1672 0
    package default 1783 0

    Identical either way, so the MSAA path is not involved and 078a6d1 is doing the work.

    For the before side: on postprocessing 6.39.1 our own notes record the production console carrying the error in two alternating forms per frame, ~256 per load — and that number is a FLOOR rather than a count, because it is where Chrome stops reporting ("too many errors, no more errors will be reported to the console for this context"). I did not re-measure 6.39.1 with the per-frame getError() method, so I can compare "hundreds, ceiling-limited" against "zero over 1672 frames" but not two numbers gathered the same way.

    One note that may be useful to others landing here, since it is a different cause with the same message: N8python/n8ao#53 reports the same Read and write depth stencil attachments cannot be the same image arising from N8AO's halfRes MRT sharing a depth-stencil texture with the composer's inputBuffer, and reports it unaffected by upgrades through postprocessing 6.39.1 and three 0.184. We run halfRes and see zero on 6.39.5, so that path appears to be covered too — but it is a distinct mechanism and I have not isolated it, so treat that as an observation rather than a claim about their issue.

    Thanks for the quick turnaround on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompatibilityA problem that affects compatibility with external libraries

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions