Tails1000
Member
I hit a hiccup in my lighting engine, as I can't figure out how to create different colored lights. I've tried several different blend modes with no luck. My goal is to create something that looks like this:
But right now I'm only able to make white light, not orange.
Here is a pic of my testing room (assets not mine obviously):
The top pic is using bm_subtract, while the bottom is using bm_add.
I'd ideally like to create an effect similar to Multiply in photoshop.
This is the code I'm working with right now:
Create:
Step:
Draw:
I'm aware drawing a surface over the entire room isn't a good idea. Since this is just a test I'll work on correcting that later.
If anyone has any tips they would be much appreciated.
I feel like the solution is obvious, I just don't know it yet.
Of course ask me any more questions if it would help.
I am using Game Maker 2 by the way.
Thanks in advance for any help!
But right now I'm only able to make white light, not orange.
Here is a pic of my testing room (assets not mine obviously):
The top pic is using bm_subtract, while the bottom is using bm_add.
I'd ideally like to create an effect similar to Multiply in photoshop.
This is the code I'm working with right now:
Create:
Code:
light_surf = surface_create(room_width, room_height);
surface_set_target(light_surf);
draw_clear_alpha(c_white, 0);
surface_reset_target();
Code:
if !surface_exists(light_surf){
light_surf = surface_create(room_width,room_height)
surface_set_target(light_surf);
draw_clear_alpha(c_white,0)
surface_reset_target();
} else {
surface_set_target(light_surf);
//set the darkness
draw_set_color(merge_color(c_black, c_navy, 0.1)); //color of the rectangle
draw_set_alpha(0.85); //alpha of the rectangle
draw_rectangle(0, 0, room_width, room_height, false); //the rectangle
//set the circles
gpu_set_blendmode(bm_add);
draw_set_alpha(0.1)
//draw the circles
with (obj_player4) { //circles for player
draw_sprite_ext(spr_light, 0, //set sprite
x + random_range(-1, 1),
y + random_range(-1, 1),
2, 2, 0, c_white, //size and color
0.8+random_range(-0.03,0.03)); //alpha
draw_sprite_ext(spr_light, 0,
x + random_range(-1, 1),
y + random_range(-1, 1),
3, 3, 0, c_white,
.2+random_range(-0.03,0.03))
}
with (obj_lamp) {
draw_sprite_ext(spr_light, 0,
x + 15 +random_range(-1, 1),
y + 40+random_range(-1, 1),
1, 1, 0, c_orange,
0.8 +random_range(-0.1,0.1));
draw_sprite_ext(spr_light, 0,
x + 15+random_range(-1, 1),
y + 40+random_range(-1, 1),
2, 2, 0, c_orange,
0.2+random_range(-0.05,0.05))
}
//reset draws
gpu_set_blendmode(bm_normal);
draw_set_alpha(1);
surface_reset_target();
}
Code:
if (!surface_exists(light_surf)){
light_surf = surface_create(room_width,room_height);
} else {
if (view_current == 0) {
draw_surface(light_surf, 0, 0)
}
}
If anyone has any tips they would be much appreciated.
I feel like the solution is obvious, I just don't know it yet.
Of course ask me any more questions if it would help.
I am using Game Maker 2 by the way.
Thanks in advance for any help!