A shading model test bed

When developing a custom shading model, every compilation seems to be forever.
Using the shading model developed by external software, you also need to debug when you want to migrate to UE4.
Also, need to compile (forever).
So I developed a little trick: shading model testbed.
Looks like this

If you remove other effects, it looks like this

exactly the same.
I used some scene textures and used them in the material as input to the shading model function.

If you want, the example file is here. (UE4.19)

I know something cool is up but not sure what and where to notice? :stuck_out_tongue: Some more explanation please?

Overall, this is a technique designed only for developers of custom shading models.
When I developed the shading model, I often encountered this situation:
You made a small change to the line of code in ShadingModels.ush, then you return to the engine, press Ctrl + Shift +. , and then wait for 7000+ shaders to compile.
After you have had a few cups of tea, the shader is compiled. You find that the effect is still somewhat unsatisfactory, so you change the line of the code back, and then guess what, wait for another 7000+ shaders to compile!:frowning:

So I developed this trick, find the shading code from the engine source code, put it into a custom node of the material editor, and then use the scene texture already in the material editor as its input. Basically, the shading of the engine is reimplemented in the material editor.

As can be seen from the comparison, after removing the fog, skylight, reflection, AO, there is no visible difference between the default shading of the engine and the material I wrote.
At the same time, in terms of compile speed, modifying the code in the custom node is much faster than directly changing the code in the source code: from a few cups of tea to a few seconds:cool:.

Thank you! :slight_smile: Very cool, I came from cell-shading model thread BTW.

So with this we can implement that cell-shading model without, custom build from Git-hub?!!

I really like the Cell-shading in that thread, but yeah waiting for someone to update the new version and then compiling is a drag.

You can compile just certain shaders you want. Some things i picked up while learning to make custom shading models:
ShadingModelsMaterials.ush - You just need to make a change in material graph hit apply and the changes will propagate.
The command below will allow you to compile specific shaders:

recompileshaders /Engine/Private/X

where X is the shader file
DeferredLightPixelShaders.usf - This compiles a bunch of shaders including ShadingModels.ush

I didn’t really know how to do this before, thank you very much.


You can put a shell that is slightly larger than the original object like the chair on the left side of the figure, and then you give the shell a Toon shading material.
Obviously, this has a lot of limitations.