Home Unreal Engine

Let me show you my hot black body...

JedTheKrampus
polycounter lvl 8
Offline / Send Message
JedTheKrampus polycounter lvl 8
Fall break at college means more time for Unreal Engine 4 patches! There are still a few rough edges here and there that I've got to iron out before I submit a pull request, but I got blackbody color working for lights:

YPmHm2i.jpg

Gotta go bake some baklava but let me know what you guys think or if you have any suggestions.

Replies

  • Farfarer
    Options
    Offline / Send Message
    Is this specifying a temperature in Kelvin to determine the light color?
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Yes. The lights are in 1024 K increments, starting from 0 (the black one) and going up from right to left, all the way to 14336 K at the back. Here are the UI bits I've added:

    UKlixTU.png

    Currently the normalize color temperature checkbox does nothing. The next thing I want to do is make it so that if that's unchecked, color temperature affects brightness and color of the lamp, and if it's checked, color temperature affects color only.

    It's not my original algorithm; I just stole the code from the MaterialTemplate.usf shader file and translated it to C++. Will probably do a bit of refactoring of what I've written as well when I get around to it.
  • Avvi
    Options
    Offline / Send Message
    Avvi polycounter lvl 3
    It will be useful for sure :) I was surprised to see blackbody node in a shader but no such setting in the lamp properties.
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Nice! I like this a lot.
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Doing some more work on this. I've made it so that if you drag a light that's pure white into the scene and tweak the color temperature slider, the intensity stays the same (as is reflected in the luminosity of the image.) The intensity of the light will not change no matter what the color temperature is, unless you go really far into the red. I probably won't change this, it's getting a little more complicated than I like as it is.

    Anyways! How about some comparisons? All screenshots are done with the tonemapper at an exposure fixed at log 0.

    Here is a standard UE4 directional light, with intensity 10 and a color of 255, 255, 255.

    rkbSDp3.jpg

    Here's a duplicate of that directional light, which I tweaked the color temperature of. Now it has an intensity of 45.947937 and a color of 132, 125, 132. (This is as close to white as you can actually get in the color temperature computation I use.) The intensity is automatically increased to compensate for the darker light color.

    HgLG4Bp.jpg

    Note how they look almost exactly the same. (The color temperature one is a little bit purple, but that's OK.) So, now let's try a lower color temperature and see if the brightness of the light changes.

    ZpoV43M.jpg

    That was quite yellow, but if I take it into Krita and desaturate it according to luminosity, you'll see that it's actually the same brightness as before!

    9flg9Z0.png

    Let's try a really hot light now. I'm going to take this one's temperature over 9000:

    s5LxWrp.jpg

    Here it is desaturated in Krita again:

    8lvs8BH.png

    A little brighter than the yellow one was desaturated, but closer to the original two.

    Of course if you uncheck the normalize color temperature checkbox the color temperature will also affect the light's intensity realistically. For most lights this results in really bright lights with UE4's default intensity at a color temperature over about 5000 or so. This property is more meant to be used for creating dynamic lights that go with explosions and such... I think I will move it to advanced properties before I submit my pull request.

    Just for fun here's the same directional light with normalization turned off and bloom turned back on.

    YJwHoDJ.jpg

    So, expect my pull request to be submitted by ... oh, probably Wednesday or so, and expect it to be merged whenever Epic's rendering team takes a break from their daily bear and lion wrestling routine ;)
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Ladies and gentlemen, the pull request is up if you want to give this a try or offer any criticism or concerns.
  • Jacky
    Options
    Offline / Send Message
    Jacky polycounter lvl 6
    Awesome stuff.I would love to see this integrated into the engine.
Sign In or Register to comment.