So I have recently been trying to add my own shading model and think I have found the right things to change. Here’s the stuff I have changed based on the stuff from . It seems LIGHTINGMODEL… has changed over to SHADINGMODEL… I have done this in 4.8 as of now:
DeferredShadingCommon.usf
4.8 Line 226
#define SHADINGMODELID_TWOSIDED_FOLIAGE 6
#define SHADINGMODELID_MYSHADER 7
#define SHADINGMODELID_NUM 8
I didn’t change the encoding and decoding as looking at it, I assumed it would work with additional ID’s added? I may be wrong on this so please let me know.
====================================================================================================================================
Engine\Source\Runtime\Engine\Classes\Engine\EngineTypes.h
4.8 [Line 197]
Engine side definition of the Material Lighting Model. This allows it to be selectable in the Material Editor
MSM_TwoSidedFoliage UMETA(DisplayName="Two Sided Foliage"),
MSM_MyShader UMETA(DisplayName = "My Shader"),
MSM_MAX,
====================================================================================================================================
Engine\Source\Runtime\Engine\Private\Materials\MaterialShared.cpp
4.8 [Line 1221]
Ensure that the shader compiler sets our new custom lighting model if selected
case MSM_TwoSidedFoliage: OutEnvironment.SetDefine(TEXT("MATERIAL_SHADINGMODEL_TWOSIDED_FOLIAGE"), TEXT("1")); break;
case MSM_MyShader: OutEnvironment.SetDefine(TEXT("MATERIAL_SHADINGMODEL_MYSHADER"), TEXT("1")); break;
default:
====================================================================================================================================
BasePassPixelShader.usf
4.8 [Line 845]
Set the Lighting Model ID based on the Material Lighting Model selected
#elif MATERIAL_SHADINGMODEL_CLEAR_COAT
GBuffer.ShadingModelID = SHADINGMODELID_CLEAR_COAT;
#elif MATERIAL_SHADINGMODEL_MYSHADER
GBuffer.ShadingModelID = SHADINGMODELID_MYSHADER;
====================================================================================================================================
The problem I am having now is where the best place is to setup my new shader code. Any changes I am making in DefereedLightingCommong are causing a lot of unneeded shader compilations when running again. Preferably, I would like to take the BRDF functionality, put it in a separate .usf can have it use that file whenever my ID is set to my own shader. Is this possible at all with the current set up?