Controlling HDRI Lighting with Nodes

I’ve seen a couple of posts recently on getting more control over HDR based lighting setups, specifically in terms of getting crisper shadows. In particular Reyante Martinez and Greg Zaal each posted some great setups that used the colour of an HDRI map as the input to the strength node of a background shader. I thought I’d add my own experiments to the mix.

Here’s a basic world setup for cycles. Just a HDR map plugged into a background node. No other lights in the scene.

HDRI_1_Basic

Here’s a setup based on one that Greg posted in his original article. It gives stronger shadows by plugging the HDRI map into both the colour and intensity inputs of the background node.

HDRI_1_ISquared

Of course there are many ways to achieve this sort of effect, and so the answer becomes which is the most effective, and which gives you the most control. The setup above gives you some control over the shadows, but by plugging the map into the strength input it becomes more difficult to affect the overall  strength of the environment lighting (incidentally, Greg posted some great improvements to the above setup in his original article). What I really want to do is to be able to control the contrast of the lighting without affecting it’s colour, and whilst still maintaing control over it’s overall brightness. I tried a few setups with this aim in mind. This was my first one:

HDRI_1_Power

This setup was my first attempt, and I was mainly concerned with making sure my math checked out so that I could get my head around future setups. Here I normalised the input to the colour node of the background shader. This gave the colour input for the background node a uniform intensity. I then extracted the value from the HDRI map and processed this separately, then used this as the input for the strength node of the background shader. By putting this input through a power (math) node first (or any other manipulation you prefer) I could control the strength and contrast of the lighting (raising it’s intensity to a higher power results in more contrast).

Notably, this setup resulted in a lot more noise. I think this is because my setup messes up the Multiple Importance Sampling for the world (which I had turned on for all my renders). This convinced me that I should try and modify the input to the colour socket of the background node, rather than the strength, which should be kept to a uniform value, in order to avoid unnecessary noise. This setup also results in some crazy backgrounds, and glossy reflections that don’t make sense. To fix these issues I made use of the light paths node and a few mix nodes to blend in the unaltered HDRI map where appropriate, namely for glossy, transmission and camera rays. I also switched to using a Brightness/Contrast node to affect the lighting strength. The result is the following setup:

HDRI_1_Advanced1

The node group of which contains the following nodes:

Nodes

This node group provides a lot of flexibility whilst remaining easy to work with. You can control how much your environment affects your lightings contrast and overall brightness  and adjust how this affects other aspects of your render like glossy reflections, transmission rays and the background as viewed by the camera. Here’s a few examples:

Different contrast adjustments:

Contrast

Adjusting the look of Glossy Reflections:

GlossyMix

The same effect shown above for Glossy reflections can also be controlled for transmission rays. So far it seems to work pretty well. If you give it a go I’d enjoy hearing your thoughts on it and how it worked for you. You can download it here.

Note: The HDR map I used is not included. You can download it from BlendedSkies.com, which is a great resource for HDR panoramas as well as other stuff like pre-tracked footage and backplates for compositing renders onto.

10 responses to “Controlling HDRI Lighting with Nodes

  1. i was always wondering why everybody use “non-color data” for the color socket? why just don’t use a node with set to “Color data” for color input, and “Non-color data” for the strength. Also as i found all these contrast difference is due to .hdr which is linear and is threated as linear for values, but does it dispalyed properly(for sRGB) when rendring?
    probably we just need to add Gamma adjustment node, and tweak ‘look’ of the texture. and adjust it’s strength and contrast to get sharp shadows, while still have correct (not darkend) glossy reflections and background gamma. That’s just my thoughts, no tests yet

    • I’m pretty sure that the colour/non-colour data option isn’t to important for HDR images, as they’re linear to begin with, and will be treated as such either way. It’s more relevant when using images with lower bit depths that you might not want to be assumed to be in sRGB colour space, such as masks or normal maps.

      • But doesn’t it uses only 1 channel for non color data(BW intensity) ? Where as for Color Data it uses 3 channels for RGB

  2. Nope. Colour/Non-Colour is an assumption about colour space, not how many channels an input has. Otherwise you’d see no colour in any of the renders here!

  3. So my question would be that, how did you realized what has to be done to achieve this node setup, and how can i learn this?

  4. Now all we need is a way to render a shadow pass from this lighting setup so it can be composited on live plates. Unfortunately Cycles currently can’t seem to render a separate shadow pass for HDR lighting.

  5. Pingback: Gumballs! | David Zerba·

  6. Seems like you are burning the blues of the image.
    Why not just crush the blacks and raise the highlights of the rendered image if it’s contrast we’re after?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s