GameMaker Why is my additive lighting creating darker areas?

mattmls00

Member
So I am working on an additive lighting system similar to many of the online tutorials. I am having one major issue. Where the lights overlap, I am actually getting areas that appear to be darker, not lighter. After reading the YoYo Games blog post about blend modes, I thought bm_add could only make things lighter.

I am creating a lighting surface, clearing it to black, and then drawing a light circle using circle_draw_color with a gradient from orange to black. Then I draw this surface over the application surface using a multiply blend mode. Here is an example of the issue:
lights.png

Just to list some of the things I have tried:
-Using sprites instead of draw-circle-color
-Using different colors and trying extended blend modes
-Not using a gradient color, but this produces really hard lines that I don't like


I am thinking maybe I need a shader but have no idea what I would do with it. I am hoping someone can help me as I have been beating my head against the wall with this for a few days and even tried the dev discord, but no solutions so far.

Thanks guys.
 
R

robproctor83

Guest
"Then I draw this surface over the application surface using a multiply blend mode"

If your creating a multiply blend mode, then that is the issue, you want to use additive.

*edit, but thinking about that mode it's probably not what you want either. Regardless, multiplying the surface is your problem. It's hard to know what is going exactly from that screen, but I am assuming that it has something to do with how you are drawing the circles. How many are in your screen? 3? When you draw the circles are you blending them, or just drawing them? You should draw the main light surface without any blend mode first to get the circles on the surface how you want. Keep in mind anything not 100% white will come through as darker in multiply blend.
 
Last edited by a moderator:

mattmls00

Member
"Then I draw this surface over the application surface using a multiply blend mode"

If your creating a multiply blend mode, then that is the issue, you want to use additive.

*edit, but thinking about that mode it's probably not what you want either. Regardless, multiplying the surface is your problem.
I may not have been clear with my writing, but I am drawing the lights with bm_add, to the light surface and then drawing the entire surface with multiply so you can see through that surface.

If you were meaning that I need to draw my lighting surface to the application surface with an additive blend as well, that makes it so my entire level is covered in opaque colors.

But if you think either option may not work, then I am back to square one.
 

mattmls00

Member
I guess I am mainly confused because if all the bm_add blend mode does is add RGB values then even a very dark color blended with another very dark color should get lighter.

For example a dark orange: RGB(80, 40, 0) + RGB(80, 40, 0) = RGB(160, 80, 0)

It makes me wonder if there is an issue with the color blending. It seems to work as expected with brighter colors in the gradient, which is even more odd.

I am just not sure what it could be doing at this point.
 

mattmls00

Member
Okay so I finally figured out something that works. Maybe this is part of what you are trying to explain. But this is what I did.

Draw all my lights onto a surface with NO blend mode. The lights are now sprites with a gradient from any given color to transparent. So I let their transparency handle the blending in a sense.

Then I draw that onto another surface with bm_add. And then finally draw this combined surface with a multiply blend mode. Hopefully that makes sense.

I am just glad to finally have a better solution after days of toying with this.
 
Top