Shadows from geometry hidden by CesiumCartographicPolygon effecting our own meshes

Hi!
I am working on a scene for a client and are using Cesium for the surrounding area of a architectural model in Unreal.

Our goal is to integrate our own model into Cesium, we are using the CesiumCartographicPolygon component to hide/cut out part of the mesh overlaying our own model. But as evident from the images attached, a smearing shadow is cast on our own mesh from Cesium, this goes away as soon as we hide the Cesium tiles. Part of the Cesium mesh is also suddenly coming into view even when it’s inside the CesiumCartographicPolygon area as seen in some of the images.

Is there any way to disable shadow casting from the Google Photorealistic 3D Tiles?

Thanks in advance, Magnus

Scene without Cesium:

Scene with Cesium:

Images of the mesh and shadow issues:



Hi @MetaMagnus,
Your screenshots look great!

Can you help us reproduce these problems you’re seeing? The clipping functionality is implemented using an Opacity Mask in a Material. So the geometry still exists, it’s just not rendered inside the polygon. I would hope Unreal wouldn’t include such invisible geometry for lighting purposes, and it that seems to be true at least with the default CesiumSunSky lighting setup based on my tests just now. But lighting in Unreal is crazy complicated, so I can imagine there is some mode or combination of settings where it’s not behaving the way we’d like.

Likewise with the extra bits of the model still appearing when they’re clipped out. We haven’t seen that, so we need your help to reproduce it so that we can debug. If you can give us instructions for reproducing the problem, preferably starting with the Cesium for Unreal Samples project, that will be a huge help.

Hi Kevin and thanks for a quick reply!

So I have created new project based on your CesiumForUnrealSamples project, moved the Georeference Origin at the same location my project is located at (somewhere in middle of Oslo, Norway).

I have then changed from the Cesium World Map/Terrain to the Google Photorealistic 3D Tiles.

Next I cut out a small piece of the Google Photorealistic 3D Tiles using the CesiumCartographicPolygon and added a simple ground plane for better visibility of the issue.

Next I added in some large boxes representing my buildings.

The last thing I have done and when I see the issues appear is when I turn on Lumen, this is not enabled in your default project settings.

And again here you can see the difference with and without Cesium visible.

Without Cesium:

With Cesium:

Here are my scene components:
image

And here is my project render settings:

This is a fairly normal Unreal 5 lighting setup with no special settings enabled. In my own project I am using the Ultra Dynamic Sky plugin for lighting but as you can see in this example I am using your CesiumSunSky Actor.

It seems like the issue goes away as soon as I disable “Use Hardware Ray Tracing when available” in the projects settings under render settings:

A bit unfortunate that we cant use the higher quality raytracing for lumen.

The pop up of cesium/google geo inside the CesiumCartographicPolygon unfortunately still happens here but is very based on camera angle and distance:

Again thanks for the quick investigation into these issues, best regards Magnus!

Good detective work with the “Use Hardware Ray Tracing when available”! I wonder if we can reproduce the same problem using non-Cesium geometry with its opacity mask set to 0.0 in the Material? If so, there’s a clear case for reporting it to Epic as a bug. Out of curiosity, are you already using UE 5.4 or is this an older version?

The Cesium geometry sometimes appearing inside the clipped region seems like it’s likely a Cesium bug, though. I’ll see if I can reproduce that and investigate.

Good point Kevin, it might have to do with how Lumen handles materials with opacity masks. And you are correct it’s really not a Cesium “issue” but more of a Unreal 5/Lumen issue.

Here is a test scene I have without Cesium implemented.

The scene without anything covering the right building:

The same scene but mesh over one of the buildings (this is just for reference):

Same scene but with a Opacity Mask Material on the white box set to a value of 0:

And as we can see the same shadow issue appear on the building on the right that is now inside the mesh with a opacity mask on it.

Here is also the same scene with the cube with a opacity mask on but with “Use Hardware Ray Tracing when available” turned off in Render settings:

It’s a bit different but does not solve the issue in this specific example. So even turning this off might not solve the issue in all cases. Changing the Material from Opacity Mask to normal Opacity does fix the issue.

I have tried and got the same issues (both the shadow issue and the geo popping up issue) on both 5.3 and 5.4.

So as a conclusion it seems that Unreal Engine 5 & Lumen does not play well with Opacity Mask materials and will create dark shadows under/inside the mesh that uses the Opacity Mask material.

Solution: The solution I have found for the shadow issues is turning on “two sided” for the material that have the opacity mask on it.

Same scene as before and same material with a value of 0 in the opacity mask constant but with two sided turned on and Use Hardware Ray Tracing when available in Render settings is also turned on:

But it seems this does not apply for the Cesium M_CesiumBaseMaterial, turning on Two-sided does unfortunately not fix the issue, any idea why Kevin? Is there somewhere else I might have to change to two-sided?

Here is a image of what I have done in a test scene with cesium:

Thanks again for the help Kevin! :slight_smile:

So as a conclusion it seems that Unreal Engine 5 & Lumen does not play well with Opacity Mask materials and will create dark shadows under/inside the mesh that uses the Opacity Mask material.

Interesting! I imagine that would cause problems for pretty common usage of opacity masks, too, such as rendering leaves on trees.

The solution I have found for the shadow issues is turning on “two sided” for the material that have the opacity mask on it.

And maybe that’s why no one has run into the problem while rendering leaves! :laughing:
It’d be pretty straightforward for us to add a feature to force two-sided rendering ON, either as an option or as automatic behavior for clipped tiles. Though it could also cause artifacts in certain meshes, I suppose.

But it seems this does not apply for the Cesium M_CesiumBaseMaterial, turning on Two-sided does unfortunately not fix the issue

Is there a similar property on the MI_CesiumThreeOverlaysAndClipping by any chance? If so, setting that instead may help. (Side note: it’s better to copy the material instance into your project rather than modifying the one in the plugin.) Looking at the code just now, though, we appear to at least attempting to always enable two-sided rendering:

So I’m not sure why that’s not working. It’s unfortunately quite common in Unreal to have properties that are settable, but that setting them doesn’t actually do anything without doing some other dance to apply the changed setting. So it’s possible this falls into that category.

haha yeah, but I think even if you didn’t make the leafs two sided there would still be less issues as there would be openings around the leafs letting in light from different directions, here I have the same test examples as my last post but I have opened up the box on the back side allowing some light to bounce into the box.

It’s not perfect but much better with one side of the box opened up, so I imagine leafs would be okay. Here Two sided is also off.

Turning on two-sided on the parent material as I did in the last post and also turning it on in the MI_CesiumThreeOverlaysAndClipping does not solve the issue unfortunately.

The pop in of random geo from Cesium even with the CesiumPolygonRasterOverlay also keeps happening… Without fixes for these issues Cesium is most likely not usable for us at the moment.

I will keep experimenting and testing out different settings and if anything new pops up on my side I will be sure to update this thread/post. Thanks again for the support Kevin! :slight_smile:

@MetaMagnus can you help me reproduce the problem with the random bits of geometry appearing inside the polygon? I tried setting up a few polygons on Google Photorealistic 3D Tiles, and wasn’t able to see a problem. I tried some concave polygons, and those seem to work fine as well. With some really ugly polygons with self-intersecting lines and I can get an arguably wrong interpretation of the polygon, but I don’t think it’s what you’re seeing:

I posted too soon! I can get it to happen with a bit of zooming in and out. It’s very random and inconsistent though, isn’t it?

Yes it’s very sporadic but generally at the same spots, but they will fade in and out based on distance and angle of the camera. I have unfortunately not found any new work around on my end.

Hello again @Kevin_Ring,
I hope you had a nice summer!

Just tried the newest version of the Cesium plugin for Unreal and I no longer see the issue with shadows from hidden geo or the problematic meshes that still showed up inside the CesiumCartographicPolygon shape in my project, I will do some more experiments in different project files to totally verify, but it’s looking good so far!

With Cesium:

Without Cesium:

Not sure what you guys did, but it seem like some of these issues have been fixed for now, It would be great if you also could redo your test on your end and check if the issues is no longer present. :smiley:

Best regards, Magnus

1 Like

Yeah sorry I didn’t update this thread, but I believe we fixed this in v2.7.0, released at the beginning of July.

Let me know if you still see any problems!

1 Like

Hello Kevin

We have run into a similar issue i think. We have 2 tileset, one for the surface and a second one for buildings. Both use the same CartographicPolygon for their cutout:

As a cutout material we have a Material set to masked, using the CesiumBaseMaterial as parent:

In the viewport everything gets masked correctly:

In certain lighting situation we get wierd shadow. Also if we enable the lumen debug view, the buildings still appear:

We are using the cesium version 2.7.1 and Unreal version 5.4

Do you see anything wrong with our approach or did we miss something when setting up the scene?

As mentioned earlier in this thread (Shadows from geometry hidden by CesiumCartographicPolygon effecting our own meshes - #3 by MetaMagnus), there may be a bug with Lumen and hardware ray tracing. It’s worth disabling it to see if that helps.

1 Like

Thanks for the answer, we didnt see that comment. But i can confirm that it solves the issue!