Guest User

Untitled

a guest
Aug 26th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. ((Draw))
  2. // Works for only the first light
  3. //Create the light surface and set it as target
  4. if (!surface_exists(light_surf))
  5. light_surf = surface_create(room_width, room_height);
  6. surface_set_target(light_surf);
  7.  
  8. //Clear the target surface to black
  9. draw_clear_alpha(c_black, .9);
  10.  
  11. //Set the shader
  12. shader_set(sh_Light);
  13.  
  14. //Set blendmode to multiply
  15. gpu_set_blendmode_ext(bm_dest_color, bm_inv_src_alpha);
  16.  
  17. //Set the uniforms for each light object
  18. with (o_Light) {
  19.  
  20. shader_set_uniform_f(other.l_pos, x, y);
  21. shader_set_uniform_f(other.l_in_rad, in_rad);
  22. shader_set_uniform_f(other.l_out_rad, out_rad);
  23. shader_set_uniform_f(other.l_dir, dir);
  24. shader_set_uniform_f(other.l_fov, fov);
  25.  
  26. //Draw the app_surf
  27. draw_surface(application_surface, 0, 0);
  28.  
  29. }
  30.  
  31. //Reset the surface target
  32. surface_reset_target();
  33.  
  34. //Reset the blendmode to normal
  35. gpu_set_blendmode(bm_normal);
  36.  
  37. //Draw the light_surf
  38. draw_surface(light_surf, 0, 0);
  39.  
  40. //Reset the shader
  41. shader_reset();
  42.  
  43.  
  44.  
  45. ((Post-Draw))
  46. draw_surface(light_surf, 0, 0);
  47. draw_surface(application_surface, 0, 0);
  48.  
  49.  
  50. ((Fragment Shader))
  51. [Light calculations]
  52.  
  53. vec3 diffuse_color = texture2D(gm_BaseTexture, v_vTexcoord).rgb;
  54.  
  55. gl_FragColor = vec4(diffuse_color, new_alpha);
Advertisement
Add Comment
Please, Sign In to add comment