[iortcw] 427/497: All: Rend2: Implement refEntity_t fadeStartTime and fadeEndTime

Simon McVittie smcv at debian.org
Fri Sep 8 10:37:41 UTC 2017


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

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 22ede07efed45e0b8afba364214a4883f4d89400
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Sat Nov 14 22:15:18 2015 -0500

    All: Rend2: Implement refEntity_t fadeStartTime and fadeEndTime
---
 MP/code/rend2/tr_shade.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++--
 SP/code/rend2/tr_shade.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 102 insertions(+), 4 deletions(-)

diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c
index 6aeb285..b5d6709 100644
--- a/MP/code/rend2/tr_shade.c
+++ b/MP/code/rend2/tr_shade.c
@@ -1387,14 +1387,63 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
 			GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT);
 		}
 
-		GL_State( pStage->stateBits );
-
 		{
 			vec4_t baseColor;
 			vec4_t vertColor;
+			int fadeStart, fadeEnd;
 
 			ComputeShaderColors(pStage, baseColor, vertColor, pStage->stateBits);
 
+			//----(SA)	fading model stuff
+			if ( backEnd.currentEntity )
+			{
+				fadeStart = backEnd.currentEntity->e.fadeStartTime;
+			}
+			else
+			{
+				fadeStart = 0;
+			}
+
+			if ( fadeStart )
+			{
+				fadeEnd = backEnd.currentEntity->e.fadeEndTime;
+
+				if ( fadeStart > tr.refdef.time )
+				{
+					// has not started to fade yet
+					GL_State( pStage->stateBits );
+				}
+				else
+				{
+					unsigned int tempState;
+					float alphaval;
+
+					if ( fadeEnd < tr.refdef.time )
+					{
+						// entity faded out completely
+						continue;
+					}
+
+					alphaval = (float)( fadeEnd - tr.refdef.time ) / (float)( fadeEnd - fadeStart );
+
+					tempState = pStage->stateBits;
+					// remove the current blend, and don't write to Z buffer
+					tempState &= ~( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS | GLS_DEPTHMASK_TRUE );
+					// set the blend to src_alpha, dst_one_minus_src_alpha
+					tempState |= ( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
+					GL_State( tempState );
+					GL_Cull( CT_FRONT_SIDED );
+					// modulate the alpha component of each vertex in the render list
+					baseColor[3] *= alphaval;
+					vertColor[3] *= alphaval;
+				}
+			}
+			else
+			{
+				GL_State( pStage->stateBits );
+			}
+			//----(SA)	end
+
 			if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL))
 			{
 				// use VectorScale to only scale first three values, not alpha
diff --git a/SP/code/rend2/tr_shade.c b/SP/code/rend2/tr_shade.c
index 21b8c07..8976b43 100644
--- a/SP/code/rend2/tr_shade.c
+++ b/SP/code/rend2/tr_shade.c
@@ -1381,14 +1381,63 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
 			GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT);
 		}
 
-		GL_State( pStage->stateBits );
-
 		{
 			vec4_t baseColor;
 			vec4_t vertColor;
+			int fadeStart, fadeEnd;
 
 			ComputeShaderColors(pStage, baseColor, vertColor, pStage->stateBits);
 
+			//----(SA)	fading model stuff
+			if ( backEnd.currentEntity )
+			{
+				fadeStart = backEnd.currentEntity->e.fadeStartTime;
+			}
+			else
+			{
+				fadeStart = 0;
+			}
+
+			if ( fadeStart )
+			{
+				fadeEnd = backEnd.currentEntity->e.fadeEndTime;
+
+				if ( fadeStart > tr.refdef.time )
+				{
+					// has not started to fade yet
+					GL_State( pStage->stateBits );
+				}
+				else
+				{
+					unsigned int tempState;
+					float alphaval;
+
+					if ( fadeEnd < tr.refdef.time )
+					{
+						// entity faded out completely
+						continue;
+					}
+
+					alphaval = (float)( fadeEnd - tr.refdef.time ) / (float)( fadeEnd - fadeStart );
+
+					tempState = pStage->stateBits;
+					// remove the current blend, and don't write to Z buffer
+					tempState &= ~( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS | GLS_DEPTHMASK_TRUE );
+					// set the blend to src_alpha, dst_one_minus_src_alpha
+					tempState |= ( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
+					GL_State( tempState );
+					GL_Cull( CT_FRONT_SIDED );
+					// modulate the alpha component of each vertex in the render list
+					baseColor[3] *= alphaval;
+					vertColor[3] *= alphaval;
+				}
+			}
+			else
+			{
+				GL_State( pStage->stateBits );
+			}
+			//----(SA)	end
+
 			if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL))
 			{
 				// use VectorScale to only scale first three values, not alpha

-- 
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