EllipsoidSurfaceAppearanceFS.glsl 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. in vec3 v_positionMC;
  2. in vec3 v_positionEC;
  3. in vec2 v_st;
  4. void main()
  5. {
  6. czm_materialInput materialInput;
  7. vec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)));
  8. #ifdef FACE_FORWARD
  9. normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
  10. #endif
  11. materialInput.s = v_st.s;
  12. materialInput.st = v_st;
  13. materialInput.str = vec3(v_st, 0.0);
  14. // Convert tangent space material normal to eye space
  15. materialInput.normalEC = normalEC;
  16. materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, materialInput.normalEC);
  17. // Convert view vector to world space
  18. vec3 positionToEyeEC = -v_positionEC;
  19. materialInput.positionToEyeEC = positionToEyeEC;
  20. czm_material material = czm_getMaterial(materialInput);
  21. #ifdef FLAT
  22. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  23. #else
  24. out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
  25. #endif
  26. }