translucentPhong.glsl 1018 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * @private
  3. */
  4. vec4 czm_translucentPhong(vec3 toEye, czm_material material)
  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. // Specular from sun and pseudo-moon
  14. float specular = czm_getSpecular(czm_sunDirectionEC, toEye, material.normal, material.shininess);
  15. specular += czm_getSpecular(czm_moonDirectionEC, toEye, material.normal, material.shininess);
  16. // Temporary workaround for adding ambient.
  17. vec3 materialDiffuse = material.diffuse * 0.5;
  18. vec3 ambient = materialDiffuse;
  19. vec3 color = ambient + material.emission;
  20. color += materialDiffuse * diffuse;
  21. color += material.specular * specular;
  22. return vec4(color, material.alpha);
  23. }