Custom shader on terrain, can i get the terrain normals somehow?

I would like to use the terrain’s normals in my fabric shader. Could i do that somehow? My naive idea

const material = new Cesium.Material({
fabric: {
uniforms: {
image: “…/images/earthspec1k.jpg”,
heightField: “…/images/earthbump1k.jpg”,
materials: {
bumpMap: {
type: “BumpMap”,
uniforms: {
image: “…/images/earthbump1k.jpg”,
source: czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec4 color; material.diffuse = materialInput.normalEC;//color.rgb; material.alpha = 0.5;//color.a; return material; } ,
viewer.scene.globe.material = material

Will those be available in shader?
const viewer = new Cesium.Viewer(“cesiumContainer”, {
terrain: Cesium.Terrain.fromWorldTerrain({
requestVertexNormals: true, //Needed to visualize slope

Hi @ka_sc, you are correct that the normals should be available via materialInput.normalEC. I am not quite clear on what your code example is trying to do. Did it already show what you wanted?

Here is a quick Sandcastle example that uses the terrain normal to color the terrain.

1 Like

Very exciting. I wasnt sure if it worked

Somehow if i zoom closer i loose the normals in your castle. The highest resolution is probably the most interesting…