godotengine / godotengine/godot

Compatibility renderer: lights seem brighter when their shadows are enabled

Open
#90,259 20 comments 16 reactions 0 assignees View on GitHub
documentation topic:3d topic:rendering
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: 4.2.0, 4.3.dev5

### System information

Godot v4.3.dev5 - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce GTX 1060 6GB (NVIDIA; 31.0.15.3713) - Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz (4 Threads)

### Issue description

When using the compatibility renderer, enabling shadows on a light will make lit surfaces brighter. This happens for directional (over the whole scene), omni and spotlights.

If the ambient light is made black, the problem goes away. If shadows are disabled for all lights, the problem also goes away. If multiple lights have shadows turned on, the problem is more pronounced than if a single light has shadows turned on. It looks like the ambient light might be applied one extra time for each light with shadows enabled.

This seems to have been introduced when compatibility renderer shadows were first added. Forward plus and mobile renderers are not affected.

Comparison of a scene with a default world environment lit by a single directional light with shadows disabled and enabled:

![Compatibility_ShadowsOff](https://github.com/godotengine/godot/assets/23417591/4cee3255-718c-48da-b3d5-be1b1e9eb2b7)
![Compatibility_ShadowsOn](https://github.com/godotengine/godot/assets/23417591/bb396fb0-1e1e-4a88-9bb0-d36a4f778c72)

### Steps to reproduce

Run the project with F5. Press 'S' to toggle shadows on the directional light on and off. Observe how surfaces get brighter when shadows are on.

### Minimal reproduction project (MRP)

[CompatShadowRepro.zip](https://github.com/godotengine/godot/files/14884361/CompatShadowRepro.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the linked CompatShadowRepro.zip project, run it with F5, and press S to reproduce the brightness change in the compatibility renderer. Trace the compatibility renderer's shadow and ambient-light handling for directional, omni, and spot lights; done means enabling shadows no longer increases lit-surface brightness, including with multiple shadowed lights.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, godot
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.