# Runtime created Cesium Tileset with material (OSM Buildings for example) doesn't render

**URL:** <https://community.cesium.com/t/runtime-created-cesium-tileset-with-material-osm-buildings-for-example-doesnt-render/14834>\
**Category:** Cesium for Unreal\
**Created:** [August 14, 2021, 2:44am UTC](https://community.cesium.com/t/runtime-created-cesium-tileset-with-material-osm-buildings-for-example-doesnt-render/14834 "2021-08-14T02:44:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![asaf.amit](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/asaf.amit/32/3476_2.png) [@asaf.amit](https://community.cesium.com/u/asaf.amit)\
**Post date:** [August 14, 2021, 2:44am UTC](https://community.cesium.com/t/runtime-created-cesium-tileset-with-material-osm-buildings-for-example-doesnt-render/14834/1 "2021-08-14T02:44:04Z")

</div>

For example creating an OSM Tileset at runtime doesn’t render the material that gets assigned to it leaving that layer invisible…

---

<div class="post-metadata">

**Author:** ![agallegos](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/agallegos/32/4464_2.png) [@agallegos](https://community.cesium.com/u/agallegos)\
**Post date:** [August 16, 2021, 2:31pm UTC](https://community.cesium.com/t/runtime-created-cesium-tileset-with-material-osm-buildings-for-example-doesnt-render/14834/2 "2021-08-16T14:31:21Z")

</div>

Hi @asaf.amit,

Thanks for bringing this to our attention. To help nail down the issue, how are you creating the tileset at runtime? It would be helpful if you could share your blueprint graph or C++ code.

-Alex

---

<div class="post-metadata">

**Author:** ![asaf.amit](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/asaf.amit/32/3476_2.png) [@asaf.amit](https://community.cesium.com/u/asaf.amit)\
**Post date:** [August 17, 2021, 1:45am UTC](https://community.cesium.com/t/runtime-created-cesium-tileset-with-material-osm-buildings-for-example-doesnt-render/14834/3 "2021-08-17T01:45:03Z")

</div>

Thank you, here is the C++ snippet

```auto
	ACesium3DTileset* Tileset = Cast<ACesium3DTileset>(
		UGameplayStatics::BeginDeferredActorSpawnFromClass(GetWorld(), ACesium3DTileset::StaticClass(), FTransform()));
	if (Tileset)
	{
		Tileset->SetTilesetSource(ETilesetSource::FromCesiumIon);
		Tileset->SetIonAssetID(Id);
		Tileset->SetIonAccessToken(CesiumAccessToken);
		Tileset->Rename(*LayerNameTextBox->GetText().ToString().TrimStartAndEnd());

		TileSet->SetMaterial(BaseMaterial);
		TileSet->EnableFrustumCulling = false;
		TileSet->EnableFogCulling = false;
		TileSet->GetRootComponent()->SetMobility(EComponentMobility::Movable);
		UGameplayStatics::FinishSpawningActor(Tileset, FTransform());
       }

```

---

<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:** [August 19, 2021, 9:53am UTC](https://community.cesium.com/t/runtime-created-cesium-tileset-with-material-osm-buildings-for-example-doesnt-render/14834/4 "2021-08-19T09:53:15Z")

</div>

Hi @asaf.amit,

I was able to reproduce the problem using the code you provided. Upon further investigation, though, it doesn’t appear to have anything to do with runtime creation of the Cesium OSM Buildings tileset, or with setting the material. Rather, the problem is the “EnableFrustumCulling = false” combined with the (default) EnforceCulledScreenSpaceError=false when rendering certain tilesets like Cesium OSM Buildings. I wrote an issue describing the problem:

> <https://github.com/CesiumGS/cesium-native/issues/314>
>
> Originally reported here with Cesium OSM Buildings, which uses external tilesets… extensively:
> https://community.cesium.com/t/runtime-created-cesium-tileset-with-material-osm-buildings-for-example-doesnt-render/14834/2
> 
> In the tile selection algorithm, we treat external tilesets as if they have a really huge geometric error. This guarantees that we never select them, but instead always refine past them. At least, it usually does.
> 
> A problem comes up when enableFrustumCulling is set to false. In this scenario, tiles that would otherwise be culled will be included in the render list. When enforceCulledScreenSpaceError is also false, we also will not (ever!) refine such tiles. And this is true even for external tilesets with their huge geometric error. Thus, we'll end up selecting an external tileset for rendering, even though it's not a thing we can render.
> 
> Now this alone wouldn't be a \_huge\_ problem. It would just be a tile in the render list without any renderable content and we could just ignore it. But because \`\_meetsSse\` is returning true for these culled external tileset tiles (and this is the \_only\_ situation in which it will), we add it to the render list with \`\_renderInnerTile\`. And \`\_renderInnerTile\` will note that the tile's \`isRenderable\` method returned false (which is fair enough, it's not renderable). Because this tile isn't renderable, and never has been, the next level up in the selection traversal will kick this tile \_and its siblings\_ out of the render list, waiting for them all to become renderable, presumably by further loading. But an external tileset will never become renderable no matter how long we wait for it to load.
> 
> End result: we don't render this whole branch of the tile tree with these settings.

As a workaround until this is fixed, you should be able to set EnforceCulledScreenSpaceError to true. That alone will result in rendering more tiles, but you can counteract this (and get close to the original behavior you were aiming for) just by setting CulledScreenSpaceError to a large value like 1024 or so.

Here’s the code I used to test it:

```auto
  const FString CesiumAccessToken = TEXT("[my key]");
  const int32 Id = 96188;

  ACesium3DTileset* Tileset =
      Cast<ACesium3DTileset>(UGameplayStatics::BeginDeferredActorSpawnFromClass(
          GetWorld(),
          ACesium3DTileset::StaticClass(),
          FTransform()));
  if (Tileset) {
    Tileset->SetTilesetSource(ETilesetSource::FromCesiumIon);
    Tileset->SetIonAssetID(Id);
    Tileset->SetIonAccessToken(CesiumAccessToken);
    Tileset->Rename(TEXT("Test"));

    //TileSet->SetMaterial(BaseMaterial);
    Tileset->EnableFrustumCulling = false;
    Tileset->EnableFogCulling = false;
    Tileset->EnforceCulledScreenSpaceError = true;
    Tileset->CulledScreenSpaceError = 1024.0f;
    Tileset->GetRootComponent()->SetMobility(EComponentMobility::Movable);
    UGameplayStatics::FinishSpawningActor(Tileset, FTransform());
  }

```

Kevin

---

<div class="post-metadata">

**Author:** ![asaf.amit](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/asaf.amit/32/3476_2.png) [@asaf.amit](https://community.cesium.com/u/asaf.amit)\
**Post date:** [August 20, 2021, 6:29am UTC](https://community.cesium.com/t/runtime-created-cesium-tileset-with-material-osm-buildings-for-example-doesnt-render/14834/5 "2021-08-20T06:29:18Z")

</div>

> [@Kevin\_Ring](#):
>
> ```auto
> Tileset->EnforceCulledScreenSpaceError = true;
> Tileset->CulledScreenSpaceError = 1024.0f;
> 
> ```

Hi Kevin,

Thank you, the workaround works.

Regards,  
Asaf
