Impossible to properly set up HDRI lighting

Hi,

I am having very hard time creating IBL setup in UE4. I want to use HDRI .exr map with sunspot which has realistic exposure. When I import my map, put it as an emissive material on my sky sphere and use SkyLight to create illumination of it, I get very bright and incorrect result:

Now, this makes sense, since UE4 is a realtime renderer, so it can’t compute sharp shadows from HDRI map, and Directional Light needs to be used as a stand-in:
When I insert Directional Light with angle and intensity matching the sun disc captured on the HDRI map, I get all wrong result. Everything is bright, washed out and shadow is gray instead of blue. This is due to the fact that the sun illumination is now effectively present twice in the scene. Once by accurate, sharp Directional Light, and once by SkyLight blurring the hell out of the super bright HDRI spot on the HDRI map and wrapping it around the normals of meshes.

To fight this, I can simply clamp the HDRI map, so that the illumination from the sun is in the scene only once, from the Directional Light which can provide proper shadows:
leClamp.JPG

Now, you can see that the illumination looks much better. Indirect lighting is blue, as it is not compromised by being averaged by the super bright value of the sun disc on HDRI map, and the correct sharp sun illumination is supplemented by directional light. It appears to be working but falls apart as soon as I view my HDRI map directly:

Clamping of the HDRI mam did solve the double illumination issue, but also completely ruined the dynamic range of the environment when viewed directly. Here’s how it looks unclamped:
Much, much better with correct HDR intensity to help us get secondary optical effects such as flare and bloom right. But at the same time, this will mean return of the incorrect scene illumination, being doubled again.

The first obvious way to tackle this would be to use “SLS specified cubemap” feature of the SkyLight, but it appears to be very obsolete, as it accepts only bitmaps defined as cubemaps, yet UE4 doesn’t define any imported bitmap as cubemap, be it EXR or HDR.

My question is, is there any way to get this right for both illumination and direct visibility without any ridiculous overcomplicated and time consuming workarounds?

Thanks in advance.

For one, check to make sure that it’s a true HDR image using other HDR software. You’ll find a lot of HDRs on the internet that are just JPGs that have been converted and won’t have the actual dynamic range to them.

Secondly, check your auto exposure settings. If it truly is a functional HDR, you may need to adjust your exposure settings so that the bright sun doesn’t blow out the rest of the image.

Just my thoughts

By the sounds of it your trying to use an HDRI as a direct lighting solution, which of course you can do, but the odds that it will be correct as to expectations is rather low.

GI solutions are tricky as a single solution, as you have found out can give results in one are that looks good and in others, like blown out sunlight, where in most cases direct light is direct lighting and and a simple matter of shapeing the result as to expectations.

What makes the big difference though is how does indirect lighting behaves as to expectations and makes a HUGE difference as to shadow behavior which I would have to say is the ball game as to proper lighting behavior.

For example here is a test I did using postprocess, HDI, and a Ambient cube map to control the indirect lighting intensity but still maintain the direct lighting intensity.

Actually, you can see on the very last image that it’s true HDRI. The flare is generated from the HDR spot on the map. It’s also written in my post. Secondly. The exposure is fine here, especially combined with filmic color mapping.

I don’t think you get my issue. I already explained it in my post. I know that I won’t have perfectly correct illumination from HDRI in UE4 since UE4 can not perform importance sampling of HDRI map in realtime and generate sharp shadows out of it. That’s to be expected. That’s why I explicitly stated in my post, that I am using directional light.

The problem I am having is as follows: In order to get at least close approximation of that HDRI light setup, I need to have Directional Light to stand in for the sun disc captured on the HDRI image. When I do that, the skylight also generates illumination from the HDRI, but averages the HDR spot on the HDRI map in such a way that it completely blurs and blows out the skylight illumination. Since the high intensity illumination is already taken care by directional light, I don’t wanna have it in my scene twice, so I have to clamp my HDRI. But when I do that, the HDRI now looks completely crappy when viewed directly.

So I need to use low range, clamped version of the HDRI for illumination of SkyLight, but HDR, full range version of HDRI for directly visible display of my environment background. And I need to do it without any ridiculous convoluted 20-step workaround.

It appears that both of you haven’t actually even read my post :frowning:

So, no one has ever set up HDRI based environment in UE4?

Your first screenshot already shows something is wrong in your setup. A skylight using that skysphere as a capture should not look that bright. Please post your skylight settings and post processing volume exposure settings (if any).

Well I was actually responding to this.

“My question is, is there any way to get this right for both illumination and direct visibility without any ridiculous overcomplicated and time consuming workarounds?”

The problem is UE4 does not support IBL as far as I know as a light emitter so no there is no simple solution.

https://forums.unrealengine.com/community/general-discussion/1440870-how-to-enable-ibl-in-unreal-engine

The root of the problem is a Sky light and a Direct light can conflict as a unique lighting element that does need work arounds to produce the desired result. Turn off Cast Shadow for example in the skylight.

For example both can cast shadows. Is this a good or bad thing I don’t know but but does change the result

This is a typical problem even in advanced rendering system like 3ds Max which solves the basic problem by introducing a Sunlight system which combines both sky light and directional light but sets up the lighting elements so that they play well together.

And yes I use HDRI regularly and most solutions involves binding a light to the object but the last time I checked an emissive material does not emit light.

This is not impossible, don’t give up. There’s also some confusing information in this thread.

Some prerequisite info: you can use and HDR or EXR, it doesn’t matter. Unreal treats HDR images as a “Texture Cube” format on import, but EXR as a regular “Texture”. The main difference is the way your material is set up; it’s a different texture type that needs different UVs. In other renderers it wouldn’t matter and EXR is the superior format, but Epic makes funny decisions sometimes :slight_smile:
20181031-23_18_41.png

  1. Like your first image, using an HDR directly with a bright sun visible creates ringing artifacts.
  2. Create a duplicate sky with the sun painted out. Create a Directional Light for sunlight.
  3. Make the sunny sky smaller so it is in front of the no-sun sky. Disable “Visible in Reflection Capture”
    The sunny sky will be visible to camera, but hidden to reflections (including the Captured Scene cubemap)

Now you have working IBL. You could also use a specified cubemap (using the no-sun HDR) instead of 2 sky domes, depends if you want to use captured scene or not. Doesn’t matter if you use a static or stationary skylight, you can read all about the differences in the docs

Obviously I didn’t go through the trouble of matching the sun intensity to the original. The good thing with the 2-sky setup like this is when objects are in shadow the sun is not visible in reflections. I hope that helps

Specified cubemap isn’t obsolete other than the fact it requires an image imported as “.hdr”. It says “cubemap” but it’s really a regular latlong HDRI like you find online everywhere

Thank you very much!
I was kinda worried about the workaround of having two skyboxes, one being not visible for reflection capture. I am not sure what the performance implication of this “hack” are. Also, using HDRI with actual HDR sun spot with not only create artifacts, but mainly double illumination, that was my main issue. You can see it on your first screenshot, where the ground plane is much brighter than it’s supposed to be under given lighting conditions.

Specified cubemap is a lot better solution, but I am having hard time importing any HDR or EXR as cubemap, They always import as regular texture. How do I specifically import them as cubemaps?

Thanks again!

EDIT: So I can on some occasions get in .hdr file as a cubemap, but I am unable, for the love of god, bring in any of the EXRs as cubemap, which is unfortunate given that my entire HDRI library is exclusively EXR. :frowning:

EDIT2: So I am unable to use “SLS Specified cubemap” workflow because I can not clamp the map inside that slot. It only allows a source texture map to be in that slot, without any adjustment nodes. That would mean I have to store, maintain and keep in sync two different maps, one clamped, and one full range. Such a workflow would introduce so much room for error it’s not acceptable :frowning:

Hi!

I have a short HDRI lighting tutorial if you’re interested:

Hi,
I know this is an old Post, but can anybody tell me the right UV settings for using an .EXR in a skydome?
Thanks