Sunday, December 25, 2016

HDR vs LDR Image Based Lighting



During my work as Technical and lighting artist, I was asked by level art team: “why we can’t use LDR images as skyboxes, they are so fancy and handpainted, why not?”





If you are making fantasy game, fine art – driven, it’s ok, use just what you like and be happy with that. But do not expect any realism from your materials.

If your goal is photorealism, then correct, linearly welded HDR is your only option (actually you can also use simulated atmosphere).

You can see how Mr. Bender Rodriguez, made of 40% titanium, reacts to light in two cases:


Left is clipped LDR as environment radiance map
Right is HDR image as environment radiance map

MUCH brighter

*all values are cd/m2
The reason for difference is MUCH wider range of values in HDR map. The luminance ratio between sky, sun and lit objects are often greatly underestimated by artists, in fact:



















- sun is ~ 1 000 000 times brighter than point on sky opposite to sun 

(if sun taken as 1.6*10cd/m2)

- sun is ~30 000 times brighter than perfectly white screen oriented on sun

- LED screen is ~3 000 000 times darker than sun,   




























Why it does not work?


But why should we care if the sky looks pleasant? Why it does not working? Try to consider sky as infinitely large amount of light sources (in fact that is true, from the physicist's point of view every atom of our atmosphere emits light). As far as we are in linear optics (and with sun on earth we are), Illumination of the point on surface would be equal to the sum of lighting from every virtual light:

Which is basically a numerical form of a lighting integral, but that would be another time

So now you have a trouble, you have some HDR value, you don't know what to do with. You are need to tonemap, tonemap means to set the range of your image to 0-255 RGB (or 0 - 1 float) without loosing information, clipping. And here is two ways to do this. Tonemap entire output image or use tonemapped input values for lighting(that was pretty common couple of year ago):


and guess what?



Function of sum of arguments does not equals to sum of functions


In fact there is a point where this two turns to be equal:
BRDF function returns you only one direction to light for observed point, and that means perfect mirror. The only difference on picture is a subpixel blending of lit points, which breaks the statement above. In most natural cases this equality is useless though.

The more complex the lighting function became - error grows bigger. When we add real world material properties - equality completely breaks apart:




I really hope that helped you out to understand why your nice-looking-easy-to-find LDR sky can't be used for lighting and why it is so important to have linear unclipped HDR to get a proper lighting.



No comments:

Post a Comment