Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

ramp.blackbody

The colours a blackbody glows at over a range of temperatures, as a Color ramp: deep red at the cool end through orange to white near 6500 K, and blue above it. glow makes the hotter keys brighter: each key is scaled by (temperature / to) ^ glow, so 0 keeps every key at full brightness and 4 follows the fourth power a real blackbody's radiance does. The colour is the Planckian-locus fit in sRGB taken to linear, normalised so its brightest channel is 1 before the glow scale. Use it for fire, embers, molten metal and stars.

The keys sit at temperatures evenly spaced from from to to, at least 2 of them, with linear interpolation and alpha 1. The fit holds temperatures to 1000 to 40000 K. The default range runs from deep red to near white; a to of 10000 K or more reaches blue.

Inputs

  • from (Float, default 1000). The temperature at 0 on the ramp, in kelvin.
  • to (Float, default 6500). The temperature at 1 on the ramp, in kelvin.
  • glow (Float, default 0). How much brighter a hotter key is: each key's colour is scaled by (its temperature / to) to this power. 0 keeps every key at full brightness; 4 follows a real blackbody's radiance.
  • keys (Float, default 16). How many keys the ramp is laid out with, evenly across the range; below 2 reads as 2.

Outputs

  • ramp (Ramp). A Color ramp.
local embers = g.ramp.blackbody({ from = 1000, to = 3000, glow = 4 })