Hi.
I was able to change the color by Z height difference.
In the same way, I want to change the material for a cylindrical object according to its normal height.
What is the best way to do this?
Hi.
I was able to change the color by Z height difference.
In the same way, I want to change the material for a cylindrical object according to its normal height.
What is the best way to do this?
For a cylinder, you can compute the normal distance easily from the geometry position: just set the z-component to zero and compute the vector length (this gives you the radial distance), and feed that through a map range node:
I’ll post a solution based on geometry nodes suitable for general surfaces later.
For the general solution you need two meshes: one with only the general, low frequency curvature, and a second one with the high frequency displacement.
Here, I use an ellipsoid for the base mesh, called “Surface_Base” with a sub-d modifier.
For the displaced mesh, I use a second object “Surface_Displaced” where the geometry of the base mesh is linked and which has the same sub-d modifier. Additionally, I use a displacement modifier with midlevel adjusted and a geometry node setup with output mapped to the new attribute “Height” which I also use in the shader setup.
The geometry nodes setup works like this: I search for the nearest surface point on the base mesh, and use the dot product with the normal on the base mesh to compute the height difference, which I map to the output attribute:
In the shader I can then use the created “Height” attribute as an input to the map range and color ramp nodes:
What a great idea!
I could actually try and then create the object I wanted.
Just another point: If you are creating the displacement from a height-map texture in the first place, you can use that in the shader setup, although the details are a bit more involved: