Closed wagnerfs closed 23 hours ago
Try length(view.xyz)
instead of -view.z
in the shader. d
isn't a view-space depth, but a world-space distance, so comparing with depth will only appear correct near the center of the view. length(view.xyz)
should give you a view-space distance to camera instead.
EDIT: Forgot view was a vec4.
@stoofin you're right, that fixed it, thanks a lot!
Tested versions
System information
Windows 10 - v4.3.stable.steam [77dcf97d8]
Issue description
I honestly have no clue where the problem lies, I basically followed this https://www.youtube.com/watch?v=jH0MD8obOCQ for a metaballs-ish approach and I'm manually setting the spheres positions using spawned rigidbodies. Someone else has followed the exact same process from the video that should supposedly work but did not so I assume something changed from past versions to 4.3.
Camera from far:
Camera near:
Seen someone on Reddit with the same issue:
https://github.com/user-attachments/assets/53430bec-aaea-4e8e-99ed-690b3a594ed7
Link: https://www.reddit.com/r/godot/comments/1dza1sm/issue_with_reading_depth_buffer_for_raymarching/
Steps to reproduce
Teste scene and shader included in the minimal reproduction project.
Minimal reproduction project (MRP)
metaballs.zip