Godot version:
Godot 3.1-beta3
Godot git 463123a661151f119132f2ee9af78925a58a068a
OS/device including version:
OS: Arch Linux x86_64
Kernel: 4.19.4-arch1-1-ARCH
GPU: NVIDIA GeForce 940MX
GPU: Intel HD Graphics 620
Issue description:
In a ShaderMaterial, DEPTH_TEXTURE seems to have incorrect data (usually 0.0 or 1.0, but sometimes glitches out with a couple random pixels with arbitrary values) with the GLES3 backend. With a similar project running Godot 3.0.6-stable (not the same project, since 3.1 didn't seem backwards compatible), the same shader code works properly (you can see geometry depth behind the plane if you put the camera close enough.) SCREEN_TEXTURE still works properly in 3.1-beta3 as well as 3.0.6-stable.
Minimal reproduction project:
depth_texture_test_case.zip
I can confirm this bug. I tested on a few versions (3.06, a1, b1, b2) and the bug was only present in beta3.
677d4400de9ae73713be9f33600f59a10a079c19 is the faulty commit. Adding an OmniLight with contact shadows enabled does indeed fix the issue.
This can likely be fixed by using a check similar to SCREEN_TEXTURE for DEPTH_TEXTURE, ie. writing to it when a shader uses it.
This issue should be fixed with #25557
Reopening as #25557 was reverted in 0eb61c3106 as it triggered #26258 (and @reduz says it's not the correct fix for this issue).
Out of curiosity, what would a more correct fix for #25557 be?
@akien-mga I think this should be part of the 3.1 milestone. Or at least part of an early round of bug fixes. Reading from depth is important for a lot of SpatialMaterial effects (depth fade, proximity fade, etc.).
I don't know if this is related to this problem, but I wanted to play around a bit with the Depth-buffer in an Shader and found this in the Godot-Asset-Library: https://godotengine.org/asset-library/asset/76
After downloading it, I stumbled upon the issue, that the intersection parts are not highlighted in Godot 3.1-Stable (this actually use the Depth-buffer to achieve the white borders) but is correctly working with Godot 3.0.6. So I guess this a bug and hopefully related to this issue here. I've uploaded two screenshots to make it more clear what I mean.
Specs:
Windows 10
Radeon RX 570 with the latest driver
Godot 3.0.6-Stable

Godot 3.1.0-Stable

@Nophlock yes, this is the result of the depth buffer not working.
Sorry to bother you. I don't quite understand the problem. The values I get in the fragment are all 1.0. Can you tell me how to get the correct value, or under what circumstances it is invalid.❤
Most helpful comment
@akien-mga I think this should be part of the 3.1 milestone. Or at least part of an early round of bug fixes. Reading from depth is important for a lot of SpatialMaterial effects (depth fade, proximity fade, etc.).