EllipsoidSurfaceAppearanceFS.glsl 1.1 KB

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