Blending Materials by Heights

Hello everyone,

Im currently trying to get this working using cycles mix shader but cant get it to work as it should and i seem to make it worse everythime i touch it.

does anyone know a better way of doing this or can spot the misstake i did? (


I think you need something like this … {hopefully you can see the node group}

A number of things …

First, to be able to blend the two textures on height, you need to have a height difference
Using a smooth sphere there is no comparative height over the surface
To simulate height I added a displace modifier to make the sphere bumpy

Secondly you need to be able to obtain the height
You were trying to do that using the normal and Z coordinate, but this merely merges over the height of the sphere instead of the sphere group level
To determine the distance from the centre of the sphere to get the height the nodes above use a dot product by itself and then some math {given a sphere radius 1 the displacement makes the surface 1 ± about 0.2} to create a value that ranges from 0 to 1
This is then further saturated by the colour ramp

Finally I used essentially the brightness of the textures {recognising the dark rocky one has cracks and the lighter planty one has highlights} to add a bump map to the shaders to add a little more height type detail

Hope this helps


And point 4 … the link you give is for creating an OSL shader
Blender Cycles can also use OSL so you could in fact use the code in the article nearly ‘as is’!

hey thanks for taing a look at this however i think you got me wrong.

i am not trying to blend it by the height of the geometry but the height of the textures (heightmap) included in the example blend for transitions between grass and cliff based on the normals.

and i try to stay away from OSL since i had several problems when i tryed to use it (and the provided example is GLSL not OSL)

here are some blend examples from dota 2 editor where they use a similar if not the same technique (this are textures not 3d models):

where the blend (mix) factor changes from something like 1 to 0.5

If i understand correctly you can play with mix nodes and color ramps, the highlighted nodes in the screenshot:

In that case i multiplied the blend layer (the one you done with the geometry normal) with the soil height map. What happens is that if the soil height map is 0 (soil crack where there should be no grass) the output value will be 0 , so the mix shader node will “choose” the soil.
You can also try inserting the color ramp between the image texture and mix node or choose other mix types…

Sorry, still misunderstood - deleted