NOW it starts to look like something not half bad. Than I draw light over hole with light alpha draw_set_blend_mode(bm_add) ĭraw_sprite(spr_light,1,obj_camera.x,obj_camera.y) I draw this surface with shadow alpha draw_set_alpha(shadow_level) I blend shadow surface with hole sprite, using (bm_one,bm_zero) surface_set_target(sf_shadow) ĭraw_sprite(spr_hole,0,width/2,height/2) Now I will cun holes in my shadow surface and than draw lights over that holes.įirst I create 2 sprites. Now if I will draw resulting surface with bm_add it will be just a light, with no shadow at all. It will recolor light source in some areas, but the brightness level will be dim. This type ofblending will not create light. What i got is a black shadow with a green shadow in. draw_set_alpha(0.9) //this alpha is the darkness Now I will draw resulting surface as I would draw my shadow. surface_set_target(sf_light_and_shadow) ĭraw_sprite(spr_test_light,1,width/2,height/2) I will draw my shadow on a surface, than I will draw my lights on the same surface, than I will draw that surface on my main surface.ĭo you remember, my light looks like this: It is very easy to draw it on a 100% opaque black surface. It means, that if I point bright orange flashlight to dark area, I will see a bright orange circle and some vague contours of surface under it. Where Rd is color of my main surface, and Rs is color of my light sprite. In case of colored light resulting color will be: red: (1-shad.a)*Rd + (light.a)*Rs There is no shad.a and light.a combination, that will return my color to it's orginal (Rd,Gd,Bd) state. Resulting color will be: red: (1-shad.a)*Rd + light.aĪnd it looks like a complete nonsense. Resulting color of main surface is: ((1-shad.a)*Rd, (1-shad.a)xGd,(1-shad.a)*Bd, (1-shad.a)) I want to have the same color as before.Ĭalculations: shad.a - alpha of my black rectangle (shadow) light.a - alpha of my while rectangle (light) How, that is the question.ĭo I draw shadows first and than lights on shadowed main surface? I will try to light up dark area with a white light. I have a light without shadows and have a shadow without lights. My only concern here is: What is up with resulting alpha? Should I make it 1.0 again? How? So in the end it is like I am multiplying every color of surface by (1-alpha) of my black rectangle. And I draw it on 100% opaque main game surface. I found out, that to create even a bit of darkness I must use very opaque black rectangle. So, what do we have here? Bm_normal calculates color as following: (bm_src_alpha, bm_inv_src_alpha) (Rs,Gs,Bs,As) * (As, As, As, As) + (Rd,Gd,Bd,Ad) * (1–As, 1–As, 1–As, 1–As) Every youtuber and his grandmother suggests to draw a transparent black rectangle over my view with bm_normal. I heard that some people use bm_multiply for lights, but I do not know what it is and how it works.Īnother useful thing I figured out with lights is that I should draw all the lights on one surface with blend mode mb_max. That's a problem, but I can keep my brightnes low enough and have a good light. If I add too much light resulting color will be white. So, as result, all the colors will be brighter (cool!) and closer to white color (not cool!). With this I can draw a light on black canvas like this: And than draw it in game like this: draw_set_blend_mode(bm_add) ĭraw_sprite(spr_test_light,1,obj_camera.x,obj_camera.y) īm_add calculates color as following: (bm_src_alpha, bm_one) (Rs,Gs,Bs,As)*(As,As,As,As)+(Rd,Gd,Bd,Ad)*(1,1,1,1) = (R,G,B,A) (I am realy a noob though.)įirst of all, I figured out, that the best way to draw lights is to use bm_add blend mode. You will tell me: hei, noob! there is a ton of information and youtube tutorials! I read all of that tutorials, but I still do not understand something important. Thanks to all of you.īut I could not find usefull information about creating lights and shadows in games. I've been reading manuals here for a long time, and found a lot of usefull information.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |