• 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!

Help with Surfaces

D

DanielBartley

Guest
Hey guys,

I'm an experience gm user since 6.1, and haven't touched gm in a few years.

i having some dramas with surfaces.

what I'm attempting to achieve is use a 'bloom' sprite to light up another sprite on the surface, and crop it so that it just leaves the 'bloomed' part of the image, which i will then draw.

As seen in the pic below, 1 is the original background, which would display completely if the bloom completely covered the image, 2 shows the actual bloom, and 3 the result I am after.

Any help would be highly appreciated.

Thanks

CODE:
if (!surface_exists(mask_surface)) {
mask_surface = surface_create(256, 256);
surface_set_target(mask_surface);
draw_clear(c_black);
gpu_set_blendmode(bm_subtract);

//draw_sprite(sprite2, 0, 128, 128);
draw_circle(128, 128, 70, false);
gpu_set_blendmode(bm_normal);
surface_reset_target();
}
if (!surface_exists(clip_surface)) {
clip_surface = surface_create(256, 256);
}

surface_set_target(clip_surface);
draw_clear_alpha(c_black, 0);

gpu_set_blendmode(bm_subtract);
draw_sprite_ext(sprite0, 0, 64, 64, 2, 2, 0, c_white, 1);
gpu_set_blendmode(bm_add);
draw_sprite(sprite2, 0, mouse_x - clipx - 32, mouse_y - clipy - 32);
//draw_circle(mouse_x - clipx, mouse_y - clipy, 40, false);

gpu_set_blendmode(bm_subtract);
draw_surface(mask_surface, 0, 0);
gpu_set_blendmode(bm_normal);

surface_reset_target();
draw_surface(clip_surface, clipx, clipy);
 

Attachments

samspade

Member
I feel like there are a couple issues, but I don't remember blendmode operations well enough to say for sure. My best suggestion is use the GMS 2 debugger. There's a graphics tab where you can view all surfaces currently in use. So you can set some breakpoints, step through the above code, and see at each step what is being drawn.

Some random things which may or may not be helpful specifically, but are definitely helpful generally on this subject:


Blendmodes GML Reference
 
Top