Author Topic: Mixing materials based on terrain slope (normal)  (Read 2928 times)

Hello, I'm very new to Substance Designer and I'd like to ask some help about mixing, for example, two noise generator nodes so that the first appear where the object (an imported terrain .obj) normal is <45°, and the second where it's >=45°, possibly with a fuzzy area to allow a smooth transition between the two noise materials.
Is this possible to achieve some way?
Thanks for any help

Hey Alessandro,

this is something you need to do in the Engine Shader. It is not possible in Substance Designer.


Best Regards
Environment Artist - Twitter

Thanks for the quick answer Fabian. So not even using a baked normal map as a sort of 'mask' would do the trick?

Well, you could bake a world space normal and create the blending mask according to it. But it'd really be counter productive: this kind of things are generally made directly in the shader within the game engine as Fabian says.
Product Manager - Allegorithmic

Sure you can do this. You'll need a world space normal map. Extract the channel that represents up with an RGBA split node (which that is might vary depending on the coordinate space used, probably green or blue). Then you can level this channel to make a mask. Just use that to blend two inputs in a blend node.

That way you can do stuff like have sand on the horizontal surfaces or rock on the steeper slopes.

If you want specific angles there's probably a better way to do it, but you might have to write a function.

Sure you can do this. You'll need a world space normal map. Extract the channel that represents up with an RGBA split node (which that is might vary depending on the coordinate space used, probably green or blue). Then you can level this channel to make a mask. Just use that to blend two inputs in a blend node.

That way you can do stuff like have sand on the horizontal surfaces or rock on the steeper slopes.

If you want specific angles there's probably a better way to do it, but you might have to write a function.

I can confirm this indeed works pretty well, it's not perfect though by any means. A little blur or sharpen can hide stuff.

Out of interest some of you mentioned fixing this in the engine. How would you do this without modifying the UV map if at all possible. I have a lot of terrain and wish to find a easy one fixes all solution if it's out there? Interesting topic. :D
Yo

I think the reason why the people with the shiny colors on their names are suggesting making changes to the shaders in-engine instead of using SD is because, with terrain, there's no way to ever really get enough detail in one image map to make it look any good. You can make the image quite effectively in SD (there's actually a node in the Normal category to turn normal maps to slope intensity map) but as soon as it's put on a terrain object, it would look like blurry squares to anyone actually playing a game.

If you're only making a texture for, say, an in-game paper map, this might be just fine. They won't actually be walking ON the texture. But if it's a full-sized terrain, usually a splat-map is used. This takes multiple, tiling textures and uses a color-coded painted map to determine which tiling texture is visible at any given spot. So it just depends what you're trying to accomplish with this texture, I guess.

Yeah I totally get you, I've seen tri planar shaders do a great job with slopes but I think they just ignore the UV and project the textures to scale on the surfaces from what I can tell in Unity. From my tests blurring slopes is the only acceptable visual look for it to hide blocky slope pixels without a specialist shader, great if you have 1600 tiles in game. I don't really want to modify the UV's to fit as it means modifying the splat map to fit also - can of worms inside... :)

If it's possible to batch Auto UV to scale faces correctly and modify the splat map with the batching to stretch to fit with the UV then this could be a interesting solution when using mesh terrain. RobinB's solution also involves baking loads of World Space Normal / Position maps too for each tile or groups to accompany that effect of which can be computed in shader land. I've made a shader to do World Space Normal colouring already, not sure how to do position yet. 
Yo