translucentPhong.glsl 926 B

123456789101112131415161718192021222324252627
  1. /**
  2. * @private
  3. */
  4. vec4 czm_translucentPhong(vec3 toEye, czm_material material, vec3 lightDirectionEC)
  5. {
  6. // Diffuse from directional light sources at eye (for top-down and horizon views)
  7. float diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal);
  8. if (czm_sceneMode == czm_sceneMode3D) {
  9. // (and horizon views in 3D)
  10. diffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal);
  11. }
  12. diffuse = clamp(diffuse, 0.0, 1.0);
  13. float specular = czm_getSpecular(lightDirectionEC, toEye, material.normal, material.shininess);
  14. // Temporary workaround for adding ambient.
  15. vec3 materialDiffuse = material.diffuse * 0.5;
  16. vec3 ambient = materialDiffuse;
  17. vec3 color = ambient + material.emission;
  18. color += materialDiffuse * diffuse * czm_lightColor;
  19. color += material.specular * specular * czm_lightColor;
  20. return vec4(color, material.alpha);
  21. }