godotengine/godot

GLES2 WebGL depth texture not draw

danilw opened this issue · 6 comments

Godot version:
3.2 stable

OS/device including version:
Chrome 78 /Firefox 70, Linux and Windows

Issue description:
GLES2 Depth texture not work when it supported by device/hardware(webbrowser)

Docs https://docs.godotengine.org/en/3.2/tutorials/misc/gles2_gles3_differences.html :

While GLES2 supports DEPTH_TEXTURE in shaders, it may not work on some old hardware (especially mobile).

it means Godot do check if device support Depth, and use it when supported.
I have support depth texture in GLES2 in webbrowser, Godot do not use it.
Webgl does Depth support https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_depth_texture

Steps to reproduce:

  1. open this link example project in browser, depth not draw
  2. open webbrowser console write
var canvas = document.createElement('canvas');var gl = canvas.getContext("webgl");console.log(gl.getSupportedExtensions());

WEBGL_depth_texture listed

1

Minimal reproduction project:
source zip link

Web

Please provide details about the OS and browser(s).

Web

Please provide details about the OS and browser(s).

Chrome 78 /Firefox 70, only Linux

@danilw Which graphics card and driver are you using? You can check the list of supported extensions here.

@Calinou look my screenshot in first post, please
this is not video card, I have AMD Vega and Nvidia with latest drivers, GLES2 Depth work in native Godot builds(GLES2) and in webbrowser (in WebGL outside Godot web build, in Godot web it does not work)

in Godot web build Depth work only in WebGL2 build(GLES3)

I have test it in Windows webbrowsers, same Depth does not work in GLES2 Godot in Web

This is expected behaviour. Take a look at the error you get when running the scene you provided:

GL ERROR :GL_INVALID_OPERATION : glDrawElements: Source and destination textures of the draw are the same.

Certain hardware (and platforms, including webgl) do not support reading from a bound depth texture. The WEBGL_depth_texture extension means your hardware supports using the depth texture. It says nothing about reading and writing at the same time.

That note in the docs is particularly pointing to this situation. Godot allows you to read from the depth_texture, however, your hardware (in this case platform) just doesn't support it. The only way to "fix" this would be to go back to the previous hardware and not allow anyone to use the depth_texture in shaders because it cannot be supported on all hardware and platforms.

okey I see, thanks for clarification
can be closed I think