- r_roundImagesDown 2 - nonpowerof2 (NPOT) support. No extension checking added yet; use at your own risk! (intended for buffer effects)

- r_parseStageSimple - working towards pcx2 support by loading shader stages with the texture last, to approximate blending functions by processing them into having alpha channels (or not, for opaque surfaces). Because I can.
- leifx filter change - indicate number of passes to the shader, so the pixel blurring order can be tweaked to further perfection (ridding the left pixel check as that happens)
This commit is contained in:
leilei-
2015-04-03 05:53:02 -04:00
parent 3597b3cefa
commit 04870d3a20
9 changed files with 1211 additions and 102 deletions

View File

@@ -1419,6 +1419,6 @@ int vresHeight;
#define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) #define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) )
#define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) #define LUMA( red, green, blue ) ( 0.296875f * ( red ) + 0.5859375f * ( green ) + 0.109375f * ( blue ) )
#endif // __Q_SHARED_H #endif // __Q_SHARED_H

View File

@@ -475,47 +475,18 @@ static void GL_StatePCX( unsigned long stateBits )
unsigned long diff = stateBits ^ glState.glStateBits; unsigned long diff = stateBits ^ glState.glStateBits;
if ( !diff )
{
return;
}
// //
// check depthFunc bits
//
if ( diff & GLS_DEPTHFUNC_EQUAL )
{
if ( stateBits & GLS_DEPTHFUNC_EQUAL )
{
qglDepthFunc( GL_EQUAL );
}
else
{
qglDepthFunc( GL_LEQUAL );
}
}
// //
// check blend bits // check blend bits
// //
if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
{
GLenum srcFactor, dstFactor;
if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) qglEnable( GL_BLEND );
{ qglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
srcFactor = GL_SRC_ALPHA;
dstFactor = GL_ONE_MINUS_SRC_ALPHA; // leilei - for pvr debug only!
qglEnable( GL_BLEND );
qglBlendFunc( srcFactor, dstFactor );
}
else
{
qglDisable( GL_BLEND );
}
}
// //
// check depthmask // check depthmask
// //

View File

@@ -136,6 +136,7 @@ static struct {
cvar_t *r_film; cvar_t *r_film;
extern int force32upload; extern int force32upload;
int leifxmode; int leifxmode;
int leifxpass;
int fakeit = 0; int fakeit = 0;
int tvinterlace = 1; int tvinterlace = 1;
@@ -795,6 +796,8 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) {
if (program->u_CC_Saturation > -1) R_GLSL_SetUniform_u_CC_Saturation(program, 1.0); if (program->u_CC_Saturation > -1) R_GLSL_SetUniform_u_CC_Saturation(program, 1.0);
if (program->u_CC_Contrast > -1) R_GLSL_SetUniform_u_CC_Contrast(program, 1.0); if (program->u_CC_Contrast > -1) R_GLSL_SetUniform_u_CC_Contrast(program, 1.0);
//
if (leifxmode == 3){ R_GLSL_SetUniform_u_CC_Brightness(program, leifxpass); }
if (program->u_zFar > -1) R_GLSL_SetUniform_u_zFar(program, tr.viewParms.zFar); if (program->u_zFar > -1) R_GLSL_SetUniform_u_zFar(program, tr.viewParms.zFar);
GL_SelectTexture(0); GL_SelectTexture(0);
@@ -1377,17 +1380,18 @@ void R_LeiFXPostprocessFilterScreen( void )
leifxmode = 3; // filter - 4 pass leifxmode = 3; // filter - 4 pass
// The stupidest hack in america // The stupidest hack in america
R_LeiFX_Stupid_Hack(); R_LeiFX_Stupid_Hack();
leifxpass = 0;
R_Postprocess_BackupScreen(); R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed(); R_Bloom_RestoreScreen_Postprocessed();
leifxpass = 1;
R_Postprocess_BackupScreen(); R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed(); R_Bloom_RestoreScreen_Postprocessed();
leifxpass = 2;
R_Postprocess_BackupScreen(); R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed(); R_Bloom_RestoreScreen_Postprocessed();
leifxpass = 3;
R_Postprocess_BackupScreen(); R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed(); R_Bloom_RestoreScreen_Postprocessed();
// leifxmode = 2;
// R_Postprocess_BackupScreen();
// R_Bloom_RestoreScreen_Postprocessed();
} }
backEnd.doneleifx = qtrue; backEnd.doneleifx = qtrue;

View File

@@ -206,6 +206,8 @@ void RE_SetColor( const float *rgba ) {
RE_StretchPic RE_StretchPic
============= =============
*/ */
extern int hackoperation;
void RE_StretchPic ( float x, float y, float w, float h, void RE_StretchPic ( float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader ) { float s1, float t1, float s2, float t2, qhandle_t hShader ) {
stretchPicCommand_t *cmd; stretchPicCommand_t *cmd;
@@ -217,6 +219,7 @@ void RE_StretchPic ( float x, float y, float w, float h,
if ( !cmd ) { if ( !cmd ) {
return; return;
} }
hackoperation = 0;
cmd->commandId = RC_STRETCH_PIC; cmd->commandId = RC_STRETCH_PIC;
cmd->shader = R_GetShaderByHandle( hShader ); cmd->shader = R_GetShaderByHandle( hShader );
cmd->x = x; cmd->x = x;

View File

@@ -1172,6 +1172,7 @@ static void Upload32( unsigned *data,
unsigned *scaledBuffer = NULL; unsigned *scaledBuffer = NULL;
unsigned *resampledBuffer = NULL; unsigned *resampledBuffer = NULL;
int scaled_width, scaled_height; int scaled_width, scaled_height;
int orig_width, orig_height;
int i, c; int i, c;
byte *scan; byte *scan;
GLenum internalFormat = GL_RGB; GLenum internalFormat = GL_RGB;
@@ -1182,28 +1183,61 @@ static void Upload32( unsigned *data,
int forceBits = 0; int forceBits = 0;
if (lightMap && r_parseStageSimple->integer) hackoperation = 4;
// leilei - npot support
orig_width = width;
orig_height = height;
// //
// convert to exact power of 2 sizes // convert to exact power of 2 sizes
// //
for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
;
for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1) if (r_roundImagesDown->integer == 2)
; {
if ( r_roundImagesDown->integer && scaled_width > width )
scaled_width >>= 1; scaled_width = width;
if ( r_roundImagesDown->integer && scaled_height > height ) scaled_height = height;
scaled_height >>= 1;
//scaled_width *= 1.5; //for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
////scaled_height *= 1.5; // ;
if ( scaled_width != width || scaled_height != height ) { //for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
resampledBuffer = ri.Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); // ;
if (hqresample)
Image_Resample32Lerp(data, width, height, resampledBuffer, scaled_width, scaled_height - 1); if ( scaled_width != width || scaled_height != height ) {
else resampledBuffer = ri.Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 );
ResampleTexture (data, width, height, resampledBuffer, scaled_width, scaled_height); ResampleTexture (data, width, height, resampledBuffer, scaled_width, scaled_height);
data = resampledBuffer; data = resampledBuffer;
width = scaled_width; width = scaled_width;
height = scaled_height; height = scaled_height;
}
}
else
{
for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
;
for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
;
if ( (r_roundImagesDown->integer == 1) && scaled_width > width )
scaled_width >>= 1;
if ( (r_roundImagesDown->integer == 1) && scaled_height > height )
scaled_height >>= 1;
if ( scaled_width != width || scaled_height != height ) {
resampledBuffer = ri.Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 );
if (hqresample)
Image_Resample32Lerp(data, width, height, resampledBuffer, scaled_width, scaled_height - 1);
else
ResampleTexture (data, width, height, resampledBuffer, scaled_width, scaled_height);
data = resampledBuffer;
width = scaled_width;
height = scaled_height;
}
} }
@@ -1321,8 +1355,48 @@ static void Upload32( unsigned *data,
// leilei - additive to alpha // leilei - additive to alpha
for ( i = 0; i < c; i++ ) for ( i = 0; i < c; i++ )
{ {
int r, g, b;
vec3_t rgb;
float amplify;
byte alfa = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]); byte alfa = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]);
//byte alfa = (scan[i*4]+ scan[i*4 + 1]+ scan[i*4 + 2]) / 3;
r = scan[i*4 + 0];
g = scan[i*4 + 1];
b = scan[i*4 + 2];
rgb[0] = r;
rgb[1] = g;
rgb[2] = b;
VectorNormalize(rgb);
r = rgb[0] * 256;
g = rgb[1] * 256;
b = rgb[2] * 256;
if (r>255) r=255;
if (g>255) g=255;
if (b>255) b=255;
if (scan[i*4 + 0] > r) r = scan[i*4 + 0];
if (scan[i*4 + 1] > g) g = scan[i*4 + 1];
if (scan[i*4 + 2] > b) b = scan[i*4 + 2];
scan[i*4 + 0] = r;
scan[i*4 + 1] = g;
scan[i*4 + 2] = b;
scan[i*4 + 3] = alfa; scan[i*4 + 3] = alfa;
}
}
else if (hackoperation == 2)
{
// leilei - alpha killing
for ( i = 0; i < c; i++ )
{
scan[i*4 + 3] = 255;
} }
} }
@@ -1332,34 +1406,68 @@ static void Upload32( unsigned *data,
{ {
for ( i = 0; i < c; i++ ) for ( i = 0; i < c; i++ )
{ {
byte alfa = LUMA(scan[i*4] * -1, scan[i*4 + 1] * -1, scan[i*4 + 2] * -1);
scan[i*4 + 3] = alfa; byte alfa = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]);
scan[i*4] = 0;
scan[i*4 + 1] = 0;
scan[i*4 + 2] = 0;
scan[i*4 + 3] = alfa;
} }
} }
else if(hackoperation == 4 ) // Multiplies else if (hackoperation == 4) // modulateply
{ {
int yee;
int yer; for ( i = 0; i < c; i++ )
int yeah; {
int yo; int r, g, b;
for ( i = 0; i < c; i++ ) vec3_t rgb;
{
yee = scan[i*4] - 127 * 1.18; // highlights float amplify;
yer = scan[i*4] * -1 + 127 ; // darks byte alfa = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]);
if (yee < 0) yee = 0; //byte alfa = (scan[i*4]+ scan[i*4 + 1]+ scan[i*4 + 2]) / 3;
if (yer < 0) yer = 0; alfa = sin(alfa/64) * 32;
yer *= 1.5;
yee = 0; amplify = (alfa - 128) / 255;
yeah = yee + yer; r = scan[i*4 + 0];
yo = 0; g = scan[i*4 + 1];
scan[i*4] = yo; b = scan[i*4 + 2];
scan[i*4 + 1] = yo; rgb[0] = r;
scan[i*4 + 2] = yo; rgb[1] = g;
scan[i*4 + 3] = yeah; rgb[2] = b;
} VectorNormalize(rgb);
r = rgb[0] * 256;
g = rgb[1] * 256;
b = rgb[2] * 256;
r *= amplify;
g *= amplify;
b *= amplify;
if (r<0) r=0;
if (g<0) g=0;
if (b<0) b=0;
if (r>255) r=255;
if (g>255) g=255;
if (b>255) b=255;
if (scan[i*4 + 0] > r) r = scan[i*4 + 0];
if (scan[i*4 + 1] > g) g = scan[i*4 + 1];
if (scan[i*4 + 2] > b) b = scan[i*4 + 2];
scan[i*4 + 0] = r;
scan[i*4 + 1] = g;
scan[i*4 + 2] = b;
scan[i*4 + 3] = alfa;
}
} }
if(r_textureDither->integer) // possibly the stupidest texture dithering ever if(r_textureDither->integer) // possibly the stupidest texture dithering ever
{ {
#ifdef DONTEVENTHINKABOUTTHIS #ifdef DONTEVENTHINKABOUTTHIS
@@ -2245,6 +2353,8 @@ void R_LoadImage( const char *name, byte **pic, int *width, int *height )
ext = COM_GetExtension( localName ); ext = COM_GetExtension( localName );
if( *ext ) if( *ext )
{ {
// Look for the correct loader and use it // Look for the correct loader and use it
@@ -2414,8 +2524,25 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
// loadtime = backEnd.refdef.floatTime - oldtime; // loadtime = backEnd.refdef.floatTime - oldtime;
image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 ); // leilei - if we need to change the texture upload with a special image prefix to separate from differently blended things
if (hackoperation)
{
char hackName[MAX_QPATH];
char *hackedName;
COM_StripExtension( name, hackName, MAX_QPATH );
if(hackoperation==1) hackedName = va("%shackadd", hackName);
if(hackoperation==2) hackedName = va("%shacknob", hackName);
if(hackoperation==3) hackedName = va("%shacksub", hackName);
if(hackoperation==4) hackedName = va("%shackmod", hackName);
else hackedName = va("%shackblend", hackName);
image = R_CreateImage( ( char * ) hackedName, pic, width, height, type, flags, 0 );
}
else
{
image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 );
}
ri.Free( pic ); ri.Free( pic );

View File

@@ -202,6 +202,7 @@ cvar_t *r_flaresDlightScale;
//cvar_t *r_flaresSurfradii; //cvar_t *r_flaresSurfradii;
cvar_t *r_alternateBrightness; // leilei - linux overbright fix cvar_t *r_alternateBrightness; // leilei - linux overbright fix
cvar_t *r_mockvr; // Leilei - for debugging PVR only! cvar_t *r_mockvr; // Leilei - for debugging PVR only!
cvar_t *r_parseStageSimple; // Leilei - for debugging PVR only!
cvar_t *r_leifx; // Leilei - leifx nostalgia filter cvar_t *r_leifx; // Leilei - leifx nostalgia filter
cvar_t *r_modelshader; // Leilei cvar_t *r_modelshader; // Leilei
@@ -1282,7 +1283,8 @@ void R_Register( void )
r_flareSun = ri.Cvar_Get( "r_flareSun", "0" , CVAR_ARCHIVE); // it's 0 because mappers expect 0. r_flareSun = ri.Cvar_Get( "r_flareSun", "0" , CVAR_ARCHIVE); // it's 0 because mappers expect 0.
r_mockvr = ri.Cvar_Get( "r_mockvr", "0" , CVAR_ARCHIVE | CVAR_CHEAT); r_mockvr = ri.Cvar_Get( "r_mockvr", "0" , CVAR_CHEAT);
r_parseStageSimple = ri.Cvar_Get( "r_parseStageSimple", "0" , CVAR_CHEAT);
r_leifx = ri.Cvar_Get( "r_leifx", "0" , CVAR_ARCHIVE | CVAR_LATCH); r_leifx = ri.Cvar_Get( "r_leifx", "0" , CVAR_ARCHIVE | CVAR_LATCH);
r_modelshader = ri.Cvar_Get( "r_modelshader", "0" , CVAR_ARCHIVE | CVAR_LATCH); // leilei - load and use special shaders for lightDiffuse models r_modelshader = ri.Cvar_Get( "r_modelshader", "0" , CVAR_ARCHIVE | CVAR_LATCH); // leilei - load and use special shaders for lightDiffuse models
r_detailTextureScale = ri.Cvar_Get( "r_detailtextureScale", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - adjust scale of detail textures r_detailTextureScale = ri.Cvar_Get( "r_detailtextureScale", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - adjust scale of detail textures

View File

@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../qcommon/q_shared.h" #include "../qcommon/q_shared.h"
#include "../qcommon/qfiles.h" #include "../qcommon/qfiles.h"
#include "../qcommon/qcommon.h" #include "../qcommon/qcommon.h"
#include "../renderercommon/tr_public.h" #include "../renderercommon/tr_public.h"
#include "../renderercommon/tr_common.h" #include "../renderercommon/tr_common.h"
#include "../renderercommon/iqm.h" #include "../renderercommon/iqm.h"
@@ -316,6 +317,10 @@ typedef struct {
int isBlend; // leilei - for leifx int isBlend; // leilei - for leifx
qboolean isLeiShade; // leilei - for the automatic shader qboolean isLeiShade; // leilei - for the automatic shader
qhandle_t program; qhandle_t program;
int imgWidth;
int imgHeight; //leilei for glsl shaders
} shaderStage_t; } shaderStage_t;
struct shaderCommands_s; struct shaderCommands_s;
@@ -1344,7 +1349,7 @@ extern cvar_t *r_flaresDlightScale;
//extern cvar_t *r_flaresSurfradii; //extern cvar_t *r_flaresSurfradii;
extern cvar_t *r_alternateBrightness; // leilei - alternate brightness extern cvar_t *r_alternateBrightness; // leilei - alternate brightness
extern cvar_t *r_parseStageSimple; // Leilei - handling textures into alphas
extern cvar_t *r_leifx; // Leilei - leifx nostalgia filter extern cvar_t *r_leifx; // Leilei - leifx nostalgia filter
extern cvar_t *r_modelshader; // Leilei - new model shading extern cvar_t *r_modelshader; // Leilei - new model shading

View File

@@ -1031,6 +1031,41 @@ static void ComputeColors( shaderStage_t *pStage )
break; break;
} }
// leilei PowerVR Hack
if (r_parseStageSimple->integer)
{
float scale;
vec3_t normme;
if ((pStage->isBlend == 1) || (pStage->isBlend == 3)){ // additive or subtracive
for(i = 0; i < tess.numVertexes; i++)
{
scale = LUMA(tess.svars.colors[i][0], tess.svars.colors[i][1], tess.svars.colors[i][2]);
tess.svars.colors[i][3] = scale - tess.svars.colors[i][3];
if (tess.svars.colors[i][3] > 255) tess.svars.colors[i][3] = 255;
normme[0] = tess.svars.colors[i][0];
normme[1] = tess.svars.colors[i][1];
normme[2] = tess.svars.colors[i][2];
// normme[0] *= (4 * tr.identityLight);
// normme[1] *= (4 * tr.identityLight);
// normme[2] *= (4 * tr.identityLight);
VectorNormalize(normme);
tess.svars.colors[i][0] = normme[0]*255;
tess.svars.colors[i][1] = normme[1]*255;
tess.svars.colors[i][2] = normme[2]*255;
}
}
}
// //
// alphaGen // alphaGen
// //

File diff suppressed because it is too large Load Diff