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

depth_buffer and camera glitches. #43575

Closed
Lexpartizan opened this issue Nov 15, 2020 · 2 comments
Closed

depth_buffer and camera glitches. #43575

Lexpartizan opened this issue Nov 15, 2020 · 2 comments

Comments

@Lexpartizan
Copy link

Lexpartizan commented Nov 15, 2020

Godot version:

3.2.3 stable win64.

OS/device including version:

Windows 10 ver 1607, gtx 1050, GLES 3.

Issue description:

Everything looks very correct in the editor. However, if I turn on preview or try to get the depth_buffer texture, I have the glitches described in the video. Although the Shader behavior is normal in the editor. The Shader itself is taken from the official tutorial.
https://youtu.be/BqOoxzMxWP0

Steps to reproduce:
When I switch the camera to orthogonal mode, I get white instead of black. When I move the plane with the Shader away from the camera and it approaches y=0, the main color approaches white, although this should not be the case, because there are no objects deeper. In the editor, everything is displayed normally and as expected. If I get the world coordinates from depth_buffer and perform more complex calculations, taking into account the height of the camera, then both the perspective and orthogonal camera work as expected (in the correct_works_depth Shader). However, if the plane with the depth_buffer Shader is lowered, it also turns white, as if there is a plane in y=0.0 coordinates.

Minimal reproduction project:
error ortho cam.zip

PS. I also noticed that for an orthogonal camera, I can only get the depth buffer, but not the 3D position, since xy is simply not displayed, unlike a perspective camera. I'm not sure that's the way it should be.

@lmsonic
Copy link

lmsonic commented Jul 19, 2023

Can reproduce in 4.1.1 after porting the project.
It looks like it lerps from black to white in the interval from the camera near plane to the far plane. The depth shader script lerps it only for perspective cameras, showing white only for orthogonal cameras, whilst the correct_works_depth shader lerps it for both orthogonal and perspective. This behavior only happens in the camera preview and when playing the scene, while in the editor the quad remains always black.

However, apart from inconsistencies in perspective and orthogonal cameras I think this behaviour is intended? The depth buffer goes from 0.0 to 1.0 depending on the distance to the far plane which are interpreted as black and white. I'm a bit confused. The reason why it goes near white when the plane is near y=0 in the OP is because the far plane is set to 30 and the camera is at y=20 pointing down.

MRP ported to Godot 4:
43575.zip

Video reproducing the issue:

godot_issue43575.mp4

@Calinou Calinou added documentation and removed bug labels Jul 19, 2023
@Calinou
Copy link
Member

Calinou commented Jul 19, 2023

Closing in favor of #48202, which is more detailed and covers the same issue.

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

No branches or pull requests

3 participants