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)?
Unfortunately, there is no link in your answer. But if I found correctly, you means this one, right?
if I need a polygon, but it do not clamped to the ground by default, is it possible to make it clamped?
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).
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.
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?
Thanks for your link.
I’m digging in this direction - if we cannot get height inside shader, let’s set it outside and use via uniforms.
a). As mentioned here, it is possible to generate texture using undocumented API and set it to the material uniforms.
b). Texture data should be rectangle, so we need to get bounding box for our polygon.
c). To get height data we can use sampleTerrainMostDetailed.
d). But, as we need to know height values not in the vertexes only, but inside the polygon too, we need to generate a set of points with small step between each other. We may do it using pointGrid for the polygon bbox via Turf library.
I still didn’t get final results, but this direction seems promising to me.
I’ve been trying to understand the heatmap example, I couldn’t figure out how to texture map is associated with the texture coordinate (st). If you look at the fragment shader code in the example, it uses the materialInput.st value to pick the colour from the texture. But in our case, we need to pick colors based on elevation, right?
The main point I took there - how to set custom texture to the shader.
As we need to pick colors based on elevation and we cannot get elevation inside the shader, we have to get elevations outside. So, for our case we can create a texture based on elevation data and after that picked the colors from it.
Here I can easily visualize how it’ll overlap/map on the polygon and we can simply pick the colour using st. But in our case, it’s a 1D array of colours, I can’t visualize how texture maps with the polygon. How st value is going to map with the correct texel in the texture since colour is supposed to be picked based on the elevation. So what is the relation between st and elevation data?