A shader function that can tell flatness?

http://img2.meristation.com/files/imagenes/juegos/pc/action/torchlight_ii/1.jpg

I really like the look of the stones in torchlight. Low poly but the textures are light at the edges of the stone and darker where it is flatter. Makes things look “worn”.

I am wondering if there is a function that I could use that could determine how “flat” the area I am currently using is. If I had total freedom I would think of getting the dot product of the normal at the very point I was calculating plus another point that was very close (actually a few points around and taking the mean of them or something) and that would give me a value that would give an idea of whether or not the point I am calculating is generally flat or near an edge, and use that to lerp between bright and dark as necessary. I can imagine this kind of thing would be easy in a normal blueprint but I don’t seem to find that same kind of functionality in the material blueprints

Any leads would be appreciated

In theory this is doable, I know that rendering software has those tricks. However, real-time creating that in a way that looks good and affordable by hardware is hard, plus not a thing that is shader only, you would probably need some extra data calculated on the cpu and pass it on to the shader. Or maybe some form of post processing.

However, the guys that made Torchlight just have really good artist that hand painted the whole thing. There is not much going on in the shader.

If you do want info in the shader like that, you might want to go for some cheap solution, like painting it in the vertex colors.

Thanks for that. I’ll have to look up vertex points regarding shadet. so fat I have completely managed to avoid uv unwrapping and baking and paint and all those things and wanted to carry on that procedure

is there a function for shiftin the uv a smal bit? like what panner does but not constantly moving?

Well, the function is just adding a value to the texture coordinate node. Panner is basically adding a value ever x amount of time. Adding a value of 0.5 to your uv’s will make sure they are shifted by half of the uv size. adding 1 would mean there are exactly “the same” again because you shifted them the size of the uv’s.