This is a UE5 version of my shading model for UE4 that I built for my military academy dating simulator/military warfare tactical rpg/tank washing simulator.
A fair amount of stuff has changed since the previous thread, including the first number in the engine version it’s for so may as well make a new thread to contain that information.
In summary, this shading model allows you to specify exactly what unreal displays in shadow and lit areas. This doesnt have to follow any sort of realistic lighting logic, you can create materials that are brighter in shadow than where they are actually lit. Whatever you put in the shadow colour pin is what is displayed in shadow.
Here is Nicholas Cage to demonstrate.
and some basic spheres
Here’s how it works.
Material and Lighting Setup
This Shading Model hijacks the Clear Coat Shading Model.
Most of this works the same as stock Unreal.
Base Colour works the same as stock Unreal, however I do not use the colour of light actors on the shading side. So if you have a surface and you want to apply a light colour to it you need to multiply that onto the base colour on the material side. I might change this back later but I’m working on some effect ideas that require this kind of setup. It’s also a nonissue unless you want to use more than just a single directional light which isn’t a purpose this shading model is really geared towards.
Metallic is shadow range, this defines how hard your shadow is. 1 is soft, 0 is hard.
Custom Data 0 is Shadow Colour. This is what renders when a surface is in shadow.
Custom Data 1 isn’t used for anything but it is exposed and will write a single channel to the gbuffer so it can be used to provide information to a post process material.
Lighting is accomplished through a single directional light. Additional point, spot, and area lights are supported.
You can adjust a light’s contribution in areas it shadows by adjusting the Specular Scale property per light.
Installation
You can find my repository here: https://github.com/envieous/UnrealEngine-SelShader
Before you ask why you got a 404 after clicking that link, read this: Unreal Engine 4 on GitHub - Unreal Engine
For 5.3(Launcher branch) and onwards
Download my repository, and overwrite Engine/Shaders/Private in your LAUNCHER engine installation folder with the Engine/Shaders/Private folder from MY REPOSITORY.
For 5.3 (Source branch) and previous
Setup
These changes aren’t explicitly required, but if you’re trying to achieve a look similar to mine this is how I’m doing it.
Disable Static Lighting
Disable exposure adjustment here.
You’ll also likely want to look at your other post process settings, bloom and vignette in particular and pick values you like.
The tonemapper in Unreal is notorious for washing out/desaturating/and just generally ruining your colours in the name of physical accuracy. I have disabled the tonemapper and Unreal now outputs colours very close to what is inputted.
If for some reason you actually want Unreal to tOnEmAp your colours you can undo this change by changing this line in PostProcessTonemap.usf
half3 OutDeviceColor = LinearColor.rgb;
back to
half3 OutDeviceColor = ColorLookupTable(LinearColor);
Unreal also tonemaps UMG elements. I have no idea why ANYONE would desire this behavior, and unfortunately I can not remove this functionality without severely compromising the usability of the editor as it affects the ENTIRE editor UI as well.
For now the best way I’ve found to correct this is to create this material function to correct UMG colours.
This isn’t an ideal way of doing this and will probably cause problems, but it’s good enough for development, and can be removed at the end while also removing UMG tonemaping for the final build to achieve correct results.
To remove UMG tonemapping open SlateElementPixelShader.usf and comment out the lines:
OutColor = ApplyContrast(OutColor);
OutColor.rgb = GammaCorrect(OutColor.rgb);
Misc
I should probably mention Lumen. I’ve played with it a bit but it doesn’t seem feasible from a both a performance and art standpoint to utilize it in my project so if you want to use it I can’t really offer any suggestions or help, but if you make something cool with it in this shading model I’m very interested to see what people come up with.
Example Project(s)
This project has all the settings setup and contains further example content. There’s two folders in the archive, use launcher example for launcher version, source for source.
Download here.
Acknowledgements
Tom Looman for his Dr Facilier shadow demonstration that I used initially as the basis for my shading system.
Doomfest and Arnage , for their custom shading models. I studied a lot of their changes to figure out what was going on in Unreal’s USF files.
FelixK and Matt Hoffman for their articles on creating a custom shading model in Unreal. These articles despite being dated were still incredibly helpful for figuring all this out.
I’m pretty sure that covers everything. Enjoy.
You can find my Twitter here, and my Discord here.
Also if you’re interested or want to support this project, you can wishlist my game on Steam, each wishlist helps <3
Also consider leaving a post and vote here in the off chance of getting Epic to make custom shading models not require wasting hours of everyone’s time building the engine from source just to enable a couple material pins.
Finally, if you want to directly support further development of this shading model, you can do so on Patreon here: