From 39f761e1715220e35b731e8ec5d5f847b1abef80 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 26 Jul 2021 11:20:01 +0100 Subject: [PATCH] Terrain wetness: reimstate clamping term Re-add this clamping of the terrain wetness value, to avoid out of bounds values in shaders appearing as black. Thanks to Colin Geniet for the testing and fix. SF-Id: https://sourceforge.net/p/flightgear/codetickets/2604/ --- src/Environment/climate.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Environment/climate.cxx b/src/Environment/climate.cxx index ac8586495..e83d8b897 100644 --- a/src/Environment/climate.cxx +++ b/src/Environment/climate.cxx @@ -882,6 +882,9 @@ void FGClimate::set_environment() { // https://weatherins.com/rain-guidelines/ _wetness = 12.0*std::max(_gl.precipitation-50.0, 0.0)/990.0; + + // clamping term, see https://sourceforge.net/p/flightgear/codetickets/2604/ + _wetness = pow(sin(atan(SGD_PI*_wetness)), 2.0); } else { _wetness = 0.0; }