1
[Max] Bug Reporting / BUG - ShadowCatcher + Env in Dome Mapping mode -> something's really wrong here
« on: 2024-04-02, 16:21:59 »
This one popped up some years ago during an online discussion and I had some funky results myself. Recently, I was using a dome-mapped environment with a ground plane with a ShadowCatcherMtl and realized that a reflective surface was reflecting something that was *behind* it which was clearly wrong. I decided to find out why that happened, turns out there's a bug when an environment is using dome mapping and is then used on a geometry with ShadowCatcherMtl.
1 - REFERENCE
In order to have a ground truth reference to test against I modeled simple test case scene - 4 different textures for the ground with 4 lights with some reflective objects. I then rendered a spherical panorama of that scene (with the reflective objects disabled for the pano). The Camera's Z-pos is at 5 meters.
Here's what the reference renderings looks like, one with spheres for lighting and reflections, another one with a box for flat reflections.
![](https://forum.corona-renderer.com/index.php?PHPSESSID=ns9pml07driki5hm7inu63iqrv&action=dlattach;topic=42375.0;attach=197103)
![](https://forum.corona-renderer.com/index.php?PHPSESSID=ns9pml07driki5hm7inu63iqrv&action=dlattach;topic=42375.0;attach=197101)
2 - VALIDATION - using the rendered pano as an environment in Dome mode
This is the scene using the reference panorama rendered before. It's set to dome mapping, 'Camera Height' is set to 5 meters to match the camera's height used to render the pano.
So far this looks good - except for the blurry environment, which is due to the low resolution of the environment map, so it's expected. Other than that, it matches the 'ground truth' reference renders from step 1.
![](https://forum.corona-renderer.com/index.php?PHPSESSID=ns9pml07driki5hm7inu63iqrv&action=dlattach;topic=42375.0;attach=197105)
![](https://forum.corona-renderer.com/index.php?PHPSESSID=ns9pml07driki5hm7inu63iqrv&action=dlattach;topic=42375.0;attach=197115)
This however is missing shadows since we don't have a ground plane. So let's add that...
3 - VALIDATION - add a ground plane with ShadowCatcherMtl (this is where the BUG is)
Now let's introduce a ground plane with a ShadowCatcherMtl using the environment map in its 'Enviro/Backplate' Slot and 'Projection mode' set to 'Enviro projection' (the correct way).
Have a look at the images, you can clearly see that reflections and GI are way off.
Notice the strange GI on the white sphere and the wrong reflections on the metal sphere.
Notice how the reflections on the metallic box are wrong. We should never see the red area of the ground being reflected since it's *behind* the box, and why is the reflected environment mirrored in a strange place? Nothing here makes sense.
![](https://forum.corona-renderer.com/index.php?PHPSESSID=ns9pml07driki5hm7inu63iqrv&action=dlattach;topic=42375.0;attach=197109)
![](https://forum.corona-renderer.com/index.php?PHPSESSID=ns9pml07driki5hm7inu63iqrv&action=dlattach;topic=42375.0;attach=197107)
This is clearly a bug. We're all using dome mapping with a ShadowCatcherMtl on some geometry in order to get shadows. Dome mapping alone works fine, but as soon as a ShadowCatcherMtl is used (and uses the same environment) it's doing something unexpected.
4 - WORKAROUND
Luckily there's a simple workaround but it may not be applicable in all cases.
Instead of using the environment's dome mapping mode in the ShadowCatcherMtl, we can reproject the panorama on the ground plane, and this reprojected panorama will then be used.
To do this, use a UVW Mapping modifier on your groundplane, set it to spherical (since our environment is a spherical pano), set the modifier gizmo to Z=5 meters (or the height that your panorama was taken at) and rotate if needed to align with your background/reference. In the ShadowCatcherMtl, set 'Projection Mode' to 'Do not alter projection' - that way, we're using the UVs from the UVW modifier, not the environment map's mapping.
However, for this to work, the ground plane (or whatever you want to use as ground geometry) needs high tessellation, otherwise UVs will stretch quite a bit. In this case, the ground plane needs 80 segments in length and width.
Here are the images, GI and reflections are now correct.
![](https://forum.corona-renderer.com/index.php?PHPSESSID=ns9pml07driki5hm7inu63iqrv&action=dlattach;topic=42375.0;attach=197113)
![](https://forum.corona-renderer.com/index.php?PHPSESSID=ns9pml07driki5hm7inu63iqrv&action=dlattach;topic=42375.0;attach=197111)
@Corona Team - this is a long standing bug and it's amazing to me this was never reported or validated/caught internally. I'd really expect this to work, hopefully it'll be fixed soon.
I'm attaching the zipped scene+environment map. Scene is from Max 2021 with Corona 9HF1 but I'm pretty sure the bug is present in recent Corona versions.
1 - REFERENCE
In order to have a ground truth reference to test against I modeled simple test case scene - 4 different textures for the ground with 4 lights with some reflective objects. I then rendered a spherical panorama of that scene (with the reflective objects disabled for the pano). The Camera's Z-pos is at 5 meters.
Here's what the reference renderings looks like, one with spheres for lighting and reflections, another one with a box for flat reflections.
2 - VALIDATION - using the rendered pano as an environment in Dome mode
This is the scene using the reference panorama rendered before. It's set to dome mapping, 'Camera Height' is set to 5 meters to match the camera's height used to render the pano.
So far this looks good - except for the blurry environment, which is due to the low resolution of the environment map, so it's expected. Other than that, it matches the 'ground truth' reference renders from step 1.
This however is missing shadows since we don't have a ground plane. So let's add that...
3 - VALIDATION - add a ground plane with ShadowCatcherMtl (this is where the BUG is)
Now let's introduce a ground plane with a ShadowCatcherMtl using the environment map in its 'Enviro/Backplate' Slot and 'Projection mode' set to 'Enviro projection' (the correct way).
Have a look at the images, you can clearly see that reflections and GI are way off.
Notice the strange GI on the white sphere and the wrong reflections on the metal sphere.
Notice how the reflections on the metallic box are wrong. We should never see the red area of the ground being reflected since it's *behind* the box, and why is the reflected environment mirrored in a strange place? Nothing here makes sense.
This is clearly a bug. We're all using dome mapping with a ShadowCatcherMtl on some geometry in order to get shadows. Dome mapping alone works fine, but as soon as a ShadowCatcherMtl is used (and uses the same environment) it's doing something unexpected.
4 - WORKAROUND
Luckily there's a simple workaround but it may not be applicable in all cases.
Instead of using the environment's dome mapping mode in the ShadowCatcherMtl, we can reproject the panorama on the ground plane, and this reprojected panorama will then be used.
To do this, use a UVW Mapping modifier on your groundplane, set it to spherical (since our environment is a spherical pano), set the modifier gizmo to Z=5 meters (or the height that your panorama was taken at) and rotate if needed to align with your background/reference. In the ShadowCatcherMtl, set 'Projection Mode' to 'Do not alter projection' - that way, we're using the UVs from the UVW modifier, not the environment map's mapping.
However, for this to work, the ground plane (or whatever you want to use as ground geometry) needs high tessellation, otherwise UVs will stretch quite a bit. In this case, the ground plane needs 80 segments in length and width.
Here are the images, GI and reflections are now correct.
@Corona Team - this is a long standing bug and it's amazing to me this was never reported or validated/caught internally. I'd really expect this to work, hopefully it'll be fixed soon.
I'm attaching the zipped scene+environment map. Scene is from Max 2021 with Corona 9HF1 but I'm pretty sure the bug is present in recent Corona versions.