[FREE] Curvature Shader

Hi,

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.

Youtube

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.

14 Likes

@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
Markus

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.
de6f970aa443a474698162a4d2b07ea9f659048e.jpeg
@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?

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?

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

Hi, I would be very interested in this as it is exactly what I need for my project. I do not see a download link and apparently, it’s not working on new versions anyways. I wouldn’t mind paying for such a plugin.

Thank you Mserena for the great resource. I got a variation of this technique to work in 4.25 and 4.26. I put the variation on the UE4 marketplace so others could try it out.

There are a few limitations, it doesn’t seem to work great for edge wear on low poly right angles. It works better on high-poly (10k+ tris) objects.

If you’re looking for edge wear in UE4, this Polycount thread helped me

I think there is a couple of mistake here, first you do transforms from screen space to world space, it should be the opposite, also you divide by the normals length in the end, but normals in UE4 are automatically normalized, so they should be equal to one. I am no GLSL expert but in the original code it was referring to vertex, due to the nature of the algorithm dividing by distance to vertices or even pixels could make sense but I am not sure.