harmonicsFunctions.fx 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #ifdef USESPHERICALFROMREFLECTIONMAP
  2. uniform vec3 vSphericalX;
  3. uniform vec3 vSphericalY;
  4. uniform vec3 vSphericalZ;
  5. uniform vec3 vSphericalXX;
  6. uniform vec3 vSphericalYY;
  7. uniform vec3 vSphericalZZ;
  8. uniform vec3 vSphericalXY;
  9. uniform vec3 vSphericalYZ;
  10. uniform vec3 vSphericalZX;
  11. vec3 EnvironmentIrradiance(vec3 normal)
  12. {
  13. // Note: 'normal' is assumed to be normalised (or near normalised)
  14. // This isn't as critical as it is with other calculations (e.g. specular highlight), but the result will be incorrect nonetheless.
  15. // TODO: switch to optimal implementation
  16. vec3 result =
  17. vSphericalX * normal.x +
  18. vSphericalY * normal.y +
  19. vSphericalZ * normal.z +
  20. vSphericalXX * normal.x * normal.x +
  21. vSphericalYY * normal.y * normal.y +
  22. vSphericalZZ * normal.z * normal.z +
  23. vSphericalYZ * normal.y * normal.z +
  24. vSphericalZX * normal.z * normal.x +
  25. vSphericalXY * normal.x * normal.y;
  26. return result.rgb;
  27. }
  28. #endif