DeferredShadingCommon.ush
GBuffer.DiffuseColor = GBuffer.BaseColor - GBuffer.BaseColor * GBuffer.Metallic;
GBuffer.SpecularColor = ComputeF0(GBuffer.Specular, GBuffer.BaseColor, GBuffer.Metallic);
ShadingCommon.ush
float DielectricSpecularToF0(float Specular)
{
return 0.08f * Specular;
}
// [Burley, "Extending the Disney BRDF to a BSDF with Integrated Subsurface Scattering"]
float DielectricF0ToIor(float F0)
{
return 2.0f / (1.0f - sqrt(F0)) - 1.0f;
}
float DielectricIorToF0(float Ior)
{
const float F0Sqrt = (Ior-1)/(Ior+1);
const float F0 = F0Sqrt*F0Sqrt;
return F0;
}
float3 ComputeF0(float Specular, float3 BaseColor, float Metallic)
{
return lerp(DielectricSpecularToF0(Specular).xxx, BaseColor, Metallic.xxx);
}