• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED] Drawing overlapped shadows, maintain alpha

Hi all,

I want to draw overlapped shadows, but without accumulated blending (I don't want the shadows to get darker as they are drawn on top of one another). Perhaps someone knows off the top of their head what blend mode might do the trick?

I have looked at the blend modes documentation, and the chart is not helping.

Cheers,
Nathan.
 
Yes, drawing to surfaces at alpha 1, and then drawing the surface at the desired (lower) alpha.
This would do, thank you Alex_Beach. However I was wondering if there was a blend mode that might offer a similar solution... but then I suppose there might be unwanted 'side-effects' when the underlying background colours differ...
 
However I was wondering if there was a blend mode that might offer a similar solution.
I think you can't do without surfaces. If you draw one shadow and then a new shadow with a blend mode you'd always either mix the second shadow with the area already darkened by the first shadow or completely ignore the destination. Both are not what you want.

Edit: removed clumsy-fingers-on-tablet-errors
 
Last edited:
Just thought I'd write back in with a code solution for reference' sake:

Code:
// draw event
if (surface_exists(shadow_surface))
{
    surface_set_target(shadow_surface);
    draw_clear_alpha(c_black, 0);
    //draw the desired shadow sprite(s) -- Know that the coordinates for a surface are always at 0, 0 (not the room or view coordinates)
    draw_sprite(some_sprite, 0, 64, 64); // 64 here represents the center point of the 128x128 pixel shadow surface, (draw here if wanting to center the sprite in the surface)
    surface_reset_target();
    else
    {
         shadow_surface = surface_create(128, 128); // 128 is arbitrary here. This typically might be a size large enough to contain some sprite, i.e. a sprite <= 128x128 pixels in size
         surface_set_target(shadow_surface);
         draw_clear_alpha(c_black, 0);
         surface_reset_target();
    }

draw_surface_ext(shadow_surface, x-64, y-64 1, 1, 0, c_black, 0.4); // x & y would be the location in the game room to draw the shadow surface. Since surfaces are always drawn from the top left corner, the offset of 64 here represents half the size of the surface, which will position the surface centered squarely over the location at x and y
 
Top