What is the latest HDRI lighting workflow for now (BabylonJS v7.4)?

Hey community,

Question #1

I’m just wanna checking in for what is the current state of HDRI lighting workflow in BabylonJS?

I found this article by @PatrickRyan

Which posted 5 years ago.
Just wondering is this still the up-to-dated? or we have some new changes or tricks for HDRI lighting in general.
I know we just enabled the new IBL shadowing pipeline earlier this year. And just wondering if I missed anything else.

Also can we add the content of this article to the official documents if this is the latest? Looks it helps a lot in term of photorealistic lighting in BJS.

Question 2:

In the article above, it only discusses scenarios where the IBL texture contains a spotlight/directional light source (such as the sun). But what if the light source in the IBL texture is an area light / area lights, such as a large area light in a photo studio? Is there a better method to simulate that lighting setup in Babylon?

Many thanks,
Tawibox

@tawibox, this article was specifically written for HDRI that have large exposure value (EV) ranges. This happens in scenes where you have the sun in the HDRI as there are pixels in the sun that can reach into the tens or hundreds of thousands in value. This happens particularly with HDRIs coming from sources that use high EV ranges as a selling point and are mostly aimed at pre-render scenarios with ray tracers. When using with real time rendering there are a lot of approximations made for optimization and one of those is in tone mapping HDR values to LDR. In our case, we made choices back then that would clip very high numbers rather than tone mapping them, so you would just blow out after a certain value. I don’t remember what it was, but it was something like 60,000 or 80,000 - more than we thought would be present in an IBL. Then high-EV HDRIs started to be a thing, so this was an article to help bring those images back into the realm of usable for our lighting pipeline.

Since then, we have added some tools. One is the ability to drop a .hdr file right onto our sandbox. This one is a 22EV HDRI that has the sun directly in the IBL:

You can see that we are not blowing out half of the spheres with the high value lights. This also bypasses the need for IBLBaker or Lys and we are not needing a DDS format for light anymore. From there, you can export the lighting for the scene to a .env file which is our format for IBL that is very small and does not require a processing step when the scene loads. You can also use .hdr directly in your scene, but you will need a precompute step which will tone map the values and create the mip chain, so you push that compute to everyone who opens your scene rather than doing it once and loading an .env file with a smaller download for the client.

In terms of doing a studio environment, the way I prefer to do those would be to set up the studio in Maya/Max/Blender and create the lighting and room detail as a scene with an equirectangular camera in the center (where your camera will be). Make sure all of your lights render in the output, and then render out a 2x1 proportion image as an .hdr file. from there follow the same steps as above. You can certainly just use a pre-generated HDRI of a lighting studio, but if you need control over where you place your lights, this is easiest. From there, you can just use PBRMaterial to get the IBL to light your assets. For shadows, you just need to put a punctual light (directional, point, spot) in the scene that mimics the light direction and cull meshes from the light contribution but pass that light to your shadow generator. Also pass all affected meshes to the shadow generator. This way you get very complex light on your materials, and can still decide which shadows you want to render.

I hope this helps but feel free to ping back with questions.

2 Likes

@PatrickRyan

Awesome!! Thank you so much for detailed response! All make sense now.
Sorry I thought I replied your response earlier but ended up I didn’t.

Happy 2025.
Tawibox

1 Like