Skip to content

Incorrect use of depth texture attachments #225

Closed

Description

@vanruesc

Description of the bug

The current depth texture system assumes that a depth texture can be assigned to a render target at any time. This assumption is incorrect as render targets are initialized once when they are used. Certain pass chains will cause the internal frame buffer to be initialized with a basic depth buffer attachment and the subsequent assignment of a depth texture won't have any effect. As a result, the depth texture won't contain the depth information of the rendered scene.

To Reproduce

  1. Add a ClearPass to the composer.
  2. Add a RenderPass to the composer.
  3. Add an EffectPass containing a depth-based effect such as SSAOEffect to the composer.
  4. See the effect fail due to missing depth information.

Expected behavior

Depth-based effects shouldn't fail with certain pass chains. One potential solution would be to assign the depth texture to a dedicated render target for geometry passes. Going one step further, a more complex render target management system could be implemented to allow passes to explicitly define input and output buffers.

Library versions used

  • Three: 0.120.0
  • Post Processing: 6.17.1

Activity

  1. vanruesc commented on Aug 30, 2020

    @vanruesc
    MemberAuthor

    Added a temporary fix in [email protected].

  2. added
    enhancementEnhancement of existing functionality
    and removed
    enhancementEnhancement of existing functionality
    on Sep 16, 2020
  3. alexpineda commented on Feb 18, 2021

    @alexpineda

    I'm having this issue with 6.19.3. I'm not sure if it's something I'm doing something wrong on my end but seeing this ticket it seems to confirm my suspicion of missing depth information, even though the needsDepthTexture and the following logic execute correctly. My example follows closely to yours, RenderPass with clearPass enabled -> EffectPass with DepthEffect. Also important to note that I'm able to use DoF and SMAA, both of which use depth, without issue. Edit: Never mind this. It's just that my camera is really far away. I had assumed the depth information would be relative. Cheers.

  4. vanruesc commented on Feb 11, 2024

    @vanruesc
    MemberAuthor

    Depth texture management is fixed in the postprocessing v7 alpha which will eventually replace v6.

    I'm keeping this ticket open until v7 lands in case someone stumbles over this bug.

  5. hybridherbst commented on Mar 25, 2025

    @hybridherbst

    I believe we're also running into this issue. I can see there's ongoing changes to v7 – do you feel the beta is ready for testing?

  6. vanruesc commented on Mar 25, 2025

    @vanruesc
    MemberAuthor

    Yes, v7 is ready for testing and has become much more stable since the first beta release.

    There are currently three main issues that prevent a full release:

    1. Removing this onBeforeCompile crutch (WebGLRenderer: Auto shader output definitions for MRT mrdoob/three.js#27808).
    2. Better management of backgrounds/skyboxes (for G-Buffer purposes).
    3. Adding more essential Effects like DoF, SSAO, SSR.
  7. vanruesc commented on Mar 20, 2026

    @vanruesc
    MemberAuthor

    Should be fixed in v6.39.0.

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

    v6Relates to version 6

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions