[FREE] Curvature Shader


Made a curvature shader based of this GLSL shader

  • Updated to use BasePassPixelShader.usf version of NormalCurvatureToRoughness it’s cheaper and with a better result.


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.

Zip attached

---- Updated with function to include PostProcess
---- Updated 2 - New function based off BasePassPixelShader.usf recreated in function attached with image to recreate it.


@mserena: Hi, looks interesting. I just had a brief look on the shader (your supplied uasset from the zip only works in 4.16, 4.15 and earlier versions do not recognize it).
A question: can you please supply more info or explain how you have used your MF in the material from the examples (picture above and video) - maybe you can post a screenshot of the material BP?

THX and greetings

Super useful, thank you! I made something similar a while back but didn’t get a result quite this good, this looks a lot nicer.

thank you.

@hessjacobs sure here you go. nothing that won’t work in previous versions.
@Sitrec thank you, all credit goes out to Evan Wallace though, I just rebuilt his glsl shader.

@mserena: thanks - got it working in 4.14, of course :slight_smile: In your example video how did you setup your red/green material? … just using a lerp function between colors an applying the MF output to the alpha input of the lerp?

yep, just a lerp using the curvature as the alpha

Is there a way to make this a postprocess shader?

Sure thing, just updated my post to include a PP function to do it. Tried to incorporate into the same function but it complained about it being used in an opaque material.
But the process is just replace the PixelNormalWS with sceneTexture : worldNormal

yep, just use it as the alpha in the lerp and it will blend two colours based of the curvature

Thanks mserena, this is awesome. I working for a surgical simulator company and I’m trying to use your shader to fill the mesh cracks with blood but the threshold is stock on fine details, I’m trying to change it to the bigger shapes but have a hard time to find what to change. I wonder if you could hint me where I should start? And Do you think that would be possible to fill the curvature of overlapping objects cracks? Well thank you if you can’t help anyway, this is already awesome giving it free.

Hey Mark, from what I saw on the youtube video, this looks fantastic! But I can’t see any download in this thread?

Oh snap! I have an idea

@Acriax the first post should have a two zips you can download, two different methods and there’s also a picture showing you how to recreate it.

Ah, my mistake! Seems I can’t see attachments when I’m logged into the forums for some reason. :S

Is there a way to make it not blend based on camera distance? Would just love to include this is shader

Is there a way to do this without the camera affecting it?

Awesome, thank you very much for this!

How can you use it to like applying edge wear?

Sadly, this seems not to work anymore in newer versions of UE (maybe I can save someone some time ;))