- stupid hack to do leifx texture shaders

- some less waterimage stuff
This commit is contained in:
leilei-
2014-12-18 05:22:04 -05:00
parent 1609c8732a
commit 05433b5c7e
3 changed files with 57 additions and 14 deletions

View File

@@ -199,6 +199,7 @@ cvar_t *r_flaresDlightScale;
cvar_t *r_alternateBrightness; // leilei - linux overbright fix
cvar_t *r_mockvr; // Leilei - for debugging PVR only!
cvar_t *r_leifx; // Leilei - leifx nostalgia filter
cvar_t *r_vertshader; // Leilei
cvar_t *r_ntsc; // Leilei - ntsc / composite signals
//cvar_t *r_tvMode; // Leilei - tv fake mode
@@ -1276,6 +1277,7 @@ void R_Register( void )
r_mockvr = ri.Cvar_Get( "r_mockvr", "0" , CVAR_ARCHIVE | CVAR_CHEAT);
r_leifx = ri.Cvar_Get( "r_leifx", "0" , CVAR_ARCHIVE | CVAR_LATCH);
r_vertshader = ri.Cvar_Get( "r_vertshader", "0" , CVAR_ARCHIVE | CVAR_LATCH);
r_ntsc = ri.Cvar_Get( "r_ntsc", "0" , CVAR_ARCHIVE | CVAR_LATCH);

View File

@@ -844,6 +844,10 @@ static void RB_FogPass( void ) {
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
}
// leilei - hmm., will integrate additive fog in the future
//
// GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE );
R_DrawElements( tess.numIndexes, tess.indexes );
}
@@ -1526,8 +1530,10 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
//
// do multitexture
//
if ( pStage->bundle[1].image[0] != 0 )
{
if (!r_leifx->integer)
DrawMultitextured( input, stage );
}
else

View File

@@ -37,6 +37,8 @@ static shader_t* hashTable[FILE_HASH_SIZE];
#define MAX_SHADERTEXT_HASH 2048
static char **shaderTextHashTable[MAX_SHADERTEXT_HASH];
extern cvar_t *r_mockvr;
/*
================
return a hash value for the filename
@@ -1044,6 +1046,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
char programFragmentObjects[MAX_PROGRAM_OBJECTS][MAX_QPATH];
int numVertexObjects = 0;
int numFragmentObjects = 0;
int leifxmode = 0; // for picking different dither tanles for blended stuff
int depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0;
qboolean depthMaskExplicit = qfalse;
@@ -1053,6 +1056,10 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
while ( 1 )
{
token = COM_ParseExt( text, qtrue );
if ( !token[0] )
{
@@ -1201,14 +1208,6 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
stage->bundle[0].image[0] = tr.whiteImage;
continue;
}
if ( !Q_stricmp( token, "$waterimage" ) )
{
stage->bundle[0].image[0] = tr.waterImage;
imgType_t type = IMGTYPE_COLORALPHA;
imgFlags_t flags = IMGFLAG_NONE;
continue;
}
else if ( !Q_stricmp( token, "$lightmap" ) )
{
stage->bundle[0].isLightmap = qtrue;
@@ -1360,11 +1359,6 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
stage->bundle[4].image[0] = tr.whiteImage;
continue;
}
if ( !Q_stricmp( token, "$waterimage" ) )
{
stage->bundle[4].image[0] = tr.waterImage;
continue;
}
else if ( !Q_stricmp( token, "$lightmap" ) )
{
stage->bundle[4].isLightmap = qtrue;
@@ -2499,12 +2493,15 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
if ( !Q_stricmp( token, "add" ) ) {
blendSrcBits = GLS_SRCBLEND_ONE;
blendDstBits = GLS_DSTBLEND_ONE;
leifxmode = 1; // 2x2
} else if ( !Q_stricmp( token, "filter" ) ) {
blendSrcBits = GLS_SRCBLEND_DST_COLOR;
blendDstBits = GLS_DSTBLEND_ZERO;
leifxmode = 1; // 2x2
} else if ( !Q_stricmp( token, "blend" ) ) {
blendSrcBits = GLS_SRCBLEND_SRC_ALPHA;
blendDstBits = GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;
leifxmode = 1; // 4x4
} else {
// complex double blends
blendSrcBits = NameToSrcBlendMode( token );
@@ -2516,6 +2513,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
continue;
}
blendDstBits = NameToDstBlendMode( token );
leifxmode = 1; // 2x2
}
// clear depth mask for blended surfaces
@@ -2523,6 +2521,8 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
{
depthMaskBits = 0;
}
}
//
// rgbGen
@@ -2783,11 +2783,17 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
continue;
}
else
{
ri.Printf( PRINT_WARNING, "WARNING: unknown parameter '%s' in shader '%s'\n", token, shader.name );
return qfalse;
}
// END DITHER TEST
}
//
@@ -2803,7 +2809,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
}
}
//
// implicitly assume that a GL_ONE GL_ZERO blend mask disables blending
//
@@ -2832,6 +2838,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
atestBits |
depthFuncBits;
return qtrue;
}
@@ -3419,6 +3426,7 @@ otherwise set to the generic stage function
*/
static void ComputeStageIteratorFunc( void )
{
if (vertexShaders)
shader.optimalStageIteratorFunc = RB_GLSL_StageIteratorGeneric;
else
@@ -3433,11 +3441,17 @@ static void ComputeStageIteratorFunc( void )
return;
}
if ( r_ignoreFastPath->integer )
{
return;
}
if (r_leifx->integer) // try not to use the multitexture shaders so we can blend
return; // lightmaps with a different dithering table
//
// see if this can go into the vertex lit fast path
//
@@ -3471,6 +3485,7 @@ static void ComputeStageIteratorFunc( void )
//
// see if this can go into an optimized LM, multitextured path
//
if ( shader.numUnfoggedPasses == 1 )
{
if ( ( stages[0].rgbGen == CGEN_IDENTITY ) && ( stages[0].alphaGen == AGEN_IDENTITY ) )
@@ -3552,6 +3567,9 @@ static qboolean CollapseMultitexture( void ) {
return qfalse;
}
if (r_leifx->integer > 1)
return qfalse; // don't do this for leifx mode
// make sure both stages are active
if ( !stages[0].active || !stages[1].active ) {
return qfalse;
@@ -4003,6 +4021,20 @@ static shader_t *FinishShader( void ) {
// vertexLightmap = qtrue;
//}
// Try to use leifx dither here instead of postprocess for more authentic overdraw artifacts
if (r_leifx->integer > 1)
{
pStage->program = RE_GLSL_RegisterProgram("leifxify", "glsl/leifxify_vp.glsl", 1, "glsl/leifxify_fp.glsl", 1);
pStage->isGLSL=1;
}
// Mockvr faking of the filtering and alpha precision of PCX2 cards
if ((r_mockvr->integer > 1))
{
pStage->program = RE_GLSL_RegisterProgram("leivrify", "glsl/leivrify_vp.glsl", 1, "glsl/leivrify_fp.glsl", 1);
pStage->isGLSL=1;
}
//
@@ -4069,10 +4101,12 @@ static shader_t *FinishShader( void ) {
//
// look for multitexture potential
//
if (!r_leifx->integer)
if ( stage > 1 && CollapseMultitexture() ) {
stage--;
}
if ( shader.lightmapIndex >= 0 && !hasLightmapStage ) {
if (vertexLightmap) {
ri.Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has VERTEX forced lightmap!\n", shader.name );
@@ -4083,6 +4117,7 @@ static shader_t *FinishShader( void ) {
}
//
// compute number of passes
//