-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
WebGPU - Duplicate shadow when logarithmicDepthBuffer is true - Shadow appears below and above object (WebGPU build 167) #29200
Comments
I've been playing around with the Link to version 168: https://unpkg.com/browse/three@0.168.0/build/three.webgpu.js if ( renderer.coordinateSystem === WebGPUCoordinateSystem ) {
coordZ = coordZ.mul( 2 ).sub( 1 ); // WebGPU: Convertion [ 0, 1 ] to [ - 1, 1 ]
} |
It looks like this particular issue has come up several times in the past with WebGL and was eventually fixed. Here are the relevant historic issues and a pull request for WebGL: Issue: #7815 Hopefully the fix for WebGPU is the same? I also found this pull request for WebGPU that appears to be related: #27243 I've tinkered around with the depth calculation nodes and was able to get the shadow working (somewhat) by changing this code in three.webgpu.js (excerpt is from the // three.webgpu.js v168 (line 32506)
// https://unpkg.com/browse/three@0.168.0/build/three.webgpu.js
const fragDepth = modelViewProjection().w.add(1);
depthNode = fragDepth.log2().mul(cameraLogDepth).mul(0.5); to this: depthNode = viewZToOrthographicDepth(positionView.z, cameraNear, cameraFar); Can someone tell me what's going on here? |
Fixed in this pull request I just submitted: #29447 |
1) Disabled logarithmic depth buffer for orthographic cameras. 2) Removed "cameraLogDepth" node from Camera.js as it is no longer used in the perspective-to-logarithmic depth conversion. 3) Ensured that modelViewProjection.w is used for perspective-to-logarithmic depth conversion, and that positionView.z is always used for orthographic cameras. 4) Adapted Outerra's logarithmic depth buffer formula, re-added "C" constant for increased resolution close to the camera, per Outerra's findings. (issue mrdoob#29200, PR mrdoob#29447)
1) Removed "cameraLogDepth" node from Camera.js as it is no longer used in the perspective-to-logarithmic depth conversion. 2) Removed "cameraIsPerspective" and "cameraIsOrthographic" nodes that were added in a previous commit 3) Ensured that modelViewProjection.w is used for perspective-to-logarithmic depth conversion, and that positionView.z is always used for orthographic cameras. 4) Adapted a modified version of Outerra's logarithmic depth buffer without requiring a "C" constant (issue mrdoob#29200, PR mrdoob#29447)
1) fixed bug where the shadowmap's "coordZ" was not getting set when not using WebGPU 2) fixed typos in comments (issue mrdoob#29200, PR mrdoob#29447)
…icDepthBuffer` (#29447) * Fixed shadows not rendering correctly when logarithmicDepthBuffer = true (issue #29200) * Further improvements to the logarithmic depth buffer shadows bugfix: 1) Disabled logarithmic depth buffer for orthographic cameras. 2) Removed "cameraLogDepth" node from Camera.js as it is no longer used in the perspective-to-logarithmic depth conversion. 3) Ensured that modelViewProjection.w is used for perspective-to-logarithmic depth conversion, and that positionView.z is always used for orthographic cameras. 4) Adapted Outerra's logarithmic depth buffer formula, re-added "C" constant for increased resolution close to the camera, per Outerra's findings. (issue #29200, PR #29447) * Further improvements to the logarithmic depth buffer shadows bugfix: 1) Removed "cameraLogDepth" node from Camera.js as it is no longer used in the perspective-to-logarithmic depth conversion. 2) Removed "cameraIsPerspective" and "cameraIsOrthographic" nodes that were added in a previous commit 3) Ensured that modelViewProjection.w is used for perspective-to-logarithmic depth conversion, and that positionView.z is always used for orthographic cameras. 4) Adapted a modified version of Outerra's logarithmic depth buffer without requiring a "C" constant (issue #29200, PR #29447) * Further improvements to the logarithmic depth buffer shadows bugfix: 1) fixed bug where the shadowmap's "coordZ" was not getting set when not using WebGPU 2) fixed typos in comments (issue #29200, PR #29447) * cleanup
Description
Note: I'm using the WebGPU build 167 of three.js for this report.
See screenshot, JSFiddle, and provided code. I have a simple sphere between two "floors", with a
DirectionalLight
pointing straight down from above. Notice how the sphere casts a shadow on the top "floor". This top shadow appears whenlogarithmicDepthBuffer
istrue
. How can I remove the shadow from the top floor? I don't want to disablelogarithmicDepthBuffer
, because I need it elsewhere in my scene. I also don't want to disable the top floor's ability to receive shadows from other objects, so I can't setreceiveShadow = false
on the top floor mesh.JSFiddle: https://jsfiddle.net/0fwkyvu6
discourse thread: https://discourse.threejs.org/t/duplicate-shadow-shadow-appears-below-and-above-object-webgpu-build-167/69481
StackOverflow question: https://stackoverflow.com/questions/78893677/three-js-duplicate-shadow-issue-bug-shadow-appears-below-and-above-object
Update 1: setting
logarithmicDepthBuffer: false
appears to fix the issue somewhat, however the logarithmic depth buffer is a requirement for my scene, so I'd like to get the shadow working with it.Update 2: the top shadow is not visible in the standard WebGLRenderer build of three.js, so there must be some issue specifically with the WebGPU build.
Reproduction steps
Please use the provided code to reproduce the issue.
Code
Version
167
Device
Desktop
Browser
Chrome, Edge
OS
Windows
The text was updated successfully, but these errors were encountered: