ElevationRamp inside the polygon

My issue:
Create a polygon on the terrain - color the area inside the polygon like ElevationRamp for a globe or like a height-depending-heatmaps.

What I know for now:

  1. There is no ready solution out-of-the-box: Question: elevationramp-to-polyline
  2. It is possible: Looks like appropriate example
  3. I’ve already read about fabric and custom appearances
  4. I’m studying a basic of shaders.
  5. I’ve investigated this shaders example.

What I don’t know for now:
How to use my new knowledges on the practice (I’m new in the Cesium and some things are not very clear for me yet, but I’m working on it :slight_smile: ).

So, my questions are:

  1. Is my direction (to use fabric / appearance / shaders) is right?
    If no:
  2. Could you advice me something other that can help?
    If yes:
  3. Should I write everything (shaders, material, etc.) from scratch?
  4. Can I combine something ready (ex., something from GlobeFS.glsl or something) with new fabric or appearance?
  5. Does all kinds of primitives and entities can be used in this case?
  6. Could you share any appropriate examples?

Thanks in advance. I will be very appreciate for any help, explanations, conversation.


Great to hear that you are taking steps to learn the Cesium platform.

You are right, you would need to create a custom shader to use for the MaterialProperty of the polygon.

The easiest one to use is probably a rectangle entity with a default clamped to ground property, as in this example (please select “Draw Rectangle” from the dropdown menu). The code starts on line 166.

We currently don’t have an example for this specific use case.

What kind of project are you working on? What is the motivation behind drawing a customized polygon on the terrain (instead of using globe material like in the elevation ramp example)?


Thanks a lot for your answer!


Unfortunately, there is no link in your answer. But if I found correctly, you means this one, right?

  1. if I need a polygon, but it do not clamped to the ground by default, is it possible to make it clamped?
  2. Is it possible to use custom shaders at the entity? (it seemed to me, when I read about this things, that it possible to use custom appearance and, hence, custom shaders, at primitives only, but I can be wrong or confuse something).


  1. Do you have any examples not for this specific case, but maybe for the case of custom shaders for the entity?


The project is the construction data analytics platform (based on drone data and images).
One of the feature - a user create the polygon to estimate an area, volume, etc. of some specific object. And for some of cases we need to colorize a space inside the polygon depends on the height of a terrain.
We already use globe elevation ramp for other case, but here we need such visualization exactly inside the users’ polygon.

Yes it is possible. You can use PolygonGraphics with heightReference set to CLAMP_TO_GROUND. You can also use GroundPrimitive, which automatically drape over terrain.

My apologies, that is the correct link.

It is possible as noted in this discussion.

I have previously made an example for primitives here. I don’t recall seeing an example for entities.

Thank you for sharing your use case. We look forward to seeing the results and assisting you further with the project.

Hi! I came back to this task and have a new questions:

I’m trying to set custom material source for GroundPrimitive (please, see my Ground primitive example)
To solve my task I need to use height (like Globe ElevationRampMaterial), but as I see, materialInput.height is available for Globe only and I cannot use it for ground primitive.

Is it possible to add values of terrain height inside the polygon to the shader? Via uniforms, for example, or some other way?