Creating a Shading Model

Work in Progress

This page is a current topic of research, some things may not be accurate.

AuthorAlessa "Codekitten" Baker Page StatusWIP Unreal Version5.2

Getting Started

Implementing a custom shading model in Unreal Engine can be one of the most enjoyable and rewarding experiences, because it opens up so much more opportunity to experiment in custom rendering with minimal code changes. A lot of it comes down to just replicating an existing implementation of another shading model.

Here are the files we’ll modify today.

Files ModifiedDescription
EngineTypes.hHolds most enums available in the engine that aren’t mapped to any particular class.


At the time of this document being written, go ahead and git clone and then compile 5.2 branch of Unreal Engine. When you have a successful compile, we can get started by modifying our first file. If you are using an engine version ahead of this branch, I cannot guarantee you won’t have a little headache if any of these things change.

Adding our Shading Model

TODO: Adding to EngineTypes.h, and other files to inform Unreal that a new shading model exists.

Modifying the Material Editor

Enabling/Disabling Pins

TODO: MP_ and switch cases to add and modify pins

Custom Data

TODO: Describe Custom Data, and how it applies to our HLSL and is passed from the material editor as a compiled parameter.

Playing with some HLSL

TODO: Add our custom data output to Diffuse Color in Base Pass. As a quick example of passing the parameter around.

Additional Resources

[1] Shading Models Official Documentation
[2] New shading models and changing the GBuffer by One3y3
[3] Unreal Engine 4 Rendering Part 6: Adding a new Shading Model
[4] Implement Cel-Shading w/ Outline Using Custom Shading Model in UE4.22 (1)
[5] [UE4] Custom Shading Model
[6] Porting custom UE4 shading models to UE5 (or how to tackle the new GBuffer codegen)