Author Topic: BUG - ShadowCatcher + Env in Dome Mapping mode -> something's really wrong here  (Read 990 times)

2024-04-02, 16:21:59


  • Active Users
  • **
  • Posts: 1885
    • View Profile
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.

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.

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.
« Last Edit: 2024-04-02, 16:40:58 by pokoy »

2024-04-03, 13:07:45
Reply #1


  • Corona Team
  • Active Users
  • ****
  • Posts: 12828
  • Marcin
    • View Profile
Thank you for your effort, Pokoy! This has to be one of the greatest bug reports ever made.
We already have a similar report (Report ID=CMAX-251), but I will double check to make sure it's the same issue.
Marcin Miodek |
3D Support Team Lead - Corona | contact us

2024-04-03, 15:09:52
Reply #2


  • Active Users
  • **
  • Posts: 1885
    • View Profile
Thank you for your effort, Pokoy! This has to be one of the greatest bug reports ever made.
We already have a similar report (Report ID=CMAX-251), but I will double check to make sure it's the same issue.
Glad you like it :D
Seriously, I wish I had tested this sooner, did lots of jobs that way and sometimes the results were strange, for some reason I never sat down and tested it with a simple straightforward case.

Glad it's reported already and hopefully a fix is coming soon.