__BulbRendererDefineHDR.gml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Feather disable all
  2. function __BulbRendererDefineHDR()
  3. {
  4. static _system = __BulbSystem();
  5. hdr = false;
  6. hdrTonemap = BULB_TONEMAP_HBD;
  7. hdrBloomIntensity = 0;
  8. hdrBloomIterations = 3;
  9. hdrBloomThresholdMin = 0.4;
  10. hdrBloomThresholdMax = 0.9;
  11. __oldHDR = undefined;
  12. __oldHDRBloomIterations = undefined;
  13. //Surface used for HDR composition prior to tonemapping
  14. //This is a 16-bit float RGBA surface and is only created on demand
  15. __outputSurface = undefined;
  16. __bloomSurfaceArray = [];
  17. __GetOutputSurface = function(_width, _height)
  18. {
  19. if ((_width <= 0) || (_height <= 0)) return undefined;
  20. if ((__outputSurface != undefined) && ((surface_get_width(__outputSurface) != _width) || (surface_get_height(__outputSurface) != _height)))
  21. {
  22. surface_free(__outputSurface);
  23. __outputSurface = undefined;
  24. }
  25. if ((__outputSurface == undefined) || !surface_exists(__outputSurface))
  26. {
  27. if (hdr && _system.__hdrAvailable)
  28. {
  29. //Work around compile error in LTS
  30. var _surface_create = surface_create;
  31. __outputSurface = _surface_create(_width, _height, surface_rgba16float);
  32. }
  33. else
  34. {
  35. __outputSurface = surface_create(_width, _height);
  36. }
  37. surface_set_target(__outputSurface);
  38. draw_clear(c_black);
  39. surface_reset_target();
  40. __FreeBloomSurfaces();
  41. }
  42. return __outputSurface;
  43. }
  44. __FreeOutputSurface = function()
  45. {
  46. if ((__outputSurface != undefined) && surface_exists(__outputSurface))
  47. {
  48. surface_free(__outputSurface);
  49. __outputSurface = undefined;
  50. }
  51. }
  52. __FreeBloomSurfaces = function()
  53. {
  54. var _i = 0;
  55. repeat(array_length(__bloomSurfaceArray))
  56. {
  57. surface_free(__bloomSurfaceArray[_i]);
  58. ++_i;
  59. }
  60. array_resize(__bloomSurfaceArray, 0);
  61. }
  62. }