multiplyWithColorBalance.glsl 491 B

123456789101112131415161718
  1. /**
  2. * DOC_TBA
  3. *
  4. * @name czm_multiplyWithColorBalance
  5. * @glslFunction
  6. */
  7. vec3 czm_multiplyWithColorBalance(vec3 left, vec3 right)
  8. {
  9. // Algorithm from Chapter 10 of Graphics Shaders.
  10. const vec3 W = vec3(0.2125, 0.7154, 0.0721);
  11. vec3 target = left * right;
  12. float leftLuminance = dot(left, W);
  13. float rightLuminance = dot(right, W);
  14. float targetLuminance = dot(target, W);
  15. return ((leftLuminance + rightLuminance) / (2.0 * targetLuminance)) * target;
  16. }