Closed walbourn closed 1 year ago
Looking at the shader in more detail, it should end up contributing zero if the light is set to 0,0,0. If you don't call EnableDefaultLighting
, it ends up looking a lot more 'metal' than it should.
After reviewing the shader some more, I'm beginning to think it's not a bug after all. The 'specular radiance' is taken from the IBL and not based on the directional lights at all.
To be clear, if I change the LightSurface
function to this:
// Accumulate light values
for (int i = 0; i < numLights; i++)
{
if (step(dot(lightColor[i], lightColor[i]), EPSILON) > 0.f)
{
// light vector (to light)
const float3 L = normalize(-lightDirection[i]);
// Half vector
const float3 H = normalize(L + V);
// products
const float NdotL = saturate(dot(N, L));
const float LdotH = saturate(dot(L, H));
const float NdotH = saturate(dot(N, H));
// Diffuse & specular factors
float diffuse_factor = Diffuse_Burley(NdotL, NdotV, LdotH, roughness);
float3 specular = Specular_BRDF(alpha, c_spec, NdotV, NdotL, LdotH, NdotH);
// Directional light
acc_color += NdotL * lightColor[i] * (((c_diff * diffuse_factor) + specular));
}
}
It made no difference.
The current implementation of directional lights in the PBR effect mean that even when they are 'off' by default, they still add to the specular metalness factors.
The helper
LightSurface
in PBRCommon.fxh needs to properly ignore a light that has it's color set to 0,0,0.