UE4 Curvature Function

UE4 ScreenSpace Curvature GLSL Port

Ported over a GLSL shader from MadeByEvan to Unreal as a Material Function for doing ScreenSpace Curvature. Also converted a more simplified version from Epic into nodes as well.

The normals are interpolated linearly so the faceting can’t be fixed at the moment, but with higher resolution mesh or more math savy people (or UE4 will do smooth interpolated normals) this could be improved upon.
Lemme know if you find it useful. Built in 4.16 but can be for any version.

Link to forum post HERE

MadeByEvan port
Epic code in nodes

float NormalCurvatureToRoughness(float3 WorldNormal)
    float3 dNdx = ddx(WorldNormal);
    float3 dNdy = ddy(WorldNormal);
    float x = dot(dNdx, dNdx);
    float y = dot(dNdy, dNdy);
    float CurvatureApprox = pow(max(x, y), View.NormalCurvatureToRoughnessScaleBias.z);
	return saturate(CurvatureApprox * View.NormalCurvatureToRoughnessScaleBias.x + View.NormalCurvatureToRoughnessScaleBias.y);


Mark Serena Written by:

Mark is an artist with a passion for technical art and things beyond his comprehension.