Curvature

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 savvy 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

GLSL Port - MadeByEven

Click to open

Epic code in nodes

Click to open

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);
}

MF_CurvatureNode
MF_CurvatureRoughness

Mark Serena Written by:

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