- aspect correction for r_tvmode
- timedemo finishing writes to cl_timedemoResult (for UI3) - support for screen palletizing shader - Additional placeholder textures (not yet used) - trying to make r_film more dynamic - more model shading crap you should ignore - also, ignore the
This commit is contained in:
@@ -907,6 +907,12 @@ void CL_DemoCompleted( void )
|
||||
CL_DemoFrameDurationSDev( ) );
|
||||
Com_Printf( "%s", buffer );
|
||||
|
||||
|
||||
// leilei - shove some abridged info in a cvar for display in the UI
|
||||
{
|
||||
Cvar_Set( "ui_timedemoResult", va("%3.1f fps %3.1f seconds", clc.timeDemoFrames*1000.0 / time, time/1000.0) );
|
||||
|
||||
}
|
||||
// Write a log of all the frame durations
|
||||
if( cl_timedemoLog && strlen( cl_timedemoLog->string ) > 0 )
|
||||
{
|
||||
@@ -3093,6 +3099,9 @@ void CL_ShutdownRef( void ) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
extern int vresWidth;
|
||||
extern int vresHeight;
|
||||
/*
|
||||
============
|
||||
CL_InitRenderer
|
||||
|
@@ -1665,10 +1665,10 @@ const void *RB_SwapBuffers( const void *data ) {
|
||||
RB_DrawAccumBlur ();
|
||||
}
|
||||
R_BrightScreen(); // leilei - alternate brightness - do it here so we hit evereything
|
||||
R_RetroAAScreen(); // leilei - then apply 'anti aliasing'
|
||||
|
||||
R_NTSCScreen();
|
||||
|
||||
R_RetroAAScreen(); // leilei - then apply 'anti aliasing' (hint: IT'S NOT really antialiasing)
|
||||
R_PaletteScreen(); // leilei - then we palette our overbrighted antialiased screen.
|
||||
R_NTSCScreen(); // leilei - then we get it through a DAC
|
||||
R_TVScreen(); // leilei - tv operation comes last, this is a SCREEN
|
||||
|
||||
|
||||
@@ -1711,6 +1711,7 @@ const void *RB_SwapBuffers( const void *data ) {
|
||||
backEnd.doneFilm = qfalse;
|
||||
backEnd.doneleifx = qfalse;
|
||||
backEnd.doneanime = qfalse;
|
||||
backEnd.donepalette = qfalse;
|
||||
backEnd.donemblur = qfalse;
|
||||
backEnd.doneSurfaces = qfalse;
|
||||
backEnd.doneSun = qfalse;
|
||||
|
@@ -142,6 +142,7 @@ int tvinterlace = 1;
|
||||
int tvinter= 1;
|
||||
extern int tvWidth;
|
||||
extern int tvHeight;
|
||||
extern float tvAspectW; // aspect correction
|
||||
extern int vresWidth;
|
||||
extern int vresHeight;
|
||||
/*
|
||||
@@ -665,10 +666,12 @@ extern int mpasses;
|
||||
static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float texY, float texWidth, float texHeight, int aa ) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
float aspcenter = 0;
|
||||
int aspoff = 0;
|
||||
float raa = r_retroAA->value;
|
||||
if (raa < 1) raa = 1;
|
||||
|
||||
float xpix = 1.0f / width / (4 / raa);
|
||||
float xpix = 1.0f / width / (4 / raa);
|
||||
float ypix = 1.0f / height / (4 / raa);
|
||||
float xaa;
|
||||
float yaa;
|
||||
@@ -692,9 +695,29 @@ static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float t
|
||||
texWidth += texX;
|
||||
texHeight += texY;
|
||||
|
||||
if (tvAspectW != 1.0){
|
||||
aspcenter = tvWidth * ((1.0f - tvAspectW) / 2);
|
||||
// leilei - also do a quad that is 100% black, hiding our actual rendered viewport
|
||||
|
||||
// qglViewport (0, 0, tvWidth, tvHeight );
|
||||
// qglScissor (0, 0, tvWidth, tvHeight );
|
||||
qglBegin( GL_QUADS );
|
||||
qglColor4f( 0.0, 0.0, 0.0, 1 );
|
||||
qglVertex2f(0,0 );
|
||||
qglVertex2f(0,height);
|
||||
qglVertex2f(width,height);
|
||||
qglVertex2f(width,0);
|
||||
qglEnd ();
|
||||
qglColor4f( 1.0, 1.0, 1.0, 1 );
|
||||
}
|
||||
|
||||
|
||||
//aspcenter = 0;
|
||||
aspoff = tvWidth * tvAspectW;
|
||||
|
||||
if (!aa){
|
||||
qglViewport( 0, 0, tvWidth, tvHeight );
|
||||
qglScissor( 0, 0, tvWidth, tvHeight );
|
||||
qglViewport(aspcenter, 0, (tvWidth * tvAspectW), tvHeight );
|
||||
qglScissor(aspcenter, 0, (tvWidth * tvAspectW), tvHeight );
|
||||
}
|
||||
qglBegin( GL_QUADS );
|
||||
//GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );
|
||||
@@ -729,6 +752,7 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) {
|
||||
if (leifxmode == 634){ if (vertexShaders) R_GLSL_UseProgram(tr.NTSCBleedProgram); program=tr.programs[tr.NTSCBleedProgram];}
|
||||
if (leifxmode == 666){ if (vertexShaders) R_GLSL_UseProgram(tr.BrightnessProgram); program=tr.programs[tr.BrightnessProgram];}
|
||||
if (leifxmode == 1236){ if (vertexShaders) R_GLSL_UseProgram(tr.CRTProgram); program=tr.programs[tr.CRTProgram];}
|
||||
if (leifxmode == 1997){ if (vertexShaders) R_GLSL_UseProgram(tr.paletteProgram); program=tr.programs[tr.paletteProgram];}
|
||||
|
||||
}
|
||||
else
|
||||
@@ -1057,8 +1081,8 @@ static void R_Postprocess_InitTextures( void )
|
||||
//else
|
||||
for (postproc.screen.height = 1;postproc.screen.height < glConfig.vidHeight;postproc.screen.height *= 2);
|
||||
|
||||
if (r_tvMode->integer > 1)
|
||||
intdiv = 2;
|
||||
// if (r_tvMode->integer > 1)
|
||||
// intdiv = 2;
|
||||
|
||||
postproc.screen.readW = glConfig.vidWidth / (float)postproc.screen.width;
|
||||
postproc.screen.readH = glConfig.vidHeight / (float)postproc.screen.height;
|
||||
@@ -1586,6 +1610,8 @@ void R_AltBrightnessInit( void ) {
|
||||
|
||||
void R_FilmScreen( void )
|
||||
{
|
||||
vec3_t tone, toneinv, tonecont;
|
||||
vec3_t tonework;
|
||||
|
||||
if( !r_film->integer )
|
||||
return;
|
||||
@@ -1594,8 +1620,43 @@ void R_FilmScreen( void )
|
||||
if ( !backEnd.projection2D )
|
||||
RB_SetGL2D();
|
||||
backEnd.doneFilm = qtrue;
|
||||
|
||||
// set up our colors, this is our default
|
||||
tone[0] = 0.8f;
|
||||
tone[1] = 0.9f;
|
||||
tone[2] = 1.0f;
|
||||
//VectorCopy( backEnd.currentEntity->ambientLight, tone );
|
||||
if (backEnd.currentEntity){
|
||||
if (backEnd.currentEntity->ambientLight[0] > 0.001f && backEnd.currentEntity->ambientLight[1] > 0.001f && backEnd.currentEntity->ambientLight[2] > 0.001f){
|
||||
tone[0] = backEnd.currentEntity->ambientLight[0];
|
||||
tone[1] = backEnd.currentEntity->ambientLight[1];
|
||||
tone[2] = backEnd.currentEntity->ambientLight[2];
|
||||
}
|
||||
}
|
||||
|
||||
// VectorNormalize(tone);
|
||||
|
||||
tone[0] *= 0.3 + 0.7;
|
||||
tone[1] *= 0.3 + 0.7;
|
||||
tone[2] *= 0.3 + 0.7;
|
||||
|
||||
// tone[0] = 1.6f;
|
||||
// tone[1] = 1.2f;
|
||||
// tone[2] = 0.7f;
|
||||
|
||||
|
||||
// TODO: Get overexposure to flares raising this faking "HDR"
|
||||
tonecont[0] = 0.0f;
|
||||
tonecont[1] = 0.0f;
|
||||
tonecont[2] = 0.0f;
|
||||
|
||||
|
||||
// inverted
|
||||
|
||||
toneinv[0] = tone[0] * -1 + 1 + tonecont[0];
|
||||
toneinv[1] = tone[1] * -1 + 1 + tonecont[1];
|
||||
toneinv[2] = tone[2] * -1 + 1 + tonecont[2];
|
||||
|
||||
// darken vignette.
|
||||
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);GL_Bind( tr.dlightImage ); GL_Cull( CT_TWO_SIDED );
|
||||
qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f );
|
||||
@@ -1605,12 +1666,15 @@ void R_FilmScreen( void )
|
||||
|
||||
// brighten.
|
||||
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE);GL_Bind( tr.dlightImage ); GL_Cull( CT_TWO_SIDED );
|
||||
qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f );
|
||||
//qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f );
|
||||
qglColor4f( (0.9f + (tone[0] * 0.5)), (0.9f + (tone[1] * 0.5)), (0.9f + (tone[2] * 0.5)), 1.0f );
|
||||
|
||||
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0.25f, 0.25f, 0.48f, 0.48f );
|
||||
|
||||
// invoort.
|
||||
// invert.
|
||||
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED );
|
||||
qglColor4f(0.85098, 0.85098, 0.815686, 1.0f );
|
||||
// qglColor4f(0.85098, 0.85098, 0.815686, 1.0f );
|
||||
qglColor4f( (0.8f + (toneinv[0] * 0.5)), (0.8f + (toneinv[1] * 0.5)), (0.8f + (toneinv[2] * 0.5)), 1.0f );
|
||||
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 );
|
||||
|
||||
// brighten.
|
||||
@@ -1626,7 +1690,8 @@ void R_FilmScreen( void )
|
||||
|
||||
// brighten.
|
||||
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED );
|
||||
qglColor4f( 0.866667, 0.847059, 0.776471, 1.0f );
|
||||
// qglColor4f( 0.866667, 0.847059, 0.776471, 1.0f );
|
||||
qglColor4f( (0.73f + (toneinv[0] * 0.4)), (0.73f + (toneinv[1] * 0.4)), (0.73f + (toneinv[2] * 0.4)), 1.0f );
|
||||
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 );
|
||||
|
||||
|
||||
@@ -1831,8 +1896,8 @@ void R_MblurScreenPost( void )
|
||||
static void R_Postprocess_BackupScreenTV( void ) {
|
||||
|
||||
int intdiv;
|
||||
if (r_tvMode->integer > 1) intdiv = 2;
|
||||
else intdiv = 1;
|
||||
// if (r_tvMode->integer > 1) intdiv = 2;
|
||||
intdiv = 1;
|
||||
|
||||
|
||||
GL_TexEnv( GL_MODULATE );
|
||||
@@ -1856,10 +1921,6 @@ static void R_Postprocess_BackupScreenTV( void ) {
|
||||
|
||||
static void R_Postprocess_ScaleTV( void ) {
|
||||
|
||||
// int intdiv;
|
||||
// if (r_tvMode->integer > 1) intdiv = 2;
|
||||
// else intdiv = 1;
|
||||
|
||||
|
||||
GL_TexEnv( GL_MODULATE );
|
||||
qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
|
||||
@@ -1911,7 +1972,7 @@ void R_TVScreen( void )
|
||||
|
||||
tvinter = tvinterlace;
|
||||
if (tvinter < 0) tvinter = 0;
|
||||
if (r_tvMode->integer < 2) tvinter = 0;
|
||||
if (r_tvMode->integer < 100) tvinter = 0;
|
||||
tvinter = 0;
|
||||
|
||||
leifxmode = 1234; // just show it through to tvWidth/tvHeight
|
||||
@@ -1920,7 +1981,7 @@ void R_TVScreen( void )
|
||||
// leifxmode = 1236; // run it through a shader
|
||||
//R_Postprocess_BackupScreen();
|
||||
|
||||
if (r_tvMode->integer > 10)
|
||||
if (r_tvMode->integer > 100)
|
||||
{
|
||||
R_Postprocess_ScaleTV();
|
||||
}
|
||||
@@ -1943,6 +2004,48 @@ void R_TVScreen( void )
|
||||
|
||||
|
||||
|
||||
// =================================================================
|
||||
// PALLETIZING
|
||||
// =================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
void R_PaletteScreen( void )
|
||||
{
|
||||
if( !r_palletize->integer)
|
||||
return;
|
||||
if ( backEnd.donepalette)
|
||||
return;
|
||||
if ( !backEnd.doneSurfaces )
|
||||
return;
|
||||
if ( !vertexShaders )
|
||||
return; // leilei - cards without support for this should not ever activate this
|
||||
if( !postproc.started ) {
|
||||
force32upload = 1;
|
||||
R_Postprocess_InitTextures();
|
||||
if( !postproc.started )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !backEnd.projection2D )
|
||||
RB_SetGL2D();
|
||||
|
||||
force32upload = 1;
|
||||
|
||||
leifxmode = 1997; // anime effect - outlines, desat, bloom and other crap to go with it
|
||||
R_LeiFX_Stupid_Hack();
|
||||
R_Postprocess_BackupScreen();
|
||||
R_Bloom_RestoreScreen_Postprocessed();
|
||||
backEnd.donepalette = qtrue;
|
||||
|
||||
force32upload = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// =================================================================
|
||||
// WATER BUFFER TEST
|
||||
|
@@ -180,6 +180,41 @@ void R_SetPalette ( const unsigned char *palette)
|
||||
|
||||
}
|
||||
|
||||
// leilei - for palettizing GLSL shaders, dump palette values to console
|
||||
void R_GLSLPalette ( const unsigned char *palette)
|
||||
{
|
||||
int i;
|
||||
|
||||
int red, green, blue;
|
||||
float redf, greenf, bluef;
|
||||
|
||||
if ( palette )
|
||||
{
|
||||
|
||||
for ( i = 0; i < 256; i++ )
|
||||
{
|
||||
|
||||
red = d_8to24table[i] & 0xff;
|
||||
green = ( d_8to24table[i] >> 8 ) & 0xff;
|
||||
blue = ( d_8to24table[i] >> 16 ) & 0xff;
|
||||
redf = (d_8to24table[i] & 0xff) * 0.003921568627451;
|
||||
greenf = (( d_8to24table[i] >> 8 ) & 0xff) * 0.003921568627451;
|
||||
bluef = (( d_8to24table[i] >> 16 ) & 0xff) * 0.003921568627451;
|
||||
//ri.Printf( PRINT_ALL, " vec3(%i, %i, %i),\n", red, green, blue );
|
||||
ri.Printf( PRINT_ALL, " vec3(%f, %f, %f),\n", redf, greenf, bluef );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void R_GLSLPalette_f ( )
|
||||
{
|
||||
R_GLSLPalette(palettemain);
|
||||
|
||||
}
|
||||
|
||||
void R_InitPalette( void ) {
|
||||
|
||||
byte *buff;
|
||||
@@ -2193,12 +2228,14 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
|
||||
//
|
||||
// load the pic from disk
|
||||
//
|
||||
oldtime = backEnd.refdef.floatTime;
|
||||
//oldtime = backEnd.refdef.floatTime;
|
||||
oldtime = ri.Milliseconds() * 100;
|
||||
R_LoadImage( name, &pic, &width, &height );
|
||||
if ( pic == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
loadtime = backEnd.refdef.floatTime - oldtime;
|
||||
loadtime = (ri.Milliseconds() * 100) - oldtime;
|
||||
// loadtime = backEnd.refdef.floatTime - oldtime;
|
||||
|
||||
|
||||
image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 );
|
||||
|
@@ -204,6 +204,7 @@ cvar_t *r_ntsc; // Leilei - ntsc / composite signals
|
||||
//cvar_t *r_tvMode; // Leilei - tv fake mode
|
||||
cvar_t *r_retroAA; // Leilei - old console AA
|
||||
cvar_t *r_anime; // Leilei - anime filter
|
||||
cvar_t *r_palletize; // Leilei - palletization
|
||||
cvar_t *r_leidebug; // Leilei - debug
|
||||
cvar_t *r_leidebugeye; // Leilei - eye debug
|
||||
cvar_t *r_leiwater; // Leilei - water effect test
|
||||
@@ -1289,6 +1290,7 @@ void R_Register( void )
|
||||
r_motionblur_fps = ri.Cvar_Get( "r_motionblur_fps", "60", 0);
|
||||
|
||||
r_anime = ri.Cvar_Get( "r_anime", "0" , CVAR_ARCHIVE | CVAR_LATCH);
|
||||
r_palletize = ri.Cvar_Get( "r_palletize", "0" , CVAR_ARCHIVE | CVAR_LATCH);
|
||||
r_leidebug = ri.Cvar_Get( "r_leidebug", "0" , CVAR_CHEAT);
|
||||
r_leidebugeye = ri.Cvar_Get( "r_leidebugeye", "0" , CVAR_CHEAT);
|
||||
r_slowness = ri.Cvar_Get( "r_slowness", "0" , CVAR_ARCHIVE); // it's 0 because you want it to be the fastest possible by default.
|
||||
@@ -1313,6 +1315,7 @@ void R_Register( void )
|
||||
ri.Cmd_AddCommand( "screenshotJPEG", R_ScreenShotJPEG_f );
|
||||
ri.Cmd_AddCommand( "gfxinfo", GfxInfo_f );
|
||||
ri.Cmd_AddCommand( "minimize", GLimp_Minimize );
|
||||
ri.Cmd_AddCommand( "paletteglsldump", R_GLSLPalette_f );
|
||||
}
|
||||
|
||||
|
||||
@@ -1435,6 +1438,10 @@ void R_GLSL_Init(void) {
|
||||
Q_strncpyz(programFragmentObjects[0], "glsl/anime_film_fp.glsl", sizeof(programFragmentObjects[0]));
|
||||
tr.animeFilmProgram = RE_GLSL_RegisterProgram("anime_film", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
|
||||
|
||||
Q_strncpyz(programVertexObjects[0], "glsl/palette_vp.glsl", sizeof(programVertexObjects[0]));
|
||||
Q_strncpyz(programFragmentObjects[0], "glsl/palette_fp.glsl", sizeof(programFragmentObjects[0]));
|
||||
tr.paletteProgram = RE_GLSL_RegisterProgram("palette", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
|
||||
|
||||
|
||||
Q_strncpyz(programVertexObjects[0], "glsl/leifx_dither_vp.glsl", sizeof(programVertexObjects[0]));
|
||||
Q_strncpyz(programFragmentObjects[0], "glsl/leifx_dither_fp.glsl", sizeof(programFragmentObjects[0]));
|
||||
|
@@ -254,6 +254,147 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
|
||||
|
||||
|
||||
|
||||
// leilei - alternative version to don't do the dynamic lighting contrast which could
|
||||
// contribute toward epilepsy.
|
||||
|
||||
static void R_SetupEntityLightingGrid_NoContrast( trRefEntity_t *ent ) {
|
||||
vec3_t lightOrigin;
|
||||
int pos[3];
|
||||
int i, j;
|
||||
byte *gridData;
|
||||
float frac[3];
|
||||
int gridStep[3];
|
||||
vec3_t direction;
|
||||
float totalFactor;
|
||||
|
||||
|
||||
|
||||
|
||||
if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) {
|
||||
// seperate lightOrigins are needed so an object that is
|
||||
// sinking into the ground can still be lit, and so
|
||||
// multi-part models can be lit identically
|
||||
VectorCopy( ent->e.lightingOrigin, lightOrigin );
|
||||
} else {
|
||||
VectorCopy( ent->e.origin, lightOrigin );
|
||||
}
|
||||
|
||||
VectorSubtract( lightOrigin, tr.world->lightGridOrigin, lightOrigin );
|
||||
for ( i = 0 ; i < 3 ; i++ ) {
|
||||
float v;
|
||||
|
||||
|
||||
v = lightOrigin[i]*tr.world->lightGridInverseSize[i];
|
||||
pos[i] = floor( v );
|
||||
frac[i] = v - pos[i];
|
||||
if ( pos[i] < 0 ) {
|
||||
pos[i] = 0;
|
||||
} else if ( pos[i] >= tr.world->lightGridBounds[i] - 1 ) {
|
||||
pos[i] = tr.world->lightGridBounds[i] - 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
VectorClear( ent->ambientLight );
|
||||
VectorClear( ent->directedLight );
|
||||
VectorClear( ent->dynamicLight );
|
||||
VectorClear( direction );
|
||||
|
||||
assert( tr.world->lightGridData ); // NULL with -nolight maps
|
||||
|
||||
// trilerp the light value
|
||||
gridStep[0] = 8;
|
||||
gridStep[1] = 8 * tr.world->lightGridBounds[0];
|
||||
gridStep[2] = 8 * tr.world->lightGridBounds[0] * tr.world->lightGridBounds[1];
|
||||
gridData = tr.world->lightGridData + pos[0] * gridStep[0]
|
||||
+ pos[1] * gridStep[1] + pos[2] * gridStep[2];
|
||||
|
||||
totalFactor = 0;
|
||||
for ( i = 0 ; i < 8 ; i++ ) {
|
||||
float factor;
|
||||
byte *data;
|
||||
int lat, lng;
|
||||
vec3_t normal;
|
||||
#if idppc
|
||||
float d0, d1, d2, d3, d4, d5;
|
||||
#endif
|
||||
factor = 1.0;
|
||||
data = gridData;
|
||||
for ( j = 0 ; j < 3 ; j++ ) {
|
||||
if ( i & (1<<j) ) {
|
||||
factor *= frac[j];
|
||||
data += gridStep[j];
|
||||
} else {
|
||||
factor *= (1.0f - frac[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !(data[0]+data[1]+data[2]) ) {
|
||||
continue; // ignore samples in walls
|
||||
}
|
||||
totalFactor += factor;
|
||||
#if idppc
|
||||
d0 = data[0]; d1 = data[1]; d2 = data[2];
|
||||
d3 = data[3]; d4 = data[4]; d5 = data[5];
|
||||
|
||||
ent->ambientLight[0] += factor * d0;
|
||||
ent->ambientLight[1] += factor * d1;
|
||||
ent->ambientLight[2] += factor * d2;
|
||||
|
||||
ent->directedLight[0] += factor * d3;
|
||||
ent->directedLight[1] += factor * d4;
|
||||
ent->directedLight[2] += factor * d5;
|
||||
#else
|
||||
ent->ambientLight[0] += factor * data[0];
|
||||
ent->ambientLight[1] += factor * data[1];
|
||||
ent->ambientLight[2] += factor * data[2];
|
||||
|
||||
ent->directedLight[0] += factor * data[3];
|
||||
ent->directedLight[1] += factor * data[4];
|
||||
ent->directedLight[2] += factor * data[5];
|
||||
#endif
|
||||
lat = data[7];
|
||||
lng = data[6];
|
||||
lat *= (FUNCTABLE_SIZE/256);
|
||||
lng *= (FUNCTABLE_SIZE/256);
|
||||
|
||||
// decode X as cos( lat ) * sin( long )
|
||||
// decode Y as sin( lat ) * sin( long )
|
||||
// decode Z as cos( long )
|
||||
|
||||
normal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
|
||||
normal[1] = tr.sinTable[lat] * tr.sinTable[lng];
|
||||
normal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
|
||||
|
||||
VectorMA( direction, factor, normal, direction );
|
||||
}
|
||||
|
||||
if ( totalFactor > 0 && totalFactor < 0.99 ) {
|
||||
totalFactor = 1.0f / totalFactor;
|
||||
VectorScale( ent->ambientLight, totalFactor, ent->ambientLight );
|
||||
VectorScale( ent->directedLight, totalFactor, ent->directedLight );
|
||||
}
|
||||
|
||||
VectorScale( ent->ambientLight, r_ambientScale->value, ent->ambientLight );
|
||||
VectorScale( ent->directedLight, r_directedScale->value, ent->directedLight );
|
||||
|
||||
{
|
||||
float ervg = ent->directedLight[0] + ent->directedLight[1] + ent->directedLight[2];
|
||||
// VectorScale( ent->ambientLight, ent->directedLight, ent->ambientLight );
|
||||
// VectorScale( ent->directedLight, 0.7, ent->directedLight );
|
||||
|
||||
}
|
||||
|
||||
VectorNormalize2( direction, ent->lightDir );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
LogLight
|
||||
|
@@ -1049,6 +1049,7 @@ typedef struct {
|
||||
qboolean donetv; // leilei - tv this frame
|
||||
qboolean doneraa; // leilei - done aa'ing this frame
|
||||
qboolean donentsc; // leilei - done ntsc'ing this frame
|
||||
qboolean donepalette; // leilei - done animeing this frame
|
||||
qboolean doneSurfaces; // done any 3d surfaces already
|
||||
trRefEntity_t entity2D; // currentEntity will point at this when doing 2D rendering
|
||||
} backEndState_t;
|
||||
@@ -1113,6 +1114,7 @@ typedef struct {
|
||||
qhandle_t NTSCEncodeProgram; // leilei
|
||||
qhandle_t NTSCDecodeProgram; // leilei
|
||||
qhandle_t NTSCBleedProgram; // leilei
|
||||
qhandle_t paletteProgram; // leilei
|
||||
|
||||
int numPrograms;
|
||||
glslProgram_t *programs[MAX_PROGRAMS];
|
||||
@@ -1175,9 +1177,20 @@ typedef struct {
|
||||
|
||||
shader_t *placeholderTextureShader; // leilei - for map textures
|
||||
shader_t *placeholderModelShader; // leilei - for models
|
||||
shader_t *placeholderSkyShader; // leilei - for skies
|
||||
shader_t *placeholderWaterShader; // leilei - for liquids
|
||||
shader_t *placeholderLavaShader; // leilei - for lavas
|
||||
shader_t *placeholderSlimeShader; // leilei - for slimes
|
||||
shader_t *placeholderFogShader; // leilei - for fogs
|
||||
shader_t *placeholderShader; // leilei - for anything else
|
||||
|
||||
qboolean placeholderTextureAvail;
|
||||
qboolean placeholderModelAvail;
|
||||
qboolean placeholderSkyAvail;
|
||||
qboolean placeholderWaterAvail;
|
||||
qboolean placeholderLavaAvail;
|
||||
qboolean placeholderSlimeAvail;
|
||||
qboolean placeholderFogAvail;
|
||||
qboolean placeholderAvail;
|
||||
|
||||
} trGlobals_t;
|
||||
@@ -1326,6 +1339,7 @@ extern cvar_t *r_leiwater; // Leilei - water test
|
||||
extern cvar_t *r_ntsc; // Leilei - ntsc
|
||||
|
||||
extern cvar_t *r_tvMode; // Leilei - tv faking mode
|
||||
extern cvar_t *r_tvModeForceAspect; // Leilei - retain aspect of the tv's mode
|
||||
extern cvar_t *r_tvConsoleMode; // Leilei - tv faking mode
|
||||
|
||||
extern cvar_t *r_retroAA; // Leilei - old console anti aliasing
|
||||
@@ -1336,6 +1350,7 @@ extern cvar_t *r_motionblur; // Leilei - motionblur
|
||||
extern cvar_t *r_motionblur_fps; // Leilei - motionblur framerated
|
||||
|
||||
extern cvar_t *r_anime; // Leilei - anime filter
|
||||
extern cvar_t *r_palletize; // Leilei - anime filter
|
||||
extern cvar_t *r_leidebug; // Leilei - debug only!
|
||||
extern cvar_t *r_leidebugeye; // Leilei - debug only!
|
||||
|
||||
@@ -1448,6 +1463,7 @@ void R_SkinList_f( void );
|
||||
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516
|
||||
const void *RB_TakeScreenshotCmd( const void *data );
|
||||
void R_ScreenShot_f( void );
|
||||
void R_GLSLPalette_f( void );
|
||||
|
||||
void R_InitFogTable( void );
|
||||
float R_FogFactor( float s, float t );
|
||||
@@ -2252,6 +2268,7 @@ void R_BloomScreen( void );
|
||||
void R_WaterScreen( void );
|
||||
void R_AnimeScreen( void );
|
||||
void R_NTSCScreen( void );
|
||||
void R_PaletteScreen( void );
|
||||
// Postprocessing
|
||||
void R_PostprocessScreen( void );
|
||||
void R_PostprocessingInit(void);
|
||||
|
@@ -1625,22 +1625,45 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
|
||||
vec3_t ambientLight;
|
||||
vec3_t lightDir;
|
||||
vec3_t directedLight;
|
||||
vec3_t specularLight;
|
||||
int numVertexes;
|
||||
int shadecap = 200; // was 127
|
||||
ent = backEnd.currentEntity;
|
||||
ambientLightInt = ent->ambientLightInt;
|
||||
VectorCopy( ent->ambientLight, ambientLight );
|
||||
VectorCopy( ent->directedLight, directedLight );
|
||||
VectorCopy( ent->directedLight, specularLight );
|
||||
VectorCopy( ent->lightDir, lightDir );
|
||||
|
||||
// averaging colors test
|
||||
/*
|
||||
{
|
||||
int rf;
|
||||
for (rf=0;rf<3;rf++){
|
||||
//directedLight[rf] = ambientLight[rf] + directedLight[rf] / 2;
|
||||
//ambientLight[rf] = pow((ambientLight[rf] / 255), (directedLight[rf] / 255)) * 255;
|
||||
specularLight[rf] -= ambientLight[rf];
|
||||
ambientLight[rf] = ambientLight[rf] + ambientLight[rf] + (directedLight[rf] / 512);
|
||||
|
||||
|
||||
//shadecap += directedLight[rf];
|
||||
if (specularLight[rf] < 0) specularLight[rf] = 0;
|
||||
if (ambientLight[rf] > 255) ambientLight[rf] = 255;
|
||||
|
||||
}
|
||||
//shadecap /= 3;
|
||||
|
||||
ambientLightInt *= 1.5;
|
||||
|
||||
}
|
||||
*/
|
||||
v = tess.xyz[0];
|
||||
normal = tess.normal[0];
|
||||
|
||||
numVertexes = tess.numVertexes;
|
||||
for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) {
|
||||
incoming = DotProduct (normal, lightDir);
|
||||
|
||||
if ( incoming <= 0 ) {
|
||||
*(int *)&colors[i*4] = ambientLightInt;
|
||||
continue;
|
||||
@@ -1687,14 +1710,14 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
|
||||
|
||||
j = ri.ftol(ambientLight[0] + incoming * directedLight[0]);
|
||||
if ( j > shadecap ) j = shadecap ;
|
||||
j += ri.ftol(spec * directedLight[0]);
|
||||
j += ri.ftol(spec * specularLight[0]);
|
||||
|
||||
if ( j > 255) j = 255;
|
||||
colors[i*4+0] = j;
|
||||
|
||||
j = ri.ftol(ambientLight[1] + incoming * directedLight[1]);
|
||||
if ( j > shadecap ) j = shadecap ;
|
||||
j += ri.ftol(spec * directedLight[1]);
|
||||
j += ri.ftol(spec * specularLight[1]);
|
||||
|
||||
if ( j > 255) j = 255;
|
||||
|
||||
@@ -1703,7 +1726,7 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
|
||||
|
||||
j = ri.ftol(ambientLight[2] + incoming * directedLight[2]);
|
||||
if ( j > shadecap ) j = shadecap ;
|
||||
j += ri.ftol(spec * directedLight[2]);
|
||||
j += ri.ftol(spec * specularLight[2]);
|
||||
if ( j > 255) j = 255;
|
||||
colors[i*4+2] = j;
|
||||
|
||||
|
@@ -4881,6 +4881,12 @@ static void CreateExternalShaders( void ) {
|
||||
tr.placeholderTextureAvail = 0;
|
||||
tr.placeholderModelAvail = 0;
|
||||
tr.placeholderAvail = 0;
|
||||
tr.placeholderSkyAvail = 0;
|
||||
tr.placeholderWaterAvail = 0;
|
||||
tr.placeholderLavaAvail = 0;
|
||||
tr.placeholderSlimeAvail = 0;
|
||||
tr.placeholderFogAvail = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4919,11 +4925,21 @@ static void CreateExternalShaders( void ) {
|
||||
// leilei - placeholder shaders
|
||||
tr.placeholderTextureShader = R_FindShader( "placeholder_texture", LIGHTMAP_NONE, qtrue );
|
||||
tr.placeholderModelShader = R_FindShader( "placeholder_model", LIGHTMAP_NONE, qtrue );
|
||||
tr.placeholderSkyShader = R_FindShader( "placeholder_sky_retro", LIGHTMAP_NONE, qtrue );
|
||||
tr.placeholderWaterShader = R_FindShader( "placeholder_water", LIGHTMAP_NONE, qtrue );
|
||||
tr.placeholderSlimeShader = R_FindShader( "placeholder_slime", LIGHTMAP_NONE, qtrue );
|
||||
tr.placeholderLavaShader = R_FindShader( "placeholder_lava", LIGHTMAP_NONE, qtrue );
|
||||
tr.placeholderFogShader = R_FindShader( "placeholder_fog", LIGHTMAP_NONE, qtrue );
|
||||
tr.placeholderShader = R_FindShader( "placeholder_model", LIGHTMAP_NONE, qtrue );
|
||||
|
||||
if(!tr.placeholderTextureShader->defaultShader) tr.placeholderTextureAvail = 1;
|
||||
if(!tr.placeholderModelShader->defaultShader) tr.placeholderModelAvail = 1;
|
||||
if(!tr.placeholderShader->defaultShader) tr.placeholderAvail = 1;
|
||||
if(!tr.placeholderSkyShader->defaultShader) tr.placeholderSkyAvail = 1;
|
||||
if(!tr.placeholderWaterShader->defaultShader) tr.placeholderWaterAvail = 1;
|
||||
if(!tr.placeholderLavaShader->defaultShader) tr.placeholderLavaAvail = 1;
|
||||
if(!tr.placeholderSlimeShader->defaultShader) tr.placeholderSlimeAvail = 1;
|
||||
if(!tr.placeholderFogShader->defaultShader) tr.placeholderFogAvail = 1;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ int tvMode; // leilei - tvmode
|
||||
int tvWidth;
|
||||
int tvHeight;
|
||||
int tvinterlace; // leilei - interlace value for height
|
||||
float tvAspectW; // leilei - for aspect correction
|
||||
|
||||
//int vresWidth;
|
||||
//int vresHeight;
|
||||
@@ -75,6 +76,7 @@ cvar_t *r_allowSoftwareGL; // Don't abort out if a hardware visual can't be obta
|
||||
cvar_t *r_tvMode; // leilei - tv mode - force 480i rendering, which is then stretched and interlaced
|
||||
cvar_t *r_tvConsoleMode; // leilei - tv mode
|
||||
cvar_t *r_tvModeAspect; // leilei - tv mode - to do widescreen and low res tv etc
|
||||
cvar_t *r_tvModeForceAspect; // leilei - tv mode - to force the screen into its native aspect
|
||||
cvar_t *r_motionblur; // leilei - moved here to set up accumulation bits
|
||||
cvar_t *r_allowResize; // make window resizable
|
||||
cvar_t *r_conMode; // leilei - console mode - force native resolutions of various consoles
|
||||
@@ -479,8 +481,11 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
|
||||
vresHeight = glConfig.vidHeight;
|
||||
|
||||
|
||||
|
||||
|
||||
vresWidth = 640;
|
||||
vresHeight = 480;
|
||||
//tvAspectW = 1.0; // no change
|
||||
|
||||
if( r_tvMode->integer ){
|
||||
|
||||
@@ -491,17 +496,42 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
|
||||
glConfig.vidHeight = 480;
|
||||
|
||||
|
||||
// leilei - make it use an aspect-corrected lower resolution that's always 640 wide for the width, but variable height
|
||||
if( r_tvModeAspect->integer ){
|
||||
float aspe = 640.0f / tvWidth;
|
||||
glConfig.vidWidth = tvWidth * aspe;
|
||||
glConfig.vidHeight = tvHeight * aspe;
|
||||
if( r_tvMode->integer == 96 ){
|
||||
glConfig.vidWidth = 320;
|
||||
glConfig.vidHeight = 200;
|
||||
}
|
||||
if( r_tvMode->integer == 97 ){
|
||||
glConfig.vidWidth = 320;
|
||||
glConfig.vidHeight = 240;
|
||||
}
|
||||
|
||||
}
|
||||
// leilei - make it use an aspect-corrected lower resolution that's always 640 wide for the width, but variable height
|
||||
|
||||
// then change the gl port..
|
||||
|
||||
vresWidth = tvWidth;
|
||||
vresHeight = tvHeight;
|
||||
|
||||
if( r_tvModeForceAspect->integer ){
|
||||
// glConfig.vidHeight = tvHeight * aspe;
|
||||
float thv = tvHeight / glConfig.vidHeight; // 720 / 480 = 1.5
|
||||
float thw = tvWidth / glConfig.vidWidth; // 1280 / 640 = 2
|
||||
float chv = glConfig.vidHeight / tvHeight; // 640 / 1280 = 0.5
|
||||
float chw = glConfig.vidHeight / tvWidth; // 480 / 720 = 0.66666666
|
||||
float chvw = tvHeight * chw; // 720 * 0.6666 = 480
|
||||
float chwv = tvWidth * chw; // 1280 * 0.6666 = 853
|
||||
//float ttw = glConfig.vidWidth / (tvWidth * chw); // 640 / 853 = 0.75 = ASPECT VALUE
|
||||
float ttw = (float)glConfig.vidWidth / ((float)tvWidth * (float)((float)glConfig.vidHeight/(float)tvHeight)); // 640 / 853 = 0.75 = ASPECT VALUE
|
||||
|
||||
//float tth = tvWidth * chv; // lower...
|
||||
// float ttw = glConfig.vidWidth / tth;
|
||||
//jj
|
||||
tvAspectW = ttw; // let's try this first to see if we can get it to our renderer
|
||||
|
||||
//tvAspectW = 0.75f; // let's try this first to see if we can get it to our renderer
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// leilei - tv mode hack end
|
||||
|
||||
@@ -533,6 +563,15 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
|
||||
screen = vidscreen;
|
||||
|
||||
|
||||
if( r_tvModeAspect->integer ){
|
||||
float aspe = 640.0f / tvWidth;
|
||||
glConfig.vidWidth = tvWidth * aspe;
|
||||
glConfig.vidHeight = tvHeight * aspe;
|
||||
|
||||
}
|
||||
// then change the gl port..
|
||||
|
||||
|
||||
|
||||
|
||||
glstring = (char *) qglGetString (GL_RENDERER);
|
||||
@@ -787,6 +826,7 @@ void GLimp_Init( void )
|
||||
// leilei - tv mode hack
|
||||
r_tvMode = ri.Cvar_Get( "r_tvMode", "0", CVAR_LATCH | CVAR_ARCHIVE );
|
||||
r_tvModeAspect = ri.Cvar_Get( "r_tvModeAspect", "0", CVAR_LATCH | CVAR_ARCHIVE ); // yes
|
||||
r_tvModeForceAspect = ri.Cvar_Get( "r_tvModeForceAspect", "0", CVAR_LATCH | CVAR_ARCHIVE ); // yes
|
||||
|
||||
r_tvConsoleMode = ri.Cvar_Get( "r_tvConsoleMode", "0", CVAR_LATCH | CVAR_ARCHIVE );
|
||||
|
||||
|
Reference in New Issue
Block a user