Terrain Shading based on slope of mesh.

Any Ideas on creating a shader that places textures based on the slope angle of each polly on a mesh.
this technique in lightwave9s new shader node system, can do realy cool terrain shading. Also is it possible for the unity shading system, to place textures according to vertex(weight,color) maps set up in a 3d app ?

The short answer is “everything’s possible”, of course :wink:

However, a terrain has to be rendered in realtime, and that does have some complications (e.g. mixing a lot of textures at runtime is slow). That’s why most terrain shaders are somewhat optimized for some particular usage.

So to answer your question again, yes it is possible to mix textures based on vertex colors, slopes (i.e. normals), other textures or basically anything else. You just have to decide what exactly do you want (e.g. “blend between two textures based on slope”) and just write a shader to do that, or find someone who would help in writing the shader.

Some existing terrain-related shaders are on Unify wiki (LayerShader, TwoLayerBumped) and on the forum (“more about terrain…”)

I haven’t done any shader programming before. How difficult would it be to create a shader that blends two textures according to the normals of a mesh? I just want a “slopes are rocky, plains are grassy” effect.

It would probably be easier (and MUCH faster) to write a script that creates a mask based on the normals and applies it to one of the two-layer scripts Aras posted.

Don’t you often want to do that based mostly on height, not on the slope?

I.e. based on slope - would the top of rocky hill be grassy? (it has no slope…)

I’m not dealing with a very large range of altitudes. I just want to be able to show which bits of terrain are passable. Another texture based on altitude might be nice, but not necessary.

But another texture, or vertex colors in the mesh most likely will work faster. You can easily generate the texture or vertex colors at load time with a script.

Sounds like a better approach. Thanks!