SkyboxFShader.fsh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. uniform samplerCube CubeMap;
  2. #ifdef ENABLE_FOG_DEPTH
  3. uniform lowp vec3 FogColour;
  4. uniform mediump float RcpMaxFogDepth;
  5. #endif
  6. #ifdef ENABLE_DISCARD_CLIP
  7. uniform bool ClipPlaneBool;
  8. #endif
  9. varying mediump vec3 EyeDir;
  10. #ifdef ENABLE_FOG_DEPTH
  11. varying mediump float VertexDepth;
  12. #endif
  13. #ifdef ENABLE_DISCARD_CLIP
  14. varying highp float ClipDist;
  15. #endif
  16. void main()
  17. {
  18. #ifdef ENABLE_DISCARD_CLIP
  19. // Reject fragments behind the clip plane
  20. if(ClipDist < 0.0)
  21. {
  22. discard; // Too slow for hardware. Left as an example of how not to do this!
  23. }
  24. #endif
  25. #ifdef ENABLE_FOG_DEPTH
  26. // Mix the object's colour with the fogging colour based on fragment's depth
  27. lowp vec3 vFragColour = textureCube(CubeMap, EyeDir).rgb;
  28. // Test depth
  29. lowp float fFogBlend = clamp(VertexDepth * RcpMaxFogDepth, 0.0, 1.0);
  30. vFragColour.rgb = mix(vFragColour.rgb, FogColour.rgb, fFogBlend);
  31. gl_FragColor = vec4(vFragColour.rgb, 1.0);
  32. #else
  33. gl_FragColor = textureCube(CubeMap, EyeDir);
  34. #endif
  35. }