Custom Shading Model
Engine: My Forked Version (included in source)
My Role: Everything
Team Size: None
Source Code: Click Here
Description
Diving deep into Unreal's Source Code I forked the engine and created a cell shaded shading style. Using full PBR calculations, the cell shader can correctly calculate BRDFs for materials with varying roughness, metallic specular values.
In my Custom Pipeline Project I had created a very 'hacky' form of rendering that is not at all physically based. To combat this I challenged myself to learn all the concepts of PBR then manipulate them to make a stylized PBR shader. I researched and utilized how Epic achieve their PBR in the engine and how its a similar version to Brent Burley's PBR equation based off BRDFs. This interest became my university research project which led me to understand all the mathematics behind it. This was one of my implementations as a result and as seen in one of the screenshots, I ended up creating my own BRDF function that utilized my own PBR and Cell Shaded calculations. This was a big challenge since the mathamatics was complex but my am happy with the final result and hope to improve it even further for use in my later projects.
The source code above includes my forked engine and the project. The documentation instructions for opening a forked engine are needed to open the project otherwise it makes the download above too big if I include the binaries.
Project Technical Aspects
- Forked UE4 Version
- I forked version 4.21 which was required do achieve a custom shading model. I changed the the Unreal classes that manage the material editor UI in order to add my own option and then have that send to the global buffer in the GPU so the shader is aware that my shading model is selected. Since I needed custom data for my Cell Shader I also programmed a custom pin that is passed to the global buffer.
- Custom BRDF
- I changed many of the shaders built into the engine in order to add my own PBR calculations and add my own BRDF for the custom shading model. I made sure to keep my shading models compatible with all lights just like Unreal's default shaders. My version of the Deffered shader still fully supports all lights including area lights and even screen based lighting.
- Custom Light Attenuation
- By changing Unreal's Lighting calculations too I was able to use a custom attenuation on all lights when using my shading model. This ment I could stylize the graphics even more with this extra code and it doesn't effect the lighting on the other shading models since I used pre-compiler checks.