# cesium for unreal 3dtiles dynamicmaterial 

**URL:** <https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034>\
**Category:** Cesium for Unreal\
**Created:** [December 2, 2024, 3:08pm UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034 "2024-12-02T15:08:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![peijw](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/peijw/32/9482_2.png) [@peijw](https://community.cesium.com/u/peijw)\
**Post date:** [December 2, 2024, 3:08pm UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/1 "2024-12-02T15:08:17Z")

</div>

can i use dynamicMaterial on 3dtiles ,i do it,but it can not render properly

 ![image](https://global.discourse-cdn.com/cesium/original/3X/9/8/988f9c2707ce4190127feec3c493ca3589fc92f9.jpeg)  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/1/3/1351ce659fd441203ee980e94eaa371e1c6568bc.png)

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [December 3, 2024, 1:08am UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/2 "2024-12-03T01:08:48Z")

</div>

Can you tell us more about what you’re doing? You can certainly specify a custom material on a Cesium3DTileset at Editor time. Setting the Material property at runtime should work, too, though it will force a full reload of the Cesium3DTileset.

---

<div class="post-metadata">

**Author:** ![peijw](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/peijw/32/9482_2.png) [@peijw](https://community.cesium.com/u/peijw)\
**Post date:** [December 3, 2024, 1:18am UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/3 "2024-12-03T01:18:59Z")

</div>

It is normal to use custom material,but I want to change it’s opacity at runtime，so if i use dynamicMaterial, it can’t render properly,It looks gray like picture 1

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [December 3, 2024, 9:48am UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/4 "2024-12-03T09:48:57Z")

</div>

I suspect the problem isn’t that it’s a _dynamic_ material, but that there’s something wrong with the material itself. You should copy `MI_CesiumThreeOverlaysAndClipping` and then modify it, rather than creating a new material from scratch. There is a lot going on in that material, and much if it is necessary in order for textures, for example, to work correctly.

If that advice doesn’t help, we’ll probably need to see how you’ve set up your material in order to help further.

---

<div class="post-metadata">

**Author:** ![peijw](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/peijw/32/9482_2.png) [@peijw](https://community.cesium.com/u/peijw)\
**Post date:** [December 3, 2024, 10:34am UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/5 "2024-12-03T10:34:22Z")

</div>

Actually, I did it as you said. I copied the material MI\_CesiumThreeOverlaysAndClipping，it rendered normally, but when I created a dynamic material based on it ,setting it to dynamic material at runtime resulted in rendering errors,The material called ‘MI\_Custom’ in picture 2 was copied from material MI\_CesiumThreeOverlaysAndClipping

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [December 4, 2024, 10:08am UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/6 "2024-12-04T10:08:44Z")

</div>

Can you please walk us step-by-step through the process you followed, so that we can reproduce it ourselves?

---

<div class="post-metadata">

**Author:** ![peijw](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/peijw/32/9482_2.png) [@peijw](https://community.cesium.com/u/peijw)\
**Post date:** [December 5, 2024, 12:30am UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/7 "2024-12-05T00:30:57Z")

</div>

The first step is to add a 3dtiles in the level. The second step is to create a dynamic material based on material MI\_CesiumThreeOverlaysAndClipping at runtime. The third step is to call the SetMaterial interface of 3dtiles and assign the dynamicmaterial created in the second step to 3dtiles. Then 3dtiles turn gray and the rendering is incorrect。 I just want to change 3dtiles opacity at runtime.

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [December 12, 2024, 7:18am UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/8 "2024-12-12T07:18:17Z")

</div>

Thanks @peijw, I can reproduce this, and I wrote an issue for it:

> <https://github.com/CesiumGS/cesium-unreal/issues/1569>
>
> Reported here:
> https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamic…material/37034
> 
> To reproduce, create a Level Blueprint like this:
> https://blueprintue.com/blueprint/oyczy--l/
> !\[image\](https://github.com/user-attachments/assets/5f933c29-450f-4e95-a980-fb5c492a1a07)
> 
> Click Play-in-Editor, and the tileset will render, but it will be missing its raster overlays (among other things).
> 
> The reason is that the new material doesn't have \`UCesiumMaterialUserData\` attached to it, so it doesn't know the mapping between material layer name (such as \`Overlay0\`) and the material layer index used to set material parameters. Adding \`UCesiumMaterialUserData\` is not an option, because the API necessary to find the layer names is only available in the Editor.
> 
> The best solution, I think, is to modify the code starting here:
> https://github.com/CesiumGS/cesium-unreal/blob/v2.11.0/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp#L3024
> So that, rather than just checking the \`pBaseAsMaterialInstance\` for \`UCesiumMaterialUserData\`, it also walks the \`Parent\` chain looking for a parent material that has it.

The issue describes a possible modification to the Cesium for Unreal code that will make it work, if you’re up for it, but I haven’t tried it myself.

Alternatively, you might consider using a [Material Parameter Collection](https://dev.epicgames.com/documentation/en-us/unreal-engine/using-material-parameter-collections-in-unreal-engine) rather than a dynamic material to enable you to set the opacity at runtime.

---

<div class="post-metadata">

**Author:** ![peijw](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/peijw/32/9482_2.png) [@peijw](https://community.cesium.com/u/peijw)\
**Post date:** [December 12, 2024, 7:41am UTC](https://community.cesium.com/t/cesium-for-unreal-3dtiles-dynamicmaterial/37034/9 "2024-12-12T07:41:56Z")

</div>

Thank you for your answer. I will try it out
