1
0

__BulbRendererDefineOverlayUnderlay.gml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // Feather disable all
  2. function __BulbRendererDefineOverlayUnderlay()
  3. {
  4. __ambienceSpriteArray = [];
  5. __shadowOverlayArray = [];
  6. __lightOverlayArray = [];
  7. __AccumulateAmbienceSprite = function(_boundaryL, _boundaryT, _boundaryR, _boundaryB)
  8. {
  9. //Now draw ambience overlay sprites, if we have any
  10. var _size = array_length(__ambienceSpriteArray);
  11. if (_size > 0)
  12. {
  13. gpu_set_colorwriteenable(true, true, true, false);
  14. var _i = 0;
  15. repeat(_size)
  16. {
  17. var _weak = __ambienceSpriteArray[_i];
  18. if (!weak_ref_alive(_weak) || _weak.ref.__destroyed)
  19. {
  20. array_delete(__ambienceSpriteArray, _i, 1);
  21. }
  22. else
  23. {
  24. with(_weak.ref)
  25. {
  26. if (visible)
  27. {
  28. __CheckSpriteDimensions();
  29. //If this light is active, do some drawing
  30. if (__IsOnScreen(_boundaryL, _boundaryT, _boundaryR, _boundaryB))
  31. {
  32. draw_sprite_ext(sprite, image, x, y, xscale, yscale, angle, blend, alpha);
  33. }
  34. }
  35. }
  36. ++_i;
  37. }
  38. }
  39. gpu_set_colorwriteenable(true, true, true, true);
  40. }
  41. }
  42. __AccumulateShadowOverlay = function(_boundaryL, _boundaryT, _boundaryR, _boundaryB)
  43. {
  44. //Now draw shadow overlay sprites, if we have any
  45. var _size = array_length(__shadowOverlayArray);
  46. if (_size > 0)
  47. {
  48. //Leverage the fog system to force the colour of the sprites we draw (alpha channel passes through)
  49. gpu_set_fog(true, __GetAmbientColor(), 0, 0);
  50. //Don't touch the alpha channel
  51. gpu_set_colorwriteenable(true, true, true, false);
  52. var _i = 0;
  53. repeat(_size)
  54. {
  55. var _weak = __shadowOverlayArray[_i];
  56. if (!weak_ref_alive(_weak) || _weak.ref.__destroyed)
  57. {
  58. array_delete(__shadowOverlayArray, _i, 1);
  59. }
  60. else
  61. {
  62. with(_weak.ref)
  63. {
  64. if (visible)
  65. {
  66. __CheckSpriteDimensions();
  67. //If this light is active, do some drawing
  68. if (__IsOnScreen(_boundaryL, _boundaryT, _boundaryR, _boundaryB))
  69. {
  70. draw_sprite_ext(sprite, image, x, y, xscale, yscale, angle, c_white, alpha);
  71. }
  72. }
  73. }
  74. ++_i;
  75. }
  76. }
  77. //Reset render state
  78. gpu_set_fog(false, c_white, 0, 0);
  79. gpu_set_colorwriteenable(true, true, true, true);
  80. }
  81. }
  82. __AccumulateLightOverlay = function(_boundaryL, _boundaryT, _boundaryR, _boundaryB)
  83. {
  84. static _u_fIntensity = shader_get_uniform(__shdBulbIntensity, "u_fIntensity");
  85. shader_set(__shdBulbIntensity);
  86. //We use the overarching blend mode for the renderer
  87. gpu_set_blendmode(bm_add);
  88. //Don't touch the alpha channel though
  89. gpu_set_colorwriteenable(true, true, true, false);
  90. var _i = 0;
  91. repeat(array_length(__lightOverlayArray))
  92. {
  93. var _weak = __lightOverlayArray[_i];
  94. if (!weak_ref_alive(_weak) || _weak.ref.__destroyed)
  95. {
  96. array_delete(__lightOverlayArray, _i, 1);
  97. }
  98. else
  99. {
  100. with(_weak.ref)
  101. {
  102. if (visible)
  103. {
  104. __CheckSpriteDimensions();
  105. //If this light is active, do some drawing
  106. if (__IsOnScreen(_boundaryL, _boundaryT, _boundaryR, _boundaryB))
  107. {
  108. shader_set_uniform_f(_u_fIntensity, intensity);
  109. draw_sprite_ext(sprite, image, x, y, xscale, yscale, angle, blend, 1);
  110. }
  111. }
  112. }
  113. ++_i;
  114. }
  115. }
  116. //Reset render state
  117. shader_reset();
  118. gpu_set_fog(false, c_white, 0, 0);
  119. gpu_set_colorwriteenable(true, true, true, true);
  120. }
  121. }