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

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

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

Thank you, here is the C++ snippet

	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());
       }

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:

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:

  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

Hi Kevin,

Thank you, the workaround works.

Regards,
Asaf