MiguelMJ / Candle

2D lighting for SFML
http://www.miguelmj.dev/Candle/
MIT License
130 stars 8 forks source link

Setting light color has no effect when lights are drawn to a lighting area. #39

Closed CoreySelover closed 1 week ago

CoreySelover commented 1 month ago

Lights can have their color set, and if they are drawn by, say, the window, this color change is apparent.

However, if the light is drawn to a lighting area (at least in fog mode, I haven't checked ambient), the light's color is ignored. This is not only not the behavior one would expect, but means that one cannot use colored lights in conjunction with a lighting area, which is a desired behavior.

I'm not familiar with blend modes, so I don't know how the blend mode in use could be effectively altered to account for this but it would be nice.

MiguelMJ commented 1 week ago

Hello @CoreySelover

The behavior you describe is the expected one (see the fog tutorial here). Maybe it's not the most intuitive for everyone, but the reason is that you might want the light just to remove the fog without adding any color to your scene, so the fog doesn't use the color of the light.

If you want to remove the fog and also add color through the light, then you need to draw the light twice: once in the fog and once in the window (I honestly don't know how this could be optimized right now). This is, in fact, how it's implemented in the demo.

Thanks for reaching out!

MiguelMJ commented 1 week ago

Hello @CoreySelover

The behavior you describe is the expected one (see the fog tutorial here). Maybe it's not the most intuitive for everyone, but the reason is that you might want the light just to remove the fog without adding any color to your scene, so the fog doesn't use the color of the light.

If you want to remove the fog and also add color through the light, then you need to draw the light twice: once in the fog and once in the window (I honestly don't know how this could be optimized right now). This is, in fact, how it's implemented in the demo.

Thanks for reaching out!