godotengine / godot

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

2D Lights with wrong textures and zoom flickering #77241

Closed caioraphael1 closed 5 months ago

caioraphael1 commented 1 year ago

Godot version

4.0.3 (the problem hasn't been fixed yet in 4.2-beta3)

System information

windows 10, Ryzen 3 3300x, 16gb RAM 2666mhz, GTX 1660 6gb.

Issue description

There are 2 major hallucinations:

  1. The 2D Lights are turning on and off depending on the zoom I do in the editor. This is not just a 'visual bug', as this actually changes the casted shadows in the game.
  2. The texture used in the PointLight2D is loading other 3 (or more) textures when I load any texture. For example: if the texture field is blank, and then I load a simple circle texture for the light, suddenly there is a whole atlas of random textures being loaded together with this simple circle.

"Why are you reporting 2 issues in the same thread?" Because my guess is that both are related. I started having both issues around the same time, both are related to light and both are really weird.

For more information, mess around with the uploaded Demo. But also, I've made a lot of videos with examples on the Godot Discord server. if I'm not clear enough with the explanation of the bug, it's because I'm confuse myself, so please check out the videos in this thread.

https://discord.com/channels/212250894228652034/1102589457187754046

bug

Steps to reproduce

For the 1st issue: Honestly, I'm not sure. This is happening for the most simple node. As such:

  1. Create a new Node2D scene.
  2. Create a PointLight2D node.
  3. Drag or load any texture to the texture slot.
  4. For visualization: create a ColorRect and give it the following shader: "shader_type canvas_item; void light() { if (LIGHT_COLOR.a > 0.1) { discard; }"
  5. The end. Now with the help of this shader you can see where there's light in the scene.

For the 2nd issue: I'm not sure either.

  1. Create a new Node2D scene.
  2. Create a PointLight2D node.
  3. Maybe create more PointLights2D.
  4. Try zooming in and out. Usually around ~200% or ~400% zoom the lights start turning on and off.

Minimal reproduction project

In the Demo below there are 2 main worlds. Make sure to see both.

Demo - Glitchy Lights.zip

Calinou commented 1 year ago

Can you reproduce this after switching to the Compatibility rendering method in the top-right corner of the editor?

caioraphael1 commented 1 year ago

Can you reproduce this after switching to the Compatibility rendering method in the top-right corner of the editor?

yes, both problems happen in Forward+ and Compatibility.

caioraphael1 commented 11 months ago

The problem still exists in 4.2.beta3. Considering how weird and specific this bug is, could anyone tell me a bit how and where can I check the source code to try and find the bug cause?