TheCheeseMaster
Member
Hi everyone,
I'm working on a top down perspective game that has a day/night cycle. I've got some lights in the game, and am using the blendmode bm_add when drawing them on the night sky surface (night_cycle_surf). After the lights are drawn, the surface is drawn over the player's view and all is good, except... those lights appear on top of some objects that are meant to be in front of them (as shown here)
Above, you can see two clear problems with the lights. The street lamp's light is shining onto the roof of the house across the street, and the bus's lights are shining through the house itself.
Here's how I'm coding this current system...
DRAW EVENT CODE for the obj_TOD (time of day object):
So, I need to find a way to block those lights from shining through objects meant to be in front of them. I was chatting with a friend and he suggested a solution where the objects blocking the light (I'm calling them light covers) are drawn onto the night cycle surface after the lights are, but since the lights are using the bm_add blendmode they still shine through.
Is there a way I can draw the light covers onto the surface after the lights in a way that can counteract the bm_add effect of the lights? I'd love to hear some suggestions as my current solution leaves many rooms for errors.
I'm working on a top down perspective game that has a day/night cycle. I've got some lights in the game, and am using the blendmode bm_add when drawing them on the night sky surface (night_cycle_surf). After the lights are drawn, the surface is drawn over the player's view and all is good, except... those lights appear on top of some objects that are meant to be in front of them (as shown here)
Above, you can see two clear problems with the lights. The street lamp's light is shining onto the roof of the house across the street, and the bus's lights are shining through the house itself.
Here's how I'm coding this current system...
DRAW EVENT CODE for the obj_TOD (time of day object):
GML:
if(outdoors == true)
{
if(!surface_exists(night_cycle_surf))
{
night_cycle_surf = surface_create(camera_get_view_width(view_camera[0]) * 1.2,camera_get_view_height(view_camera[0]) * 1.2);
}
surface_set_target(night_cycle_surf);
draw_clear(tod_colour); //created the surface and told it to be black
//ACCOUNT FOR LIGHTS
if(lights == true) //aka obj light exists
{
gpu_set_blendmode(bm_add);
with(obj_light)
{
if(active == true)
{
draw_set_alpha(g_alpha);
draw_sprite_ext(my_sprite,0,my_x + offset_x,my_y + offset_y,scale, scale,0,colour,g_alpha);
draw_set_alpha(1.0);
}
}
gpu_set_blendmode(bm_normal); //change to normal
}
surface_reset_target(); //******
if(obj_player.tea_active != true) //not relevant at the moment
{
gpu_set_blendmode_ext(bm_dest_color,bm_zero);
//draw the actual surface we've created
alpha = 0.1;
draw_surface_ext(night_cycle_surf,camera_get_view_x(view_camera[0]),camera_get_view_y(view_camera[0]),1,1,0,c_white,alpha);
gpu_set_blendmode(bm_normal);
}
else //if tea active IS true
{
}
}
Is there a way I can draw the light covers onto the surface after the lights in a way that can counteract the bm_add effect of the lights? I'd love to hear some suggestions as my current solution leaves many rooms for errors.