Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. From RobustLight2.dm:
  2. set_color(red, green, blue, queued_run = 0)
  3.  
  4. if (src.r == red && src.g == green && src.b == blue && !queued_run)
  5. return
  6.  
  7. /*
  8. src.r_des = red
  9. src.g_des = green
  10. src.b_des = blue
  11. */
  12.  
  13. //hello yes now it's ZeWaka exporting my hellcode implementations across the code
  14. //scientific reasoning provided by Mokrzycki, Wojciech & Tatol, Maciej. (2011).
  15. /*
  16. var/R_sr = ((red + src.r*255) /2) //average value of R components in the two compared colors
  17.  
  18. var/deltaR2 = abs(red - (src.r*255))**2
  19. var/deltaG2 = abs(blue - (src.b*255))**2
  20. var/deltaB2 = abs(green - (src.g*255))**2
  21. */
  22. //this is our weighted euclidean distance function, weights based on red component
  23. //var/color_delta =( (2+(R_sr/256))*deltaR2 + (4*deltaG2) + (2+((255-R_sr)/256))*deltaB2 )
  24.  
  25. //DEBUG_MESSAGE("[x],[y]:[temperature], d:[color_delta], [red]|[green]|[blue] vs [src.*255]|[src.*255]|[src.*255]")
  26.  
  27. /*
  28. // This breaks everything if a light's value is 0, so, begone
  29. if (color_delta < 144) //determined via E'' sampling in science paper above, 144=12^2
  30. Z_LOG_DEBUG("Lighting", "Color update would be ignored due to color_delta ([color_delta]) under 144. ([R_sr], [deltaR2] [deltaG2] [deltaB2])")
  31. return
  32. */
  33.  
  34. if (src.enabled)
  35. if (SHOULD_QUEUE)
  36. light_update_queue.queue(src)
  37. dirty_flags |= D_COLOR
  38. return
  39.  
  40. var/strip_gen = ++RL_Generation
  41. var/list/affected = src.strip(strip_gen)
  42.  
  43. src.r = red
  44. src.g = green
  45. src.b = blue
  46. src.precalc()
  47.  
  48. for (var/turf/T in src.apply())
  49. T.RL_UpdateLight()
  50. for (var/turf/T in affected)
  51. if (T.RL_UpdateGeneration <= strip_gen)
  52. T.RL_UpdateLight()
  53. else
  54. src.r = red
  55. src.g = green
  56. src.b = blue
  57. src.precalc()
  58.  
  59. From FEA_Fire.dm:
  60. // now this is ss13 level code
  61. proc/set_real_color()
  62. var/input = temperature / 100
  63.  
  64. var/red
  65. if (input <= 66)
  66. red = 255
  67. else
  68. red = input - 60
  69. red = 329.698727446 * (red ** -0.1332047592)
  70. red = max(0, min(red, 255))
  71.  
  72. var/green
  73. if (input <= 66)
  74. green = max(0.001, input)
  75. green = 99.4708025861 * log(green) - 161.1195681661
  76. else
  77. green = input - 60
  78. green = 288.1221695283 * (green ** -0.0755148492)
  79. green = max(0, min(green, 255))
  80.  
  81. var/blue
  82. if (input >= 66)
  83. blue = 255
  84. else
  85. if (input <= 19)
  86. blue = 0
  87. else
  88. blue = input - 10
  89. blue = 138.5177312231 * log(blue) - 305.0447927307
  90. blue = max(0, min(blue, 255))
  91.  
  92. color = rgb(red, green, blue) //changing obj.color is not expensive, and smooths imperfect light transitions
  93.  
  94.  
  95. // dear lord i apologuize for this conditional which i am about to write and commit. please be with the starving pygmies down in new guinea amen
  96.  
  97. //hello yes now it's ZeWaka with an even more hellcode implementation that makes no sense
  98. //scientific reasoning provided by Mokrzycki, Wojciech & Tatol, Maciej. (2011).
  99.  
  100. var/R_sr = ((red + light.r*255) /2) //average value of R components in the two compared colors
  101.  
  102. var/deltaR2 = abs(red - (light.r*255))**2
  103. var/deltaG2 = abs(blue - (light.b*255))**2
  104. var/deltaB2 = abs(green - (light.g*255))**2
  105.  
  106. //this is our weighted euclidean distance function, weights based on red component
  107. var/color_delta =( (2+(R_sr/256))*deltaR2 + (4*deltaG2) + (2+((255-R_sr)/256))*deltaB2 )
  108.  
  109. //DEBUG_MESSAGE("[x],[y]:[temperature], d:[color_delta], [red]|[green]|[blue] vs [light.r*255]|[light.g*255]|[light.b*255]")
  110.  
  111. if (color_delta > 144) //determined via E'' sampling in science paper above, 144=12^2
  112.  
  113. red /= 255
  114. green /= 255
  115. blue /= 255
  116.  
  117. light.set_color(red, green, blue, queued_run = 1)
  118. light.enable(queued_run = 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement