I want to colour the polygon based on the elevation ramp, similar to the elevation ramp example on the globe but confined to the drawn polygon - Cesium Sandcastle
Things I’ve explored so far
I’ve gone through some similar questions but couldn’t find any solution to this -
- ElevationRamp inside the polygon
- Elevation Ramp material for geometry instances
I’ve gone through few links to get some understanding on Shaders, GLSL and Cesium Fabric -
- Fabric docs: Fabric · CesiumGS/cesium Wiki · GitHub
- Basics of Shaders: The Book of Shaders: What is a shader?
Things which I have tried
I’ve created a minimal example where I’m painting polygon using a custom fragment shader script through fabric - Cesium Sandcastle
Edit: I extended the previous example and wrote custom vertex and fragment shaders (based on GlobeVS). It still doesn’t work because
position3DAndHeight attribute is missing. How I can calculate this and pass it to the vertex shader? How it’s done in the case of Globe? - Cesium Sandcastle
This example currently paints the polygon with black colour, it’s because
materialInput.height is not present, it’s only available when the material is applied on the globe. Fragment position and height is required to select the colour from the elevation ramp but I was not able to get the height. I’ve looked into the GlobeVS.glsl file and figured that
v_height is being set by the vertex shader which is basically used in the GlobeFS.glsl to set the
I further explored and found that
GlobeVS.glsl is computed from the
position3DAndHeight attribute, but couldn’t figure out from where it’s being passed down to the
I don’t know how I can get this world height information in my custom Vertex shader so that I can pass it down to Fragment shader. If only I can get the height of the fragment, I can pick the right colour from the elevation ramp.
Areas where I need help
- How to get the height information for the fragment in my custom
Fragment Shaderfor polygon
- Basic example of writing vector and fragment shader from scratch. Existing scripts in the repository are quite complex and I’m having a hard time wrapping my head around it.
- Various functions like
czm_eastNorthUpToEyeCoordinatesare being used in the Cesium’s GLSL scripts, is there any documentation on it?
A couple of parallel conversations happening on different tickets on a different approach which seems very promising -