From e7474eb48d3f5627a781cc25c96d721aa08b9629 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 27 Jul 2011 00:25:45 -0500
Subject: [PATCH] SH-2120 Better fix for water being very dark when basic
 shaders disabled (sinA might be negative)

---
 indra/newview/llvosky.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 3a94b03a84d..ef21e7373e4 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -754,7 +754,12 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo
 {
 	// project the direction ray onto the sky dome.
 	F32 phi = acos(Pn[1]);
-	F32 sinA = llmax(sin(F_PI - phi), 0.01f);
+	F32 sinA = sin(F_PI - phi);
+	if (fabsf(sinA) < 0.01f)
+	{ //avoid division by zero
+		sinA = 0.01f;
+	}
+
 	F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA;
 
 	Pn *= Plen;
-- 
GitLab