Blackbody radiation for lights

Godot Version

4.0.4

Question

Hi everyone! I’m a Blender user, and I use Blackbody Radiation a lot when designing lighting because it makes it a lot easier to handle colour temperatures without having to faff about with RGB or HSV values.

How can I create a shader or script that allows me to colour lights with colour temperatures? There don’t seem to be any addons in the Asset Library for this as well.

I apologise if this is in the wrong category as well, this is my first post and the Shaders category seems to be the most fitting.

The problem with blackbody is it’s a pretty complex computation for a game. You could find a (GLSL) shader that does it and just use it in godot, then bake it with GI probe. That’s the best I can tell you because I haven’t used blackbody much, but PBR shaders are not magic. Just grab a minimal example and put it into godot. It should just work (might be very slow).

Thanks for the pointers, I’ll see what I can do

This is supported if you enable physical light units: Physical light and camera units — Godot Engine (latest) documentation in English

It sounds like we could allow light temperature to work if not using physical light units, but there may be a reason why it’s not exposed otherwise: godot/scene/3d/light_3d.cpp at 84692c6252438393999c427bf7f5d35b9c43926c · godotengine/godot · GitHub

Edit: I’ve tried removing the early return in the function linked above, modifying _validate_property() to expose the property then recompiling, and it works. That said, it’s noted in another comment that the default value of 6500.0 is nearly white, and not completely white. Since it acts as a multiplier for the light color, we’d need to ensure it’s actually white if physical light units are disabled (perhaps by special-casing the value 6500.0).

3 Likes

Thank you so much, this is absolutely perfect!

UPDATE: There is an addon for Godot 4.1+ called Light Tools, found in the Asset Library and at this GitHub link that converts a colour temperature to RGB values, achieving the same thing but without any of the PBR performance concerns.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.