I have sculpted a planet in Zbrush and now I am trying to make a shader that would work based on elevation and slopes. I have learned that the position node stores the center of the planet, but I can;t understand how to get values for surface elevation.
I can bake a Height map, true. I just want to learn how to do this more efficiently
A height map baked into the vertices is the most efficient way to do this. Could be stored as the vertex color, or a second UV set. A height map texture is also an acceptable way to do this.
If you want a purely shader based approach, you can look at the length of the object space position which gives you the distance from the center of the planet. You will have to manually supply the min & max ranges as material properties. Shaders don’t have information about the entire mesh, each invocation only knows about the individual vertex or screen pixel it is currently working on.
Like bgolus said, you can take the fragment position distance to the center to get elevation. For slope bake the elevation to a tangent space normal map on a regular sphere, then sample that.
Thanks guys, I’ll get to working on that. On a side note, any idea why emission isn’t making an object glow? I am trying to make atmosphere for a planet, Perhaps not the best way to do it, because there is limited control? how would you suggest I go about that?