X
XirmiX
Guest
So, after much research and look at some ways of creating light and shadows and some extensions, I thought I would settle on using the Light and Shadows extension in order to create my lights and what not.
I read through the tutorial file and looked at the example file in order to get what I need. I also looked at this tutorial to get what I need in terms of the dark surface which would be applied to the entirety of a room:
So, I did some thinking, trying out and understanding some stuff and when I thought I finally got what I need... I didn't:
The shadows aren't working correctly and if I minimize the game and bring it up again, it'll give me this error:
Even though the surface has been set in the same goddamn object:
obj_lightControl Create event:
This is how the room looks like in the editor:
This is how I want it all to look like when the game is running:
P.S This was drawn edit from the next image, which is why parts of inaccuracy can be seen in places. I just wanted to give a general idea here.
And this is how it is actually rendering:
I believe the fault is in the shadow casting and the surface not being rendered for whatever reason, but I am unsure of how to fix this. I just tried to follow what I was given. So, considering all that, I'll just plop in all of the relevant code here:
On another note, once this is resolved, there is another detail I want to add to my lights, which is making shadows have a blur-like effect like it can be seen at 7:43 in this video:
But that's the step afterwards, I need the former to work right first, obviously.
I read through the tutorial file and looked at the example file in order to get what I need. I also looked at this tutorial to get what I need in terms of the dark surface which would be applied to the entirety of a room:
So, I did some thinking, trying out and understanding some stuff and when I thought I finally got what I need... I didn't:
The shadows aren't working correctly and if I minimize the game and bring it up again, it'll give me this error:
Even though the surface has been set in the same goddamn object:
obj_lightControl Create event:
Code:
alpha = 1;
darkSurface = surface_create(room_width, room_height);
lightStrength = 1;
This is how the room looks like in the editor:
This is how I want it all to look like when the game is running:
P.S This was drawn edit from the next image, which is why parts of inaccuracy can be seen in places. I just wanted to give a general idea here.
And this is how it is actually rendering:
I believe the fault is in the shadow casting and the surface not being rendered for whatever reason, but I am unsure of how to fix this. I just tried to follow what I was given. So, considering all that, I'll just plop in all of the relevant code here:
obj_collisionbox Create event
obj_collisionbox Draw event
obj_lightControl Create event
obj_lightControl Draw event
obj_lightmap Create event
obj_lightmap Draw event
obj_light_spotlight
Code:
caster_init_sprite();
Code:
draw_self();
Code:
alpha = 1;
darkSurface = surface_create(room_width, room_height);
lightStrength = 1;
Code:
surface_set_target(darkSurface);
draw_clear(c_black);
with(obj_light_spotlight)
{
draw_set_blend_mode(bm_src_colour);
draw_sprite_ext(spr_light, 0, x, y, image_xscale, image_yscale, 0, c_white, lightStrength);
draw_set_blend_mode(bm_normal);
}
surface_reset_target();
draw_surface_ext(darkSurface, 0, 0, 1, 1, 0, c_white, alpha);
Code:
lightmap_init(view_wview,view_hview);
lightmap_set_ambient(0.3);
lightmap_set_light_parent_object(obj_light_parent);
lightmap_set_caster_parent_object(obj_caster_parent);
lightmap_move_with_view(true);
lightmap_set_shadows_enabled(true);
lightmap_set_shadow_size(256);
Code:
lightmap_update();
lightmap_draw();
Code:
lightStrength = 1;
light_init_sprite(spr_light,0);
image_alpha = 0.5;
On another note, once this is resolved, there is another detail I want to add to my lights, which is making shadows have a blur-like effect like it can be seen at 7:43 in this video:
But that's the step afterwards, I need the former to work right first, obviously.