PBRCookTorrance.glsl 873 B

1234567891011121314151617181920
  1. //! Calculates Cook-Torrance BRDF.
  2. vec3 occPBRCookTorrance (in vec3 theView,
  3. in vec3 theLight,
  4. in vec3 theNormal,
  5. in vec3 theBaseColor,
  6. in float theMetallic,
  7. in float theRoughness,
  8. in float theIOR)
  9. {
  10. vec3 aHalf = normalize (theView + theLight);
  11. float aCosV = max(dot(theView, theNormal), 0.0);
  12. float aCosL = max(dot(theLight, theNormal), 0.0);
  13. float aCosH = max(dot(aHalf, theNormal), 0.0);
  14. float aCosVH = max(dot(aHalf, theView), 0.0);
  15. vec3 aCookTorrance = occPBRDistribution (aCosH, theRoughness)
  16. * occPBRGeometry (aCosV, aCosL, theRoughness)
  17. * occPBRFresnel (theBaseColor, theMetallic, theIOR, aCosVH);
  18. aCookTorrance /= 4.0;
  19. return aCookTorrance;
  20. }