Using Shader Graph to Create RGB Gradient for Terrain on a Sphere

Hi everyone,

So, I’ve begun researching this and unfortunately I don’t know what I don’t know.

Heres the idea:

  • I have a non-perfect spherical object that has some terrain. Craters, ridges, depressions, etc…

  • I would like to create an RGB gradient digital terrain map of that sphere, where different elevations have a different color.

I believe this will involve vertex shading? In my head the idea is to calculate the distance between the center of the object, and a given vertex then apply the appropriate color to that vertex based on the distance.

Trying to accomplish this in Shader Graph has been a bit, over-whelming as I’ve stumbled upon tri-planar mapping, geometric shaders, vertex shaders, etc…

Would someone please point me in the right direction? Thanks!

*Worth mentioning that I’m using the URP.

**I’ve attached a photo of the basic idea that I’d like to accomplish, however the coloring in the photo is wrong as it looks like its probably shading along a global y axis, or using the bottom of the object as the origin rather than the center.

I don’t really know what you don’t know either. It seems like you have a good idea of the math behind it so all you need to do is translate that to a graph. I’m guessing the center is the origin of the object so you can just take the length of the position vector as height (otherwise you’d just feed in the center point and calculate the distance).