This patch refactors the implementation of the GGX microfacet BSDF.
On the one hand, it provides a small but measurable performance improvement due to the following changes:
- Using a reformulated version of the G1 term (credit for that one goes to @Erik Englesson (ErikEnglesson)).
- Not calculating tanTheta in the calculation of the isotropic distribution term D.
- Skipping some terms in the anisotropic D.
- Deduplicating some terms in the final BSDF refraction calculation.
- Not calculating the reflection direction and fresnel term in the refraction code since they're unused anyways.
On the other hand, it moves some of the shared terms to separate functions and adds more comments to the code, therefore improving overall readability.