-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Add DepthPass shader #16999
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
Add DepthPass shader #16999
Conversation
Render the depth buffer, useful when you post process only part of the geometry in your application, you can then draw that geometry over the depth buffer from the non-post processed geometry.
| this.scene.overrideMaterial = null; | ||
| renderer.clearDepth(); | ||
| renderer.setRenderTarget(this.renderToScreen ? null : readBuffer); | ||
| renderer.context.colorMask(false, false, false, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally avoid making gl calls directly because it can mess up the renderer's internal state. You may have to do this:
renderer.state.buffers.color.setMask( ... );There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is sort of an awkward API, but it works for you, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is working, I will think about a demo, for now it is a contract job that I cannot post anything but the depth pass, which I am using for another personal side project, so happy to share.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it work to add it to one of the boxes in this example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do, the main use case I have found is post processing transparent objects like lines and particles that wrap around, through and behind solid objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something cool like that would be ... cool. :-)
|
@mrdoob Why do we have |
I expect there are a lot of users who would appreciate seeing an example of that. |
I think |
|
Agreed that a simple example of the usage would be great. Also to ensure we don't beak it. |
|
Do we need an example for this? |
|
I don't think this PR is acceptable since a depth pass should not render the scene with the same potentially expensive PBR materials than the beauty pass. AFAIK, doing Besides, I've often encountered situations where I want to sample the depth of the scene in the fragment shader of different object. Check out how the water foam is rendered in this example: https://codesandbox.io/s/black-mountain-gojcn Currently, I use this pattern: scene.overrideMaterial = depthMaterial;
renderer.setRenderTarget(renderTarget);
renderer.render(scene, camera);
renderer.setRenderTarget(null);
scene.overrideMaterial = null;where |
|
Closing for now. This needs to be implemented differently. #8676 actually looks more promising. |
Render the depth buffer, useful when you post process only part of the geometry in your application, you can then draw that geometry over the depth buffer from the non-post processed geometry.