1
0
forked from Rowland/EG
EG/Cesium-1.132/packages/engine/Source/Shaders/Builtin/Functions/approximateTanh.glsl
2025-08-25 17:48:13 +08:00

11 lines
276 B
GLSL

/**
* Compute a rational approximation to tanh(x)
*
* @param {float} x A real number input
* @returns {float} An approximation for tanh(x)
*/
float czm_approximateTanh(float x) {
float x2 = x * x;
return max(-1.0, min(1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
}