Fog.glsl 621 B

123456789101112131415161718192021222324
  1. #ifdef COMPILEPS
  2. vec3 GetFog(vec3 color, float fogFactor)
  3. {
  4. return mix(cFogColor, color, fogFactor);
  5. }
  6. vec3 GetLitFog(vec3 color, float fogFactor)
  7. {
  8. return color * fogFactor;
  9. }
  10. float GetFogFactor(float depth)
  11. {
  12. return clamp((cFogParams.x - depth) * cFogParams.y, 0.0, 1.0);
  13. }
  14. float GetHeightFogFactor(float depth, float height)
  15. {
  16. float fogFactor = GetFogFactor(depth);
  17. float heightFogFactor = (height - cFogParams.z) * cFogParams.w;
  18. heightFogFactor = 1.0 - clamp(exp(-(heightFogFactor * heightFogFactor)), 0.0, 1.0);
  19. return min(heightFogFactor, fogFactor);
  20. }
  21. #endif