Download

Curvature Shader for procedural texturing please

Hello here,

can we please get a Curvature shader for our materials, so that we can realize procedural texturing with it?
Because now, that we can have multi million polygon heavy objects, it would be really nice, if we can texture them with triplanar mapping, and define things like Edge damage via a curvature shader and some masks (f.e. stored in vertex color).

What do you think?

I wonder if it can be derived from the normal? i currently derive both the blue channel of the normal from red and green and then cavity from the full normal. IIRC Dice did a presentation on it back in 2016-17 GDC. If we can get the world space normals in the material, it should just be abit of math to create a curvature map mask. Im not really a shader wiz, but maybe someone else can expand on this?

There exist some Screenspace Curvature Shader (or as PostProcess), but those i found have all the same problem: They act only on what is on the screen, and fail the moment, reflections are involved. F.e. you see your object in a mirror, the reflected object has not this effect.
Pretty bad, if you use it for a Tron-Like material to get the famous edge glow, and all your reflections come without that edge glow ^.^

Like this one here:

https://markserena.com.au/post/ue4_screenspacecurvature/

A real curvature shader would not break with reflections :slight_smile:

You can do it with ddx and ddy but it depends on the mesh very much and it has a weird fading out when you move close to the object.
What you need is a “edge distance” kinda thing where you have a gradient with value of 1 at the peak of the edge and 0 at the middle of the surface. that way you can create “smart masks” like in painter.
A curvature function will show only polygons that are at an angle from adjacent polys, which is not very useful if your mesh has hard edges or very thin strips of face weighted polys

Sounds interesting, do you have an example blueprint by any chance? And will this work with raytraced reflections too?