PBRPointLight.glsl 1.1 KB

123456789101112131415161718192021222324252627
  1. //! Function computes contribution of isotropic point light source
  2. //! into global variable DirectLighting (PBR shading).
  3. //! @param theId light source index
  4. //! @param theNormal surface normal
  5. //! @param theView view direction
  6. //! @param thePoint 3D position (world space)
  7. //! @param theIsFront front/back face flag
  8. void occPointLight (in int theId,
  9. in vec3 theNormal,
  10. in vec3 theView,
  11. in vec3 thePoint,
  12. in bool theIsFront)
  13. {
  14. vec3 aLight = occLight_Position (theId) - thePoint;
  15. float aDist = length (aLight);
  16. float aRange = occLight_Range (theId);
  17. float anAtten = occPointLightAttenuation (aDist, aRange);
  18. if (anAtten <= 0.0) return;
  19. aLight /= aDist;
  20. theNormal = theIsFront ? theNormal : -theNormal;
  21. DirectLighting += occPBRIllumination (theView, aLight, theNormal,
  22. BaseColor, Metallic, Roughness, IOR,
  23. occLight_Specular (theId),
  24. occLight_Intensity(theId) * anAtten);
  25. }