Exposing the BRDF Models to the Material Editor?

has anything changed in terms of adding a new model?
would like to add a new specular model. make it lengthier in (4.8 or 4.9)

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?

I would really like to implement Oren-Nayar diffuse in my game. I have a lot of rough surfaces underwater (Sand, grass, rocks, coral, aquatic animals) that really benefit from the softness of Oren-Nayar diffuse.

Sadly, I couldn’t find the Oren-Nayer model in these shader files. However, some research online lead me to this:

I plugged that code into a post process material using the G-buffer roughness, and presto! Instant Oren-Nayar substitute. It doesn’t look great on surfaces with sharp roughness <0.3, and since this is a post process it doesn’t handle translucency all too well (and particles can change brightness as they pass different roughness objects on the screen). But for my purposes it worked beautifully. Epic should make an official Oren-Nayer shading option later on for projects that are using simple, rough shaders and could benefit greatly from it.

You can change shading model in:
ShadingModels.usf(62)
Just comment Lambert and uncomment OrenNayar.
In BRDF.usf there is also Gotanda Diffuse, but I don’t know this one.

hi with the 4.17 preview we can create shaders within plugins so if you can update the tutorial it would be nice !