rendering behind terrain with different style

1. A concise explanation of the problem you’re experiencing.

I want to be able to render elements behind the terrain and give them a different style when they are behind the terrain, at the same time some may be behind the terrain and some are not. their style should adapt accordingly.

Any suggestion?

I really do not want to go to the solution of having to different cesium instances, one for the items behind the terrain and one for the others while the difference between them is depthTestAgainstTerrain value

4. The Cesium version you’re using, your operating system and browser.

latest. chrome.

Hey Ariel,

Have you tried using a depthFailMaterial, like in this code example? That example colors the part of the line occluded by terrain or 3D Tiles as red, and the part that is visible in yellow.

Hi Omar,

thanks for the example but it seems this feature is not working if we are using “clampToGround:true”.
what can you suggest or is there any other option?

I think this might just be a matter of adding support for this for clamped polylines. I opened a GitHub issue here with more details:

In the meantime, you could do what the Sandcastle I linked to there does: sample the terrain positions along your polyline, and create a polyline that is not clamped to ground, but has the ground positions baked in in that way. Let me know if that helps.

What kind of application are you doing with Cesium?