Commonly Ignored Features #2: Contrasty HDR Lighting

Update 2016: This method is pretty much just wrong. See this post instead.

At the time Cycles came out in Alpha, I was playing around with HDR lighting in Blender internal. I found BI to be annoyingly slow and impossible to get that magic one-click lighting that all the non-blender websites had promised HDR could do.

You might remember some fool using this in some tutorial...

You might remember some fool using this in some tutorial…

So when Cycles showed up, I figured the day was saved and all my problems would magically disappear.

Well most of them did, but HDR lighting still looked flat and boring, lacking the shadows from the sun even in simplest of outdoor images.

hdr_bad

However, a couple years (has it really been that long?) later and I can now tell you where that magick one-click-lighting button is!

hdr_good

Well its not technically a button… but a single node connection:

hdr_nodes

All you need to do is connect the image to the Strength input of the Background shader and it’ll use those awesome bright pixels of the sun as the strength, meaning the sun is actually brighter than all the other white things! Hence the awesome shadows and realistic lighting.

The Multiply node is there to control the strength of the light, I increased it to 2.0 since it was a little dark, but it could probably even go higher since the shadows are a bit dark here.

Update:

Don’t forget that we’re working with nodes here people! Anything’s possible!

hdr_joined

On the left is the plain setup with the HDR plugged just into the colour.
The middle is with the node setup above, the image plugged into the strength too (brightened with a multiple math node)
And the right one is with some extra adjustments:

hdr_nodes

Notice that the colour hasn’t been altered at all.
The Multiple math node is just to brighten it up, but the orange mix node mixes that strength value with white, effectively decreasing it’s contrast and making the shadows less harsh (thanks to Sir Reyn for the great idea!)

Now the blue mix node is where it gets a little more technical: The Light Path node gives us access to the different sorts of light rays. It’s common to see people use the Is Camera Ray to make something look a certain way to the camera, but behave differently for the rest of the scene – for example making a glass object look like glass to the camera, but the rest of the scene perceives it as plain old transparency, thus eliminating caustics.
Here we’re adding the Is Camera and Is Glossy rays (making sure to Clamp them so as to keep the result between 0 and 1 and continue energy conservation) and using that as the Fac of a mix between the strength driven by the image and a consistent strength (in this case of 5.0 since that’s what is bright enough for this HDR). So to the camera and in reflections (the glossy ray), the environment looks exactly as it did before we started messing with the strength, but it still lights the scene nicely.

Hope that isn’t too confusing for ya :)

Also remember to enable Multiple Importance Sample and choose Non-Color Data for the environment texture.

 

PS: For those of you who have been hiding in a cave the last few years, Reyn’s blog is a great one to follow! A true artist he is :)

17 thoughts on “Commonly Ignored Features #2: Contrasty HDR Lighting

  1. Hey, Greg! I wrote a post with reference to this one, improving further on your great idea:

    http://reynantem.blogspot.com/2013/07/proper-hdr-lighting-remix.html

    I hope you don’t mind. :)

    Thanks so much!

    -Reyn

  2. Nazzareno Giannelli

    Hey! Great method here! But I’m experiencing an issue: With hdr with this setting I’m having a LOT of noise and even after many passes it’s not better. Any idea of what it could cause this? Thx anyway for all the tips!

  3. Great tip, love your Blender blog posts. Keep up the good work.

  4. Interesting tip!

  5. Fool?????
    That tutorial was much before you even knew what HDR lighting was.
    OK though now you will be the fool left when HDR improves beyond your yearnings,
    Thou Fool!.

  6. “Here we’re adding the Is Camera and Is Glossy rays…” — That is not how the Light Path node works. Putting an Add node after it does not “add the rays”. If a ray hitting the environment sphere came straight from the camera, without hitting anything else, the Light Path node will output a 1.0 from Is Camera. If, however, it was a reflective ray that bounced off a glossy BSDF, the Is Glossy output will output a 1.0. Otherwise, either output 0.0.

    Adding them will never produce a 2.0, because a ray can’t be both straight from the camera AND reflected off a glossy object. Therefore, the clamp is useless.

    The end result, of course, is the same, i just wanted to clarify the technical side of it :)

    • Ah right, makes sense! Just a habit to clamp everything I don’t need a high value range for I guess. Thanks for the explanation :)

      • Clamping is certainly a good habit to have (unless you’re doing weird non-physically based things or you find it you need to fudge the shaders by quite a bit due to too dark textures etc.) :)

  7. Got a question. When I wire up the environment HDR as prescribed I am getting a nuclear blow out of the image. I am using an exr hdr image and I don’t know why the image is being blown out.

    • All you need to do is reduce the intensity :) If you have the multiply node plugged into the Background shader, just reduce the second value to something between 0 and 1 (greater than 1 will make it brighter, less than 0 inverts it)

  8. Cool post, I learned some useful new things here!

    By the way, you have a broken link at the end.

  9. The way I’m doing and getting decent results is to just add a Gamma node after the environment texture and set it to something like 1.5. If that makes it too bright then I reduce the Strength in the the Background node.
    Thanks for the tip, always good to learn new techniques.