Whilst playing the games Dishonored 2 and Prey, I had noticed that on the curved edges of a lot the models - there was a bit of roughness in order to make the specular highlights pop a bit. I really liked this effect and decided to replicate it in UE4. At first, I didn't know how to approach this and experimented with generating curvature maps in Substance that I added to the roughness channel. Whilst this achieved the desired effect, it wasn't very dynamic so I decided to take a real time approach.
Here is the node layout for the material function:
The method I have incorporated uses screen-space operations for real-time effects, using DDY and DDX nodes - something I have never used. In order to calculate the curvature, I had to take the pixel normal in world space and calculate the dot product between the neighbouring pixels. This allows me to see how steep the change in surface is per pixel. I added a power node after that in order to control the falloff of the curvature, a multiply after that to control the intensity, an add node to control the curvature bias and finally a saturate node to limit the effect between 0 and 1.
As the function uses pixel normal values, the change in direction on a normal texture will also be taken into account which means baked surface normal detail will produce a realistic looking roughness. This material function is very cheap and can be adjusted on the fly, giving greater artistic control. However, a downside to this approach is that it doesn't look as crisp as a texture-based approach, because the DDY and DDX processes the pixels in chunkes of 2x2. This is more noticeable at longer distances, however I personally quite like it as it gives the surface a more realistic appearance.
Here are some screenshots with the material function applied and using various parameters:
Comments