TexturedMaterialAppearanceFS.glsl 672 B

12345678910111213141516171819202122232425
  1. in vec3 v_positionEC;
  2. in vec3 v_normalEC;
  3. in vec2 v_st;
  4. void main()
  5. {
  6. vec3 positionToEyeEC = -v_positionEC;
  7. vec3 normalEC = normalize(v_normalEC);
  8. #ifdef FACE_FORWARD
  9. normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
  10. #endif
  11. czm_materialInput materialInput;
  12. materialInput.normalEC = normalEC;
  13. materialInput.positionToEyeEC = positionToEyeEC;
  14. materialInput.st = v_st;
  15. czm_material material = czm_getMaterial(materialInput);
  16. #ifdef FLAT
  17. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  18. #else
  19. out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
  20. #endif
  21. }