I am currently experiencing a very obvious artifact that occurs when looking at objects on very grazing angles
Here is a picture of the artifact:
I noticed that the issue was coming from my implementation of Cook-Torrance's Specular BRDF.
Here is the equation for the Cook-Torrance Specular BRDF:
More specifically, calculating the denominator is causing the issue:
float denominator = 4 * max(dot(viewDir, normal), 0.0) * max(dot(lightDir, normal), 0.0) + 0.001; // Prevents any division by zero
When I change the calculation of dot(viewDir, normal) to dot(halfway, normal), the artifact disappears:
float denominator = 4 * max(dot(halfway, normal), 0.0) * max(dot(lightDir, normal), 0.0) + 0.001; // Prevents any division by zero
But this equation is no longer correct. I was wondering if anyone knows why my implementation causes these artifacts?
If you want to see my fragment shader you can find the code here:
Thank you!
normalize(normal * 2.0f - 1.0f)
) to the same vector you used to create the TBN matrix $\endgroup$pow()
function. $\endgroup$