Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ((Draw))
- // Works for only the first light
- //Create the light surface and set it as target
- if (!surface_exists(light_surf))
- light_surf = surface_create(room_width, room_height);
- surface_set_target(light_surf);
- //Clear the target surface to black
- draw_clear_alpha(c_black, .9);
- //Set the shader
- shader_set(sh_Light);
- //Set blendmode to multiply
- gpu_set_blendmode_ext(bm_dest_color, bm_inv_src_alpha);
- //Set the uniforms for each light object
- with (o_Light) {
- shader_set_uniform_f(other.l_pos, x, y);
- shader_set_uniform_f(other.l_in_rad, in_rad);
- shader_set_uniform_f(other.l_out_rad, out_rad);
- shader_set_uniform_f(other.l_dir, dir);
- shader_set_uniform_f(other.l_fov, fov);
- //Draw the app_surf
- draw_surface(application_surface, 0, 0);
- }
- //Reset the surface target
- surface_reset_target();
- //Reset the blendmode to normal
- gpu_set_blendmode(bm_normal);
- //Draw the light_surf
- draw_surface(light_surf, 0, 0);
- //Reset the shader
- shader_reset();
- ((Post-Draw))
- draw_surface(light_surf, 0, 0);
- draw_surface(application_surface, 0, 0);
- ((Fragment Shader))
- [Light calculations]
- vec3 diffuse_color = texture2D(gm_BaseTexture, v_vTexcoord).rgb;
- gl_FragColor = vec4(diffuse_color, new_alpha);
Advertisement
Add Comment
Please, Sign In to add comment