[ioquake3] 46/59: OpenGL2: Clamp entity lighting to more resemble OpenGL1.

Simon McVittie smcv at debian.org
Wed Sep 21 19:57:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository ioquake3.

commit 8417c184b42bd2d97f57b428b56c3c039531853b
Author: SmileTheory <SmileTheory at gmail.com>
Date:   Wed Sep 14 04:19:46 2016 -0700

    OpenGL2: Clamp entity lighting to more resemble OpenGL1.
---
 code/renderergl2/tr_light.c | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/code/renderergl2/tr_light.c b/code/renderergl2/tr_light.c
index a335eb6..1bf1eb7 100644
--- a/code/renderergl2/tr_light.c
+++ b/code/renderergl2/tr_light.c
@@ -385,16 +385,42 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) {
 		VectorMA( lightDir, d, dir, lightDir );
 	}
 
-	// clamp ambient
-	if ( !r_hdr->integer )
+	// clamp lights
+	// FIXME: old renderer clamps (ambient + NL * directed) per vertex
+	//        check if that's worth implementing
 	{
-		for ( i = 0 ; i < 3 ; i++ ) {
-			if ( ent->ambientLight[i] > tr.identityLightByte ) {
-				ent->ambientLight[i] = tr.identityLightByte;
-			}
+		float r, g, b, max;
+
+		r = ent->ambientLight[0];
+		g = ent->ambientLight[1];
+		b = ent->ambientLight[2];
+
+		max = MAX(MAX(r, g), b);
+
+		if (max > 255.0f)
+		{
+			max = 255.0f / max;
+			ent->ambientLight[0] *= max;
+			ent->ambientLight[1] *= max;
+			ent->ambientLight[2] *= max;
+		}
+
+		r = ent->directedLight[0];
+		g = ent->directedLight[1];
+		b = ent->directedLight[2];
+
+		max = MAX(MAX(r, g), b);
+
+		if (max > 255.0f)
+		{
+			max = 255.0f / max;
+			ent->directedLight[0] *= max;
+			ent->directedLight[1] *= max;
+			ent->directedLight[2] *= max;
 		}
 	}
 
+
 	if ( r_debugLight->integer ) {
 		LogLight( ent );
 	}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git



More information about the Pkg-games-commits mailing list