Thursday, July 25, 2013

Proper HDR Lighting (Remix)

Note: check some awesome updates by Greg Zaal and Ben Simonds at the end of the post.

HDRI- and image-based lighting is simply awesome and highly addicting! This is one of the nicest things that has ever dawned the world of computer graphics.  And on that note, I want to share with you something.

I've recently been inspired by Greg Zaal's recent posts (in fact, all of them!) on his blog Adaptive Samples (http://adaptivesamples.wordpress.com).

To be specific, I've really been thrilled by his post titled 'Commonly Ignored Features #2: Proper HDR Lighting'.  If you haven't seen that yet, I highly suggest you visit it first before reading any further.

Though it does seem like a plausible solution to the issue, there is something missing, or rather something that was lost.

In the post/article, Greg showed us how to accurately use an HDR image (which is used as an Environment texture), to cast shadows.  His technique and workaround is incredible, HOWEVER, I did notice that by using that node setup, the environment lighting/reflection had already been outpowered by the shadows (through a Multiply Math Node), thus reducing the brightness of the reflections/ambient lighting and even darkening/burning the tones, generally.

To elaborate further, here are the things that we need to be aware of:

- the standard HDR environment texture mapping is OK, but it's too 'diffused' and is lacking the defined shadows that we would expect from a sunny HDR image

- Greg Zaal's method works but reduces the ambient feel that we would get from a standard HDR environment texture and it burns the image

- please be kind with me as I don't technically know too much of those Math nodes, I just felt that it looked right and couldn't really explain how and why ;)

The images below demonstrate the issues:

(standard HDR lighting, Env strength: 3, click image to enlarge)


(Greg Zaal's HDR lighting method, click image to enlarge)


To address this issue (except for the last item about my ignorance), and using Greg's Node setup as a starting point and reference, I added a small node group/connection that controls the 'burning effect' that we would get otherwise. 

This is possible by plugging in the Environment Texture to either of the Value input sockets of the Cosine Math Node (Add Math Node works too, with a slight washed out effect), using this to control the Background Node's strength value, while keeping the Environment Texture connected to the Color input socket of the Background Node.  I almost got lost explaining things there, so here's an image to better illustrate what I mean:

(HDRI with better shadows Node Setup, click to enlarge)


(my remixed version of the HDR lighting with defined shadows, click to enlarge)


Kudos to you, Greg, for that wonderful idea.  I'm looking forward to seeing more of these out-of-the-box thoughts of yours; really inspiring! ^_^

To the community and readers out there, if you have any suggestions (highly recommended!) and explanations, please feel free to drop by a comment below.

Here's a download link to the .blend file to those of you interested in playing around with it (without the HDRI, for quicker uploads on my side):

https://www.dropbox.com/s/ibcv28by976e8ac/hdr_lighting_with_defined_shads.blend

Thank you so much for your time and happy Blending! :)

Autumn Field HDRI downloaded from: http://openfootage.net
Greg Zaal's article: http://adaptivesamples.wordpress.com/2013/07/24/cif-2-hdr-lighting/

P.S.
No monkeys were harmed/burned in this demonstration.

UPDATE:

In a flash, Greg Zaal improved the setup making my jaw drop. ;)

Check his updates at:

http://adaptivesamples.wordpress.com/2013/07/24/cif-2-hdr-lighting/

UPDATE (2013-Nov-8):

And here's a really impressive adaptation and improvement by Ben Simonds:

http://bensimonds.com/2013/11/07/controlling-hdri-lighting-with-nodes/

-Reyn

2 comments:

monitorhero said...

I would really like to know the proper workflow with a backplate image and an hdri. Is there a way to get proper reflections from the backplate (not from the hdri)and accurate shadows? Thanks for any answer. I haven't found a real solution for this problem in Blender yet. Maybe you know a workaround.

greetings Rushlord

Anonymous said...

The sIBL web site (http://www.hdrlabs.com/sibl/index.html) states that "Another common problem is the sun. It's just too bright, which makes it notoriously hard to capture [in HDRI]. It's even harder to render with, because it causes the worst render artifacts. Much more convenient is a regular 3d directional light, allowing more control over intensity and shadow." Adding an additional directional light to recreate the effect of the small but bright sun seems to be a simple solution for this "soft shadows" issue. Any thoughts?

Cheers,
Robert