Cesium UE5.6 Issue with height based shader

Im trying to separate mountains and from flats, using raster overlay material, the issue im facing is that i have tried using local z position, world space, local space, using pixel normal/vertex normal dot products, doesnt work , at the end, they give weird results, the local z is messed up, for a normal displaced plane that i created it works with the shader, but in cesium it doesnt, is there a different way i can approach, i dont want to do per actor shading, it would probably be expensive and not that accurate, thank you

using local z :

Hey @Aman-701, could you share a bit more about what you’re trying to achieve? I’m not sure I fully understand the end goal. For example:

  • Are you trying to colorize terrain by elevation (e.g., green at low altitudes, white at peaks)?
  • Or are you trying to mask/blend between different materials based on slope or height?
  • How large is the area you’re working with?

Also, have you looked at the Cesium for Unreal Samples project? (also available in Fab) Specifically, Level 9 - Material Editing (Content/CesiumSamples/Maps/09/09_CesiumMaterialEditing) demonstrates custom material effects applied to Cesium World Terrain, and the CesiumSamples/Materials folder has several example materials you can reference. That would be a good starting point for understanding how to hook into the Cesium material pipeline.

Cheers!

so cesium javascript has this function called function HeightmapTerrainData(options)
which returns texture which can be used as height mask, (Source : Code Github )
why isnt it in cesium ue5, or do i need to modify the plugin myself, or is it implemented in some other way

Hey @Aman-701,

As you mentioned HeightmapTerrainData is CesiumJS class that represents raw terrain heightmap tile data internally. It’s not a texture you can sample in a material, and it doesn’t have an equivalent in Cesium for Unreal, Unreal Engine is an entirely different platform and porting all features is not always feasible or even possible.

I digress, in Cesium for Unreal, the right way to do height-based material effects is through the Absolute World Position node in the material graph (not local space). The reason local Z doesn’t work as expected is that Cesium tiles are spawned at different world positions as the globe traverses – “local” is relative to each individual tile, so it’s not consistent across the terrain.

With Absolute World Position, you get the real-world Z coordinate (in centimeters) that you can use in a linear/smoothstep to blend between your flat and mountain materials at a given elevation threshold.

I’d strongly recommend checking out the Cesium for Unreal Samples project (available on Fab) and looking at Level 9 – 09_CesiumMaterialEditing. It has pre-built material examples for elevation band coloring that you can open up, study, and adapt directly. That should save you a lot of trial and error. Have you looked at this sample yet?

I’ve attached some screenshot of the CesiumHeightBlend material included in the samples project, added to the tileset in Level 9:



Let me know if that points you in the right direction!

Cheers!