2
0

opengl_fragment.glsl 370 B

1234567891011121314151617
  1. uniform lowp vec4 fogColor;
  2. uniform float fogDistance;
  3. uniform float fogShadingParameter;
  4. varying highp vec3 eyeVec;
  5. varying lowp vec4 varColor;
  6. void main(void)
  7. {
  8. vec4 col = varColor;
  9. float clarity = clamp(fogShadingParameter
  10. - fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
  11. col.rgb = mix(fogColor.rgb, col.rgb, clarity);
  12. gl_FragColor = col;
  13. }