I tried, but I don’t see any difference. I deleted Saved, Intermediate, DerivedDataCache and %LOCALAPPDATA%\UnrealEngine\Common\DerivedDataCache\ folders. When I open my project Unreal recompiles global shaders. I did some tests by adding errors, to see if the shaders compilation fails and it does. So I am sure my changes get compiled. I also tried setting Lighting.Diffuse *= 0 to produce some clearly visible results, but everything still looks the same. I have a simple scene with a sphere mesh and a point light.
Here’s how I changed DefaultLitBxDF in ShadingModels.ush (UE 5.6):
FDirectLighting DefaultLitBxDF( FGBufferData GBuffer, half3 N, half3 V, half3 L, float Falloff, half NoL, FAreaLight AreaLight, FShadowTerms Shadow )
{
BxDFContext Context;
FDirectLighting Lighting;
Lighting.Diffuse = 0;
Lighting.Specular = 0;
Lighting.Transmission = 0;
#if FEATURE_LEVEL == FEATURE_LEVEL_ES3_1
// adjust N for Adreno shader compilation bug. See UE-274816
N = N * 0.5f;
N = normalize(N);
#endif
BRANCH
if (NoL > 0.0f)
{
#if SUPPORTS_ANISOTROPIC_MATERIALS
bool bHasAnisotropy = HasAnisotropy(GBuffer.SelectiveOutputMask);
#else
bool bHasAnisotropy = false;
#endif
float NoV, VoH, NoH;
BRANCH
if (bHasAnisotropy)
{
half3 X = GBuffer.WorldTangent;
half3 Y = normalize(cross(N, X));
Init(Context, N, X, Y, V, L);
NoV = Context.NoV;
VoH = Context.VoH;
NoH = Context.NoH;
}
else
{
#if SHADING_PATH_MOBILE
InitMobile(Context, N, V, L, NoL);
#else
Init(Context, N, V, L);
#endif
NoV = Context.NoV;
VoH = Context.VoH;
NoH = Context.NoH;
SphereMaxNoH(Context, AreaLight.SphereSinAlpha, true);
}
Context.NoV = saturate(abs(Context.NoV) + 1e-5);
// --- Oren–Nayar diffuse ---
// Uses DiffuseColor, Roughness, NoV, NoL, VoH.
Lighting.Diffuse = Diffuse_OrenNayar(
GBuffer.DiffuseColor,
GBuffer.Roughness, // pass unsquared roughness; function handles it internally
NoV,
NoL,
VoH
);
Lighting.Diffuse *= AreaLight.FalloffColor * (Falloff * NoL);
//this_will_fail();
BRANCH
if (bHasAnisotropy)
{
Lighting.Specular = AreaLight.FalloffColor * (Falloff * NoL) * SpecularGGX(GBuffer.Roughness, GBuffer.Anisotropy, GBuffer.SpecularColor, Context, NoL, AreaLight);
}
else
{
if (IsRectLight(AreaLight))
{
Lighting.Specular = RectGGXApproxLTC(GBuffer.Roughness, GBuffer.SpecularColor, N, V, AreaLight.Rect, AreaLight.Texture);
}
else
{
Lighting.Specular = AreaLight.FalloffColor * (Falloff * NoL) * SpecularGGX(GBuffer.Roughness, GBuffer.SpecularColor, Context, NoL, AreaLight);
}
}
FBxDFEnergyTerms EnergyTerms = ComputeGGXSpecEnergyTerms(GBuffer.Roughness, Context.NoV, GBuffer.SpecularColor);
// Diffuse attenuation by specular layer (energy preservation)
Lighting.Diffuse *= ComputeEnergyPreservation(EnergyTerms);
// Specular multiple scattering term (energy conservation)
Lighting.Specular *= ComputeEnergyConservation(EnergyTerms);
Lighting.Transmission = 0;
}
return Lighting;
}