[iortcw] 117/152: All: Rend2: Clamp entity lighting to more resemble OpenGL1

Simon McVittie smcv at debian.org
Fri Sep 8 10:40:21 UTC 2017


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

smcv pushed a commit to annotated tag 1.5a
in repository iortcw.

commit 0da8efa7c722854759d60ac10b9504fe4b4db528
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Fri Sep 16 21:09:18 2016 -0400

    All: Rend2: Clamp entity lighting to more resemble OpenGL1
    
    Supplants previous commit for this issue.
    See https://github.com/MAN-AT-ARMS/iortcw-archive/commit/752ebecde733c8f0c1917d826197219f7a4d101e
---
 MP/code/rend2/tr_light.c | 37 +++++++++++++++++++++++++++++++------
 MP/code/rend2/tr_shade.c | 15 ---------------
 SP/code/rend2/tr_light.c | 37 +++++++++++++++++++++++++++++++------
 SP/code/rend2/tr_shade.c | 15 ---------------
 4 files changed, 62 insertions(+), 42 deletions(-)

diff --git a/MP/code/rend2/tr_light.c b/MP/code/rend2/tr_light.c
index b0ba83a..fc892c2 100644
--- a/MP/code/rend2/tr_light.c
+++ b/MP/code/rend2/tr_light.c
@@ -412,13 +412,38 @@ 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;
 		}
 	}
 
diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c
index e912a82..71807a8 100644
--- a/MP/code/rend2/tr_shade.c
+++ b/MP/code/rend2/tr_shade.c
@@ -1418,26 +1418,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
 		if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE)
 		{
 			vec4_t vec;
-			vec_t cap = 1.0f / (1 << tr.overbrightBits);
 
 			VectorScale(backEnd.currentEntity->ambientLight, 1.0f / 255.0f, vec);
-			if ((vec[0] > cap) || (vec[1] > cap) || (vec[2] > cap))
-			{
-				vec_t hi = MAX(vec[0], vec[1]);
-				hi = MAX(hi, vec[2]);
-				
-				VectorScale(vec, cap / hi, vec);
-			}
 			GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vec);
 
 			VectorScale(backEnd.currentEntity->directedLight, 1.0f / 255.0f, vec);
-			if ((vec[0] > cap) || (vec[1] > cap) || (vec[2] > cap))
-			{
-				vec_t hi = MAX(vec[0], vec[1]);
-				hi = MAX(hi, vec[2]);
-				
-				VectorScale(vec, cap / hi, vec);
-			}
 			GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, vec);
 			
 			VectorCopy(backEnd.currentEntity->lightDir, vec);
diff --git a/SP/code/rend2/tr_light.c b/SP/code/rend2/tr_light.c
index 9fd6a19..835762f 100644
--- a/SP/code/rend2/tr_light.c
+++ b/SP/code/rend2/tr_light.c
@@ -413,13 +413,38 @@ 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;
 		}
 	}
 
diff --git a/SP/code/rend2/tr_shade.c b/SP/code/rend2/tr_shade.c
index 10c28da..8253f8b 100644
--- a/SP/code/rend2/tr_shade.c
+++ b/SP/code/rend2/tr_shade.c
@@ -1413,26 +1413,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
 		if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE)
 		{
 			vec4_t vec;
-			vec_t cap = 1.0f / (1 << tr.overbrightBits);
 
 			VectorScale(backEnd.currentEntity->ambientLight, 1.0f / 255.0f, vec);
-			if ((vec[0] > cap) || (vec[1] > cap) || (vec[2] > cap))
-			{
-				vec_t hi = MAX(vec[0], vec[1]);
-				hi = MAX(hi, vec[2]);
-				
-				VectorScale(vec, cap / hi, vec);
-			}
 			GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vec);
 
 			VectorScale(backEnd.currentEntity->directedLight, 1.0f / 255.0f, vec);
-			if ((vec[0] > cap) || (vec[1] > cap) || (vec[2] > cap))
-			{
-				vec_t hi = MAX(vec[0], vec[1]);
-				hi = MAX(hi, vec[2]);
-				
-				VectorScale(vec, cap / hi, vec);
-			}
 			GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, vec);
 			
 			VectorCopy(backEnd.currentEntity->lightDir, vec);

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



More information about the Pkg-games-commits mailing list