Skip to content

GLES2 WebGL DEPTH_TEXTURE Feedback loop error #46883

Description

Issue description:
I am trying to use this snippet https://docs.godotengine.org/en/3.2/tutorials/shading/screen-reading_shaders.html#depth-texture
to create post-processing shader which uses pixels world position to calculate new color.

It doesn't seem to work on browser with GLES2 if modifying ALBEDO and console gets filled with:
GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture.

However it seems to work with GLES3 on HTML5 but isn't GLES3 going to be deprecated for browser? Also for me HTML5 GLES3 projects loads longer when starting it.

Here is the shader:

shader_type spatial;

void vertex() {
	POSITION = vec4(VERTEX, 1.0);
}

void fragment() {
	// https://docs.godotengine.org/en/3.2/tutorials/shading/screen-reading_shaders.html#depth-texture
	float depth = textureLod(DEPTH_TEXTURE, SCREEN_UV, 0.0).r;
	vec4 upos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
	vec3 pixel_position = upos.xyz / upos.w;
	
	// Lines below triggers the bug (on browser only)
	ALBEDO = vec3(1.0, 1.0, 1.0) * pixel_position.x;
}

On native and Godot editor the shader works as expected and you should see this:
bug

Godot version:
3.2.3.stable.official

OS/device including version:
Linux with Nvidia Drivers (460.39) - WebGL with GLES2
Chromium 89

Minimal reproduction project:
GLES2 Webgl Bug.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions