godotengine / godot

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

Light2D affects alpha-channel unexpectedly #49251

Open bluepandion opened 3 years ago

bluepandion commented 3 years ago

Godot version: 3.3.2 stable

OS/device including version: Windows 10, Nvidia GTX-960

Issue description: Light2D affects alpha-channel and produces visible aliasing when lighting is strong enough. All affected non-zero alpha values are seemingly increased, until the resulting image looks as if it had 1-bit alpha.

This is especially apparent when textures have soft alpha-gradients or large areas that are partially transparent.

Proposal behavior for Light2D additive blend mode: source.RGB = source.RGB + (light.RGB * light.A)

This issue is present in both GLES2 and GLES3

Steps to reproduce: Add a Sprite with partially transparent areas. Add a strong Light2D or multiple lights that affect the sprite.

Minimal reproduction project: light2d_alpha_channel.zip

image image

Calinou commented 3 years ago

Related to https://github.com/godotengine/godot/issues/31824 and https://github.com/godotengine/godot/issues/8685. Can you check if either of those issues are duplicates?

bluepandion commented 3 years ago

Related to #31824 and #8685. Can you check if either of those issues are duplicates?

I don't think they are duplicates, because they seem to affect rendering based on bounding boxes of the lights. Based on those issues I'd guess masking somehow needs to disable any other lights that would affect the same pixels, but I'm only guessing.

This issue affects single pixels, not whole nodes.

lawnjelly commented 3 years ago

Can confirm this has existed since at least Godot 3.1.2. I'm not sure whether it is a bug, or a feature.

golddotasksquestions commented 3 years ago

Definitely not a feature, this is very unwanted behaviour. Alpha should be conserved.