AllMaterialAppearanceFS.glsl 914 B

12345678910111213141516171819202122232425262728293031
  1. varying vec3 v_positionEC;
  2. varying vec3 v_normalEC;
  3. varying vec3 v_tangentEC;
  4. varying vec3 v_binormalEC;
  5. varying vec2 v_st;
  6. void main()
  7. {
  8. vec3 positionToEyeEC = -v_positionEC;
  9. mat3 tangentToEyeMatrix = czm_tangentToEyeSpaceMatrix(v_normalEC, v_tangentEC, v_binormalEC);
  10. vec3 normalEC;
  11. #ifdef FACE_FORWARD
  12. normalEC = normalize(faceforward(v_normalEC, vec3(0.0, 0.0, 1.0), -v_normalEC));
  13. #else
  14. normalEC = normalize(v_normalEC);
  15. #endif
  16. czm_materialInput materialInput;
  17. materialInput.normalEC = normalEC;
  18. materialInput.tangentToEyeMatrix = tangentToEyeMatrix;
  19. materialInput.positionToEyeEC = positionToEyeEC;
  20. materialInput.st = v_st;
  21. czm_material material = czm_getMaterial(materialInput);
  22. #ifdef FLAT
  23. gl_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  24. #else
  25. gl_FragColor = czm_phong(normalize(positionToEyeEC), material);
  26. #endif
  27. }