godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
87.35k stars 19.62k forks source link

OpenGL - depth clear issue in directional shadow atlas #84558

Open BastiaanOlij opened 8 months ago

BastiaanOlij commented 8 months ago

Godot version

4.2.dev 5ee983188de97ae027f9b9c1443438063f708a7e

System information

Windows - OpenGL

Issue description

I may have introduced this in the work I'm doing right now but just in case this is a more serious issue I don't want to loose track of it. Don't have time to investigate it right now.

In LightStorage::update_directional_shadow_atlas the code:

glDepthMask(GL_TRUE);
glBindFramebuffer(GL_FRAMEBUFFER, directional_shadow.fbo);
RasterizerGLES3::clear_depth(1.0);
glClear(GL_DEPTH_BUFFER_BIT);

Results in:

ERROR: GL ERROR: Source: OpenGL Type: Undefined behavior  ID: 131222  Severity: Medium
Message: Program undefined behavior warning:
The current GL state uses a sampler (0) that has depth comparisons enabled,
with a texture object (1018) with a depth format,
by a shader that samples it with a non-shadow sampler.
Using this state to sample would result in undefined behavior

(edited for readability)

Steps to reproduce

Create a project using the compatibility renderer with a directional light, and turn it on.

Minimal reproduction project

n/a

dqanxy-umich commented 8 months ago

Hello,

Hope people don't mind that I try to investigate this. Currently working on a school project where I need to contribute to an open source project.

Calinou commented 8 months ago

Hope people don't mind that I try to investigate this. Currently working on a school project where I need to contribute to an open source project.

Feel free to open a pull request for this 🙂

dqanxy-umich commented 8 months ago

Hello, I cannot seem to replicate this issue. Is this using the 3D directional light? Are you able to replicate this on a new empty project?

germanbv commented 8 months ago

after updating from 4.1 to 4.2-stable I started to experiment this issue every time I open my project:

drivers/gles3/rasterizer_gles3.cpp:176 - GL ERROR: Source: OpenGL Type: Undefined behavior ID: 131222 Severity: Medium Message: Program undefined behavior warning: The current GL state uses a sampler (0) that has depth comparisons enabled, with a texture object (1020) with a depth format, by a shader that samples it with a non-shadow sampler. Using this state to sample would result in undefined behavior

I have a 2D project and I don't use directional light anywhere..

joined72 commented 7 months ago

I attached a MRP

test.zip

willnationsdev commented 3 months ago

First time I've touched Godot in a little while, but just reporting that I've been getting this same error & it completely prevents me from using the OpenGL renderer on my system.

  1. Create a new project with "Compatibility" renderer.
  2. Click button to add a Node2D to the current scene.
  3. Click "Ctrl+S" to save scene

OR

  1. Create a new project with "Compatibility" renderer.
  2. Mouse over any of the files in the FileSystemDock to generate the info/preview popup.

In each case, the popup that appears will have zero content and then the entire Godot process (editor & popups) stop responding.

Tested with 4.2.1 stable and 4.3.0-dev.5 (mono releases)