|
|
|
|
|
|
// Ambient occlusion is cosine weighted, thus use following equation. See slide 129 |
|
|
|
float cosAv = sqrt(1.0 - surfaceData.ambientOcclusion); |
|
|
|
float roughness = max(PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness), 0.01); // Clamp to 0.01 to avoid edge cases |
|
|
|
float cosAs = exp2(-3.32193 * Sq(roughness)); |
|
|
|
float cosAs = exp2((-log(10.0)/log(2.0)) * Sq(roughness)); |
|
|
|
float cosB = dot(bentNormalWS, reflect(-V, surfaceData.normalWS)); |
|
|
|
|
|
|
|
return SphericalCapIntersectionSolidArea(cosAv, cosAs, cosB) / (TWO_PI * (1.0 - cosAs)); |
|
|
|