How to change the texture in the normal direction

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:


cylinder_normal_texture.blend (1.4 MB)

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:


general_surface_normal_texture.blend (165.2 KB)

3 Likes

What a great idea!

I could actually try and then create the object I wanted.


Based on your advice, I will now try another form.

1 Like

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:

Thank you!

With the help of the link, I was able to change the material according to the height of the texture.

I still have a lot to figure out, including the attribute capture node, but this advice helped a lot.



1 Like