Here's a new smoothness curve function to try out that adds a Fresnel effect calculated from smoothness. Starting with line 241 in Metalness.fx:
// original function: fSmth = clamp(pow(abs(fSmth), gMtrl.roughness.y) * gMtrl.roughness.x, 0.0005f, 0.9999f);
fSmth = pow(abs(fSmth), gMtrl.roughness.y) * gMtrl.roughness.x;
fSmth = clamp( fSmth + ((1.0f - fSmth) * pow(abs(1.0f - dCN),4.0f)) * pow(abs(fSmth),0.5f), 0.01f, 0.999f);
The third line provides the Fresnel effect. abs(1.0f - dCN)
is raised to the 4th power because it gave a good-enough visual result. Fresnel is the most intense where dCN approaches zero, and not in a linear fashion.
This bit * pow(abs(fSmth),0.5f)
prevents the Fresnel effect for materials with 0 smoothness. 0.5 as exponent worked good enough.
Question: What is the purpose of clamp()
? Is it to avoid a divide-by-zero condition later on?