# How to create Aspect Map in Cesium

**URL:** <https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701>\
**Category:** CesiumJS\
**Created:** [November 17, 2018, 2:03pm UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701 "2018-11-17T14:03:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sritushar0109](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@sritushar0109](https://community.cesium.com/u/sritushar0109)\
**Post date:** [November 17, 2018, 2:03pm UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/1 "2018-11-17T14:03:14Z")

</div>

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

I want to create Aspect Map in Cesium.

How should I get insight of fabric properties in Material, precisely for aspect map?

the below link  
[https://github.com/AnalyticalGraphicsInc/cesium/wiki/Fabric](https://github.com/AnalyticalGraphicsInc/cesium/wiki/Fabric)

defines the usage of fabric but does not entails the potential values of attributes like type, materials, components etc of fabric within Cesium.Material

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

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

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [November 19, 2018, 4:19pm UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/2 "2018-11-19T16:19:42Z")

</div>

Better documentation for the fabric system is definitely something I’d love to see improve.

In the mean time, you might find this example that colors the terrain based on elevation useful:

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=Globe%20Materials.html)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

Let me know if that helps, or if there’s a specific thing you’re trying to do that you’re stuck on.

---

<div class="post-metadata">

**Author:** ![sritushar0109](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@sritushar0109](https://community.cesium.com/u/sritushar0109)\
**Post date:** [November 19, 2018, 5:02pm UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/3 "2018-11-19T17:02:57Z")

</div>

Hi Omar,

Thanks for the reply.

I already saw this example but its somehow not fulfilling my need of creating an aspect map or more clearly a direction map with 8 directions East, West, North, South, North East, North West, South East, South West.

This example explains creating slope, elevation and contours and its implemented through fabric property of Cesium Materials but no support on this aspect map. I am eyeing Elevation Ramp for Aspect Map but I am not sure whether it will take me in the right path.

Please direct me the to the properties and its values for fabric, to produce an aspect map.

Regards,  
Tushar

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [November 27, 2018, 8:21pm UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/4 "2018-11-27T20:21:11Z")

</div>

If all you need is the direction of the surface at each point, I think you should be able to do this by using the normal at any given pixel, which should be possible with a custom shader. It is a bit involved, and there isn’t currently a tutorial the Fabric system, but it’s definitely something I’ll make sure to cover as we update our learning materials.

---

<div class="post-metadata">

**Author:** ![sritushar0109](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@sritushar0109](https://community.cesium.com/u/sritushar0109)\
**Post date:** [November 29, 2018, 9:00am UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/5 "2018-11-29T09:00:41Z")

</div>

May I have some sample example, towards this approach, I am trying to get the aspect of the slope, like if slope is on east side of rockies, moving down to great plains then I should get its aspect in terms of degrees.

I want to provide my own terrain, then I want to draw the slope layer and aspect layer over it.

The aspect will be calculated from the perspective of highest elevation point of rockies towards its slopes leading to great plains.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [December 4, 2018, 7:14pm UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/6 "2018-12-04T19:14:53Z")

</div>

I don’t have any ready-made examples to share unfortunately. This recent thread is someone trying to do a similar thing so it might be good to keep an eye on:

[https://groups.google.com/d/msg/cesium-dev/Us4\_CBDWtco/OMWzzndkBgAJ](https://groups.google.com/d/msg/cesium-dev/Us4_CBDWtco/OMWzzndkBgAJ)

---

<div class="post-metadata">

**Author:** ![sritushar0109](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@sritushar0109](https://community.cesium.com/u/sritushar0109)\
**Post date:** [December 7, 2018, 7:47am UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/7 "2018-12-07T07:47:08Z")

</div>

Hi Omar,

This is what I am working at

function makeShadersDirty(globe) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var defines = ;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var requireNormals = defined(globe.\_material) && (globe.\_material.shaderSource.match(/slope/) || globe.\_material.shaderSource.match('normalEC'));

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var fragmentSources = ;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (defined(globe.\_material) && (!requireNormals || globe.\_terrainProvider.requestVertexNormals)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fragmentSources.push(globe.\_material.shaderSource);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;defines.push('APPLY\_MATERIAL');  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;globe.\_surface.\_tileProvider.uniformMap = globe.\_material.\_uniforms;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;globe.\_surface.\_tileProvider.uniformMap = undefined;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fragmentSources.push(GlobeFS);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;globe.\_surfaceShaderSet.baseVertexShaderSource = new ShaderSource({  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sources : [GroundAtmosphere, GlobeVS],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;defines : defines  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;globe.\_surfaceShaderSet.baseFragmentShaderSource = new ShaderSource({  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sources : fragmentSources,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;defines : defines  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;globe.\_surfaceShaderSet.material = globe.\_material;  
&nbsp;&nbsp;&nbsp;&nbsp;}

GlobeVS.glsl has this

#ifdef APPLY\_MATERIAL  
&nbsp;&nbsp;&nbsp;&nbsp;vec3 finalNormal = normalMC;  
&nbsp;&nbsp;&nbsp;&nbsp;vec3 ellipsoidNormal = normalize(position3DWC.xyz);  
&nbsp;&nbsp;&nbsp;&nbsp;v\_slope = abs(dot(ellipsoidNormal, finalNormal));  
&nbsp;&nbsp;&nbsp;&nbsp;v\_height = height;  
#endif

By far, this glsl has been invoked from Globe.js and Custom Shader Source implies to work with czm\_materialInput that is defined as

/\*\*  
\* Used as input to every material's czm\_getMaterial function.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [December 17, 2018, 4:29pm UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/8 "2018-12-17T16:29:52Z")

</div>

Looks like there’s been some work on supporting this, check out this PR:

[https://github.com/AnalyticalGraphicsInc/cesium/pull/7415](https://github.com/AnalyticalGraphicsInc/cesium/pull/7415)

I’m not sure when it will get merged but you should be able to use their fork of Cesium if you want to develop with this feature right away. Feel free to provide feedback on it in that link above!

---

<div class="post-metadata">

**Author:** ![sean\_lilley](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sean_lilley/32/2083_2.png) [@sean\_lilley](https://community.cesium.com/u/sean_lilley)\
**Post date:** [February 4, 2019, 2:09pm UTC](https://community.cesium.com/t/how-to-create-aspect-map-in-cesium/7701/9 "2019-02-04T14:09:35Z")

</div>

Hi everyone, the PR Omar linked above was merged and will ship with Cesium 1.55 on March 1st.
