How do you do blend textures in cycles?

At 17 minutes in this tut he starts making mountains and using blends based on the z value to pick which color to use.
http://cgcookie.com/blender/lessons/creating-an-island-environment-in-blender-2-6-part-01/

I would like to to this same video but in cycles. How do you get the Z value form a mesh to feed into the fac of the mix shader? Or is there a better way?

Thanks!

I’m sure there are more elegant ways to do it, but for my playing around with terrains I use:

Altitude-based ground covering (dirt, grass, snow): ‘Texture Coordinate: Generated’ blue channel into a ColorRamp to control MixShaders.

Angle-based coverings (rocky sheer surfaces, grass/dirt/snow flatter surfaces): ‘Geometry: True Normal’ into a Normal node then ColorRamp into a MixShader.

A couple of these together give a quick dirty, grassy, rocky, snowy base.

OK, that is really cool but why the blue channel? How does this work? What does generated output?
Thanks!

PS
Your last photo is too blurry. Can you include a blend or post a better shot?

The last pic is just showing several MixShaders strung together to paint a DEM, so the specific nodes aren’t that important.

How does this work? Pipe the ‘Texture Coordinate’ into a Diffuse shader and you’ll see how those colours relate to the object.

wiki.blender.org’s ‘Bump and Normal Maps’ page states:

Normal maps in Blender store a normal as follows:

  • Red maps from (0-255) to X (-1.0 - 1.0)
  • Green maps from (0-255) to Y (-1.0 - 1.0)
  • Blue maps from (0-255) to Z (0.0 - 1.0)

We’re interested in the object’s Z axis, so using ‘Separate RGB’ to isolate the blue channel, we get an automatically generated height map where 0.0 is the lowest part of the object and 1.0 the highest.

Feeding that Blue component into ColorRamps, we can then tweak the gradients to control the MixShaders. Repeat for as many levels as required.

As for how robust or future-proof this method is, I’ll defer to someone more experienced in Blender.

The concept is the same for angle-based mixing. Rather than the Geometry node I suggested above, it looks like ‘Texture Coordinate: Normal’ can be used. Piping that into a Diffuse shader shows the Blue value is 0 for vertical faces, increasing to 1 for horizontal faces.

Again we can feed that Blue value into a ColorRamp to control a MixShader.

Thanks. I worked a bit on it myself and came up with this. It works well and is simple. To change from angle to Z, all you have to do is change the input.

Question, what is that linking rope with a dot in it? I found that I can connect it to an input and it works just fine. I have never seen a Y-joint before. Perhaps a hidden node or what?

Thanks.


This was great thanks for the post on this…

Thanks Spaced!
I always try to solve everything with UV mapping but this is a lot easier!

This brings another question. How do you control the mapping coordinates with an empty, in BI this is very easy, and you can animate texture blending. I guess you can put a key into the color ramp and animate it that way. But with the empty technique you can move in all axis.
TIA

One thing that eveyrone should note… try to use as little BSDF nodes as possible… they are quite slow with calculations… if the only type of bsdf node you are using is diffuse, you can simplify it down to only one bsdf node and do everythign in colour mix nodes instead… it will be faster overall and wont have any visual difference in the end.

i believe to get the reroute node you hold down shift and drag over a noodle… (what you called a y joint node)… you can move this anywhere… the point is to clean up node networks

@ doublebishop Thanks for the heads up on BSDF… had not realized that…