Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differences between RenderPass.depth and DepthPass #330

Closed
swingingtom opened this issue Dec 11, 2021 · 4 comments
Closed

Differences between RenderPass.depth and DepthPass #330

swingingtom opened this issue Dec 11, 2021 · 4 comments
Labels
question Further information is requested

Comments

@swingingtom
Copy link

Hi, Im not sure this is a bug, but as I didn't find any information in documentation or in existing issues, I create one.

Description of the bug

DepthPass doesn't produce the same results as RenderPass+DepthSavePass.
DepthPass seems to ignore : material.depthWrite=false , material.side , material.alpha|material.alphaTest

To Reproduce

Compare the results of both https://codesandbox.io/s/depthpass-vs-renderpass-depthsavepass-5bos0
Toggle DepthPass>>Show/Hide from the gui to compare both depth

Expected behavior

Should'nt both ways produce the same results ?

Screenshots

RenderPass
image

Depth( from RenderPass )
image

Depth( from DepthPass )
image

Library versions used

  • Three: 0.132.2
  • Post Processing: 6.23.3
@vanruesc
Copy link
Member

DepthPass seems to ignore : material.depthWrite=false , material.side , material.alpha|material.alphaTest

That is correct; it's a limitation of three's override material system. The DepthPass uses a MeshDepthMaterial to render the depth of objects into a render target. It ignores individual settings of the original materials for performance reasons.

The RenderPass + DepthSavePass combo works because the DepthSavePass enables an internal depth texture attachment for the RenderPass. The resulting depth is correct because all objects use their original materials, including custom depth materials. The DepthPass ignores those too.

You can enable the override material workaround which was primarily created to support skinned and instanced meshes. It supports the side parameter, but not alphaTest, depthWrite, and probably many other settings.

Trying to handle all possible values of built-in materials, not to mention custom shaders, is not feasible. The best solution is to use MRT instead, but it's a change that needs to happen in postprocessing, not in user code, and I'm working on it.

@vanruesc vanruesc added the question Further information is requested label Dec 26, 2021
@swingingtom
Copy link
Author

Hey ! Sorry for the super long delay.
Thank you for the answer. I was expecting such performance reasons.

I could indeed adjust granularity of depth using available options DepthPass and OverrideMaterial workaround or simply rely on DepthSavePass.

I will therefore close this issue.

But is there any other differences? On the internal structure or something else? I tried to replace DepthPass with DepthSavePass in godrays example as explained here #331 but something works different, and I struggle to find what.

@iuriiiurevich
Copy link

Trying to handle all possible values of built-in materials, not to mention custom shaders, is not feasible. The best solution is to use MRT instead, but it's a change that needs to happen in postprocessing, not in user code, and I'm working on it.

@vanruesc Are there any updates on this?

I ran into an issue when using SelectiveBloomEffect (which internally uses DepthPass) on meshes with ShaderMaterial, so the vertex shader is not being applied to the depth texture, resulting in a difference in vertex positions between objects on the screen and the bloom result (which is expected)

@vanruesc
Copy link
Member

Are there any updates on this?

@iuriiiurevich Progress has been made but #419 skipped over a lot of details that I need to figure out as I go. There will be a big commit in the next few days to establish the baseline for v7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants