One of the more disappointing things about UE4 is a lack of specularity on translucent objects, which makes stuff like my water more difficult. Some people have taken to passing in a light vector and building blinn/phong lighting in the pixel shader. I'll be showing how to do that with the specular model that is closer to what UE4 uses, as well as another model for comparison.
To start out here is the default lighting with no direct specular:
Lit Translucency - The highlights are all due to screenspace reflection.
To start out here is the default lighting with no direct specular:
Lit Translucency - The highlights are all due to screenspace reflection.
and here is UE4's opaque shader:
In order to get a specular highlight i needed a light vector, so I made a level blueprint that passes the directional light vector to a material collection. This way multiple shaders can access the same global attribute if needed.
We can then use this new attribute to add a specular highlight. Here it is with a custom Blinn specular added through the emissive channel
Lit Translucency + Blinn
If you compare this to UE4's specularity though, its
Here are each shader again, specular only (well...specular + screenspace reflections):
Here are each shader again, specular only (well...specular + screenspace reflections):
Blinn
UE4 Specular
UE4's specular is much more advanced than Blinn and to get this kind of specularity, we will need to rebuild it from scratch like we did for the Blinn. This paper is a good read for those looking to figure out how exactly the shader works (WARNING: MATH). To get a handle on doing this in UE4, i used the Cook Toorance shader I wrote a while back as the basis for my rebuilt lighting. It uses Beckmann's model of specularity, which is slightly different than the GGX approach UE4 uses.
Beckmann Specular -
While the specular is a lot more focused and apparent with this, it does not have as much spread as UE4's which I was a little disappointed with. This definitely helps in the background, in terms of enhancing the wave's readability in the distance. So instead i attempted to implement UE4's specular model - GGX/Trowbridge-Reitz.
GGX/Trowbridge-Reitz Custom -
GGX/Trowbridge-Reitz Custom -
Here is my the shader with UE4's Lit translucency and GGX specular added.
Here are the different material functions for each. Let me know if you need anything clarified.
EDIT: GGX originally had some issues but is now MORE BETTER and updated graphs have been uploaded. Thanks for the help Eric!
EDIT: GGX originally had some issues but is now MORE BETTER and updated graphs have been uploaded. Thanks for the help Eric!