How to make a material with textures based on slope for a mesh ?

Hello everyone,
I’m facing a problem I can’t solve myself, even after many researches.

I made a material following some tutorials, which basically paints different textures depending on the slope. This works pretty well when it is applied to a Landscape actor, using UE4 editor.
But I created a procedural mesh at runtime using the RuntimeMeshComponent to generate my landscape myself, and when I apply my material to my landscape, the material doesn’t apply as expected. I mean it only paints grass, which is the top of the material.

To illustrate my issue, here are three pictures. The first is about my Material blueprint, the second about what it renders applied to a Landscape made with the editor, and the third is what it looks like on my generated map mesh.

Material Blueprint :

Landscape rendering :

Runtime mesh rendering :

If you have any idea about how to solve this, it would help me a lot.
Thanks a lot for your time

Hey Nazruden,

This procedural mesh you’re generating, does it have any Normals?
You can generate these from the Vertices/Triangles/UVs and then use those Normals/Tangents when you generate your procedural section.


My first guess would be your material node to define the slope tries to access these Normals and they have not yet been created by you.

Oh good point, I have my normals and tangents initialized to some constant value actually, gonna try calculating them after the vertices and triangles generation. By the way, I’m doing the generation in C++ but I guess that’s the same function as in blueprint :slight_smile: Thanks man