- Widescreen fixes, should expand on all viewsize values now and leave less refdefs alone

- Accumulation buffer motion blur, which should work on shader model 2 hardware with less memory footprint. Pixel shader moved to r_motionblur 3 (will do texture motionblur on 2)
- Tried to make r_tvMode 2 half vertical resolution, and failed.
- Q3MME's FX scripted particle system files, just dropped in there, because they can't compile at all atm. Procrastinplanning on integrating this to replace my cgame effects
This commit is contained in:
leilei-
2014-06-07 05:07:56 -04:00
parent 5451917a76
commit 1947afbe2e
10 changed files with 4693 additions and 33 deletions

488
code/client/fx_local.h Normal file
View File

@@ -0,0 +1,488 @@
/*
===========================================================================
Copyright (C) 2006 Sjoerd van der Berg ( harekiet @ gmail.com )
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// fx_local.h -- private fx definitions
#define FX_HASH_SHIFT 8
#define FX_HASH_SIZE ( 1 << FX_HASH_SHIFT )
#define FX_HASH_MASK (FX_HASH_SIZE - 1)
#define FX_ACTIVE_HASH_SHIFT 5
#define FX_ACTIVE_HASH_SIZE ( 1 << FX_ACTIVE_HASH_SHIFT )
#define FX_ACTIVE_HASH_MASK (FX_ACTIVE_HASH_SIZE - 1)
#define FX_MAX_SCRIPTS 4096
#define FX_MAX_ENTITIES (16*1024)
#define FX_EMIT_TRACE 0x001
#define FX_EMIT_SINK 0x002
#define FX_EMIT_MOVE 0x004
#define FX_EMIT_PARENT 0x010
#define FX_EMIT_IMPACT 0x020
#define FX_EMIT_MASKSIZE 16 //Probably enough space
#define FX_ENT_STATIONARY 0x001
#define FX_ENT_DEAD 0x002
#define FX_SCRIPT_PARENT 0x001
#define FX_STACK_SIZE 128
#define FX_VECTOR_PARENT 0x10000
#define FX_MASK_PARENT 0x00001
#define FX_MASK_ORIGIN 0x00002
#define FX_MASK_VELOCITY 0x00004
#define FX_MASK_SHADER 0x00008
#define FX_MASK_SIZE 0x00010
#define FX_MASK_ROTATE 0x00020
#define FX_MASK_COLOR 0x00040
#define FX_MASK_DIR 0x00080
#define FX_MASK_MODEL 0x00100
#define FX_MASK_AXIS 0x00200
#define FX_MASK_ANGLES 0x00400
#define FX_MASK_WIDTH 0x00800
#define FX_MASK_T0 0x01000
#define FX_MASK_T1 0x02000
#define FX_MASK_T2 0x04000
#define FX_MASK_T3 0x08000
#define FX_MASK_V0 0x10000
#define FX_MASK_V1 0x20000
#define FX_MASK_V2 0x40000
#define FX_MASK_V3 0x80000
struct fxHashEntry_s;
struct fxEntity_s;
struct fxInitScript_s;
typedef struct fxAtive_s {
struct fxAtive_s *next;
unsigned int key1, key2;
int beenUsed;
} fxActive_t;
typedef struct fxEntity_s {
struct fxEntity_s *next;
const fxRunEmitter_t *emitter;
int flags;
int startTime;
float traceTime;
float moveTime, lifeScale;
vec3_t origin, velocity;
} fxEntity_t;
//Making any changes to this order you'll also need to modify the mask/unpacking stuff
typedef struct {
vec3_t origin;
vec3_t velocity;
float size, rotate;
color4ub_t color;
qhandle_t shader;
vec3_t dir;
float width;
vec3_t angles;
qhandle_t model;
vec3_t axis[3];
float t0, t1, t2, t3;
vec3_t v0, v1, v2, v3;
const fxParent_t *parent;
float lerp;
float loop;
float life;
struct fxEntity_s *entity;
int shaderTime;
unsigned int key;
int stackUsed;
float stackData[FX_STACK_SIZE];
} fxRun_t;
const void *fxRunMath( fxRun_t *run, const void *data, float *value );
typedef const void *(*fxHandler_t)( fxRun_t *run, const void * );
static ID_INLINE const float *fxFloatSrc( const fxRun_t *run, int offset ) {
if ( offset & FX_VECTOR_PARENT)
return (float *) (((char *)run->parent) + (offset & ~FX_VECTOR_PARENT) );
else
return (float *) (((char *)run) + offset );
}
static ID_INLINE float *fxFloatDst( const fxRun_t *run, int offset ) {
return (float *) (((char *)run) + offset );
}
typedef enum {
fxCmdHalt,
fxCmdSkip,
fxCmdEmitter,
fxCmdKill,
fxCmdRepeat,
fxCmdOnce,
fxCmdIf,
fxCmdInterval,
fxCmdDistance,
fxCmdSprite,
fxCmdBeam,
fxCmdLight,
fxCmdDirModel,
fxCmdAnglesModel,
fxCmdAxisModel,
fxCmdQuad,
fxCmdRings,
fxCmdSpark,
fxCmdDecal,
fxCmdTrace,
fxCmdScript,
fxCmdColor,
fxCmdColorList,
fxCmdColorBlend,
fxCmdColorHue,
fxCmdColorScale,
fxCmdColorMath,
fxCmdColorFade,
fxCmdAlphaFade,
fxCmdShader,
fxCmdShaderList,
fxCmdModel,
fxCmdModelList,
fxCmdSound,
fxCmdSoundList,
fxCmdLoopSound,
fxCmdVibrate,
fxCmdPush,
fxCmdPop,
fxCmdPushParent,
fxCmdScale,
fxCmdCopy,
fxCmdAdd,
fxCmdAddScale,
fxCmdSub,
fxCmdSubScale,
fxCmdRotateAround,
fxCmdInverse,
fxCmdNormalize,
fxCmdPerpendicular,
fxCmdRandom,
fxCmdClear,
fxCmdWobble,
fxCmdMakeAngles,
fxCmdValue,
} fxCommand_t;
typedef struct {
int blockSize;
void *blockData;
} fxRunBlock_t;
typedef struct fxScript_s {
fxHandle_t handle;
struct fxHashEntry_s *entry;
struct fxScript_s *remap;
unsigned int readMask;
void *data[0];
} fxScript_t;
typedef struct {
int renderfx;
} fxRunRender_t;
typedef struct {
color4ub_t value;
} fxRunColor_t;
typedef struct {
unsigned int count;
} fxRunColorBlend_t;
typedef struct {
unsigned int count;
} fxRunColorList_t;
typedef struct {
float delay, scale;
} fxRunColorFade_t;
typedef struct {
unsigned int index;
} fxRunColorMath_t;
typedef struct {
color4ub_t value;
} fxRunAlpha_t;
typedef struct {
int size;
} fxRunAlphaScale_t;
typedef struct {
float delay, scale;
} fxRunAlphaFade_t;
typedef struct {
int size;
} fxRunRed_t;
typedef struct {
int size;
} fxRunGreen_t;
typedef struct {
int size;
} fxRunBlue_t;
typedef struct {
unsigned short flags;
unsigned short size;
unsigned short emitRun;
unsigned short impactRun;
unsigned short deathRun;
unsigned short allocSize;
byte mask[FX_EMIT_MASKSIZE];
float impactSpeed;
float bounceFactor;
float sinkDelay, sinkDepth;
float gravity;
} fxRunEmitter_t;
typedef struct {
int src;
int dst;
} fxRunScale_t;
typedef struct {
int src;
int dst;
} fxRunWobble_t;
typedef struct {
int src;
int dst;
} fxRunCopy_t;
typedef struct {
int src;
int dst;
} fxRunMakeAngles_t;
typedef struct {
int dst;
} fxRunClear_t;
typedef struct {
int src;
int dst;
} fxRunInverse_t;
typedef struct {
int src;
int dst;
} fxRunNormalize_t;
typedef struct {
int src1;
int src2;
int dst;
} fxRunAdd_t;
typedef struct {
int src1;
int src2;
int dst;
} fxRunSub_t;
typedef struct {
int src;
int scale;
int dst;
} fxRunAddScale_t;
typedef struct {
int src;
int scale;
int dst;
} fxRunSubScale_t;
typedef struct {
int src;
int dir;
int dst;
} fxRunRotateAround_t;
typedef struct {
int src;
int dst;
} fxRunPerpendicular_t;
typedef struct {
int dst;
} fxRunRandom_t;
typedef struct {
int dst;
} fxRunValue_t;
typedef struct {
qhandle_t shader;
} fxRunShader_t;
typedef struct {
unsigned int count;
} fxRunShaderList_t;
typedef struct {
qhandle_t model;
} fxRunModel_t;
typedef struct {
unsigned int count;
qhandle_t list[0];
} fxRunModelList_t;
typedef struct {
int flags;
int life;
} fxRunDecal_t;
typedef struct {
void *data;
} fxRunScript_t;
typedef struct {
int count;
int offset;
} fxRunPush_t;
typedef struct {
int count;
int offset;
} fxRunPushParent_t;
typedef struct {
int count;
int offset;
} fxRunPop_t;
typedef struct {
int size;
} fxRunRepeat_t;
typedef struct {
int size;
} fxRunOnce_t;
typedef struct {
int beenUsed;
} fxActiveOnce_t;
typedef struct {
int size;
} fxRunInterval_t;
typedef struct {
int beenUsed;
int nextTime;
} fxActiveInterval_t;
typedef struct {
int size;
} fxRunSkip_t;
typedef struct {
int testCount;
int elseStep;
int size;
} fxRunIf_t;
typedef struct {
int size;
} fxRunDistance_t;
typedef struct {
int beenUsed;
vec3_t lastOrigin;
float distance;
} fxActiveDistance_t;
typedef struct {
float strength;
} fxRunVibrate_t;
typedef struct {
unsigned int count;
sfxHandle_t handle[0];
} fxRunSoundList_t;
typedef struct {
sfxHandle_t handle;
} fxRunSound_t;
typedef struct {
sfxHandle_t handle;
} fxRunLoopSound_t;
typedef struct fxEntity_s {
struct fxEntity_s *next;
const fxRunEmitter_t *emitter;
int flags;
int startTime;
float traceTime;
float moveTime, lifeScale;
vec3_t origin, velocity;
} fxEntity_t;
/* Just gonna stick with using next for now */
typedef struct fxHashEntry_s {
const char *name;
const char *text;
fxScript_t *script;
struct fxHashEntry_s *next;
} fxHashEntry_t;
#define FX_VIBRATE_QUEUE 32
typedef struct {
fxScript_t *scripts[FX_MAX_SCRIPTS];
fxHashEntry_t *entryHash[FX_HASH_SIZE];
fxActive_t *activeHash[FX_ACTIVE_HASH_SIZE];
int scriptCount;
int *allocSearch;
int *allocStart;
int allocSize;
int time, oldTime;
float timeFraction;
float deltaTime;
int seed;
fxEntity_t *entityActive;
fxEntity_t *entityNew;
struct {
int entitySize, activeSize;
int entityCount, activeCount;
} last;
struct {
int used, time;
float offset, magnitude;
struct {
vec3_t origin;
float strength;
} queue[FX_VIBRATE_QUEUE];
} vibrate;
struct {
fxHashEntry_t *entries;
} alloc;
} fxMain_t;
void fxInitParser( void );
void fxFreeMemory( void );
extern cvar_t *fx_Debug;
extern cvar_t *fx_Override;

1569
code/client/fx_main.c Normal file

File diff suppressed because it is too large Load Diff

2390
code/client/fx_parse.c Normal file

File diff suppressed because it is too large Load Diff

35
code/client/fx_public.h Normal file
View File

@@ -0,0 +1,35 @@
/*
===========================================================================
Copyright (C) 2006 Sjoerd van der Berg ( harekiet @ gmail.com )
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// fx_public.h -- public fx definitions
#include "fx_types.h"
void FX_Init( void );
void FX_Shutdown( void );
fxHandle_t FX_Register( const char *name );
void FX_Debug( void );
void FX_Reset( void );
void FX_Begin( int time, float fraction );
void FX_End( void );
void FX_Run( fxHandle_t handle, const fxParent_t *parent, unsigned int key );
void FX_VibrateView( float scale, vec3_t origin, vec3_t angles );

51
code/client/fx_types.h Normal file
View File

@@ -0,0 +1,51 @@
/*
===========================================================================
Copyright (C) 2006 Sjoerd van der Berg ( harekiet @ gmail.com )
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// fx_types.h -- shared fx types
typedef int fxHandle_t;
#define FXP_ORIGIN 0x0001
#define FXP_VELOCITY 0x0002
#define FXP_DIR 0x0004
#define FXP_ANGLES 0x0008
#define FXP_SIZE 0x0010
#define FXP_WIDTH 0x0020
#define FXP_COLOR 0x0040
#define FXP_SHADER 0x0080
#define FXP_MODEL 0x0100
#define FXP_AXIS 0x0200
#define FXP_LIFE 0x0400
typedef struct {
int flags;
vec3_t origin;
vec3_t velocity;
vec3_t dir;
color4ub_t color;
qhandle_t shader;
float life;
float size;
float width;
qhandle_t model;
vec3_t angles;
vec3_t axis[3];
color4ub_t color2;
} fxParent_t;

View File

@@ -1089,23 +1089,11 @@ extern int tvWidth;
extern int tvHeight;
void RB_SetGL2D (void) {
backEnd.projection2D = qtrue;
// set 2D virtual screen size
if (r_tvMode->integer)
{
qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity ();
qglOrtho (0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1);
qglMatrixMode(GL_MODELVIEW);
qglLoadIdentity ();
}
else
{
qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
@@ -1114,7 +1102,7 @@ void RB_SetGL2D (void) {
qglOrtho (0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1);
qglMatrixMode(GL_MODELVIEW);
qglLoadIdentity ();
}
qglGetFloatv(GL_PROJECTION_MATRIX, glState.currentProjectionMatrix);
qglGetFloatv(GL_MODELVIEW_MATRIX, glState.currentModelViewMatrix);
@@ -1562,6 +1550,71 @@ void RB_UpdateMotionBlur (void){
float mtime; // motion blur frame time
//
// leilei - accumulation buffer-based motion blur, a much more legacy technique
// code addapted from MH's "Quake motion blur" thread (which is intended for GLQuake)
// but made to work with our cvars relating to the crappy pixel shader'd motion blur
// i coded on a whim one day.
//
float mblur_time;
float mblur_timelast;
float time_now;
float time_last;
float mbluracc;
void RB_AccumBlurValue (void)
{
// calculate how much we need, determined by motion blur fps
mblur_time = time_now - time_last;
mbluracc = (mblur_time) / 32;
mbluracc *= -1;
mbluracc += 1.0f;
mbluracc /= 2;
};
void RB_DrawAccumBlur (void)
{
static int blurstate = 0;
float accblur;
static float damagetime = -1.0f;
if (r_tvMode->integer) return; // tvmode causes this to crash
if (!r_motionblur->integer) return;
if (r_motionblur->integer > 1) return; // don't do it for the other motion blur techniques
RB_AccumBlurValue ();
accblur = mbluracc;
//ri.Printf( PRINT_WARNING, "accum value %f\n", mbluracc );
if (accblur > 1.0f)
accblur = 0.5f;
if (accblur <= 0.0f)
{
// reinit if we're not blurring so that the contents of the
// accumulation buffer are valid for the frame
blurstate = 0;
return;
}
if (!blurstate)
{
// load the scene into the accumulation buffer
qglAccum (GL_LOAD, 1.0f);
}
else
{
qglAccum (GL_MULT, accblur); // scale contents of accumulation buffer
qglAccum (GL_ACCUM, 1.0f - accblur); // add screen contents
qglAccum (GL_RETURN, 1.0f); // read result back
}
blurstate = 1;
}
/*
=============
RB_SwapBuffers
@@ -1571,14 +1624,14 @@ RB_SwapBuffers
const void *RB_SwapBuffers( const void *data ) {
const swapBuffersCommand_t *cmd;
// finish any 2D drawing if needed
if ( tess.numIndexes ) {
RB_EndSurface();
}
if (r_motionblur->integer){
if (r_motionblur->integer > 2){
{
mtime = backEnd.refdef.time + (1000.0f / r_motionblur_fps->integer);
mblurred = 0;
@@ -1586,6 +1639,7 @@ const void *RB_SwapBuffers( const void *data ) {
}
}
// texture swapping test
if ( r_showImages->integer ) {
RB_ShowImages();
@@ -1600,7 +1654,9 @@ const void *RB_SwapBuffers( const void *data ) {
}
if (r_motionblur->integer == 1){
RB_DrawAccumBlur ();
}
R_BrightScreen(); // leilei - alternate brightness - do it here so we hit evereything
R_RetroAAScreen(); // leilei - then apply 'anti aliasing'
R_TVScreen(); // leilei - tv operation comes last, this is a SCREEN
@@ -1678,7 +1734,7 @@ const void *RB_SwapBuffers( const void *data ) {
time_last = backEnd.refdef.time;
return (const void *)(cmd + 1);
}
@@ -1691,7 +1747,7 @@ void RB_ExecuteRenderCommands( const void *data ) {
int t1, t2;
t1 = ri.Milliseconds ();
time_now = t1;
while ( 1 ) {
data = PADP(data, sizeof(void *));

View File

@@ -367,14 +367,28 @@ R_Postprocess_InitTextures
static void R_Postprocess_InitTextures( void )
{
byte *data;
int vidinted = glConfig.vidHeight * 0.55f;
int intdiv = 1;
force32upload = 1;
// find closer power of 2 to screen size
for (postproc.screen.width = 1;postproc.screen.width< glConfig.vidWidth;postproc.screen.width *= 2);
if (r_tvMode->integer > 1) // interlaced
for (postproc.screen.height = 1;postproc.screen.height < vidinted;postproc.screen.height *= 2);
else
for (postproc.screen.height = 1;postproc.screen.height < glConfig.vidHeight;postproc.screen.height *= 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;
// find closer power of 2 to effect size
postproc.work.width = r_bloom_sample_size->integer;
postproc.work.height = postproc.work.width * ( glConfig.vidWidth / glConfig.vidHeight );
@@ -385,6 +399,8 @@ static void R_Postprocess_InitTextures( void )
postproc.effect.readW = postproc.work.width / (float)postproc.effect.width;
postproc.effect.readH = postproc.work.height / (float)postproc.effect.height;
postproc.screen.readH /= intdiv; // interlacey
postproc.effect.readH /= intdiv; // interlacey
// disable blooms if we can't handle a texture of that size
if( postproc.screen.width > glConfig.maxTextureSize ||
@@ -433,7 +449,7 @@ static void R_Postprocess_InitTextures( void )
// leilei - motion blur textures!
if (r_motionblur->integer){
if (r_motionblur->integer > 2){
data = ri.Hunk_AllocateTempMemory( postproc.screen.width * postproc.screen.height * 4 );
Com_Memset( data, 0, postproc.screen.width * postproc.screen.height * 4 );
postproc.motion1.texture = R_CreateImage( "***motionblur1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE );
@@ -776,15 +792,34 @@ static void R_Postprocess_BackupScreen( void ) {
static void R_Postprocess_BackupScreenTV( void ) {
int intdiv;
if (r_tvMode->integer > 1) intdiv = 2;
else intdiv = 1;
GL_TexEnv( GL_MODULATE );
qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
qglMatrixMode( GL_PROJECTION );
qglLoadIdentity ();
qglOrtho( 0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1 );
qglMatrixMode( GL_MODELVIEW );
qglLoadIdentity ();
GL_Bind( postproc.screen.texture );
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, tvinter, glConfig.vidWidth, glConfig.vidHeight);
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight);
//qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, 320, 240);
}
// leilei - motion blur hack
void R_MotionBlur_BackupScreen(int which) {
if( !r_motionblur->integer)
if( r_motionblur->integer < 3)
return;
if (which == 1){ GL_Bind( postproc.motion1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // gather thee samples
if (which == 2){ GL_Bind( postproc.motion2.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); }
@@ -887,7 +922,7 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) {
GL_Bind( postproc.depth.texture );
// motion blur crap
if( r_motionblur->integer){
if( r_motionblur->integer > 2){
if (program->u_mpasses > -1) R_GLSL_SetUniform_u_mpasses(program, mpasses);
GL_SelectTexture(2);
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
@@ -1282,8 +1317,11 @@ void R_TVScreen( void )
return;
}
if ( !backEnd.projection2D )
RB_SetGL2D();
// if ( !backEnd.projection2D )
// RB_SetGL2D();
force32upload = 1;
// postprocess = 1;
@@ -1295,11 +1333,11 @@ void R_TVScreen( void )
tvinter = tvinterlace;
if (tvinter < 0) tvinter = 0;
if (r_tvMode->integer < 3) tvinter = 0;
if (r_tvMode->integer < 2) tvinter = 0;
leifxmode = 1234; // just show it through to tvWidth/tvHeight
if (r_tvMode->integer == 2)
if (r_tvMode->integer > 2)
leifxmode = 1236; // run it through a shader
//R_Postprocess_BackupScreen();
R_Postprocess_BackupScreenTV();
@@ -1387,7 +1425,7 @@ void R_AnimeScreen( void )
void R_MblurScreen( void )
{
if( !r_motionblur->integer)
if( r_motionblur->integer < 3)
return;
if ( backEnd.donemblur)
return;
@@ -1414,7 +1452,7 @@ void R_MblurScreen( void )
void R_MblurScreenPost( void )
{
if( !r_motionblur->integer)
if( r_motionblur->integer < 3)
return;
if ( !backEnd.doneSurfaces )
return;

View File

@@ -204,7 +204,7 @@ cvar_t *r_leidebugeye; // Leilei - eye debug
cvar_t *r_suggestiveThemes; // leilei - mature content control
cvar_t *r_motionblur; // Leilei - motionblur
//cvar_t *r_motionblur; // Leilei - motionblur
cvar_t *r_motionblur_fps; // Leilei - motionblur framerated
cvar_t *r_slowness; // Leilei - the cvar that slows everything down. use with caution.
@@ -214,7 +214,7 @@ cvar_t *r_slowness_gpu; // Leilei
// leilei - fallback shader hack
#include "tr_leiglsl.h"
#ifdef USE_FALLBACK_GLSL
@@ -1258,7 +1258,7 @@ void R_Register( void )
r_suggestiveThemes = ri.Cvar_Get( "r_suggestiveThemes", "1" , CVAR_ARCHIVE | CVAR_LATCH);
r_motionblur = ri.Cvar_Get( "r_motionblur", "0" , CVAR_ARCHIVE | CVAR_LATCH);
// r_motionblur = ri.Cvar_Get( "r_motionblur", "0" , CVAR_ARCHIVE | CVAR_LATCH);
r_motionblur_fps = ri.Cvar_Get( "r_motionblur_fps", "60", 0);
r_anime = ri.Cvar_Get( "r_anime", "0" , CVAR_ARCHIVE | CVAR_LATCH);

View File

@@ -394,9 +394,19 @@ void RE_RenderScene( const refdef_t *fd ) {
// recalculate fov according to widescreen parameters
{
float zoomfov = tr.refdef.fov_x / 90; // figure out our zoom or changed fov magnitiude from cg_fov and cg_zoomfov
int thisisit;
// find aspect to immediately match our vidwidth for perfect match with resized screens...
float erspact = tr.refdef.width / tr.refdef.height;
float aspact = glConfig.vidWidth / glConfig.vidHeight;
if (erspact == aspact) thisisit = 1;
// try not to recalculate fov of ui and hud elements
if (((tr.refdef.fov_x / tr.refdef.fov_y) > 1.3) && (tr.refdef.width > 320) && (tr.refdef.height > 240))
//if (((tr.refdef.fov_x / tr.refdef.fov_y) > 1.3) && (tr.refdef.width > 320) && (tr.refdef.height > 240))
//if (((tr.refdef.fov_x / tr.refdef.fov_y) > 1.3) && (tr.refdef.width > (320 * refdefscalex)) && (tr.refdef.height > (240 * refdefscaley)))
if (((tr.refdef.fov_x / tr.refdef.fov_y) > 1.3) && (thisisit))
{
// undo vert-
parms.fovY = parms.fovY * (73.739792 / tr.refdef.fov_y) * zoomfov;

View File

@@ -52,6 +52,7 @@ static QGLContext opengl_context;
int tvMode; // leilei - tvmode
int tvWidth;
int tvHeight;
int tvinterlace; // leilei - interlace value for height
typedef enum
{
@@ -69,6 +70,7 @@ static const SDL_VideoInfo *videoInfo = NULL;
cvar_t *r_allowSoftwareGL; // Don't abort out if a hardware visual can't be obtained
cvar_t *r_tvMode; // leilei - tv mode - force 480i rendering, which is then stretched and interlaced
cvar_t *r_tvModeAspect; // leilei - tv mode - to do widescreen and low res tv etc
cvar_t *r_motionblur; // leilei - moved here to set up accumulation bits
cvar_t *r_allowResize; // make window resizable
cvar_t *r_centerWindow;
cvar_t *r_sdlDriver;
@@ -202,6 +204,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
int sdlcolorbits;
int colorbits, depthbits, stencilbits;
int tcolorbits, tdepthbits, tstencilbits;
int accumbits, taccumbits; // leilei - motionblur
int samples;
int i = 0;
SDL_Surface *vidscreen = NULL;
@@ -293,6 +296,12 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
stencilbits = r_stencilbits->value;
samples = r_ext_multisample->value;
// leilei - motion blur via accumulation buffer support
if (r_motionblur->integer == 1)
accumbits = 16;
else
accumbits = 0;
for (i = 0; i < 16; i++)
{
// 0 - default
@@ -324,6 +333,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
tcolorbits = colorbits;
tdepthbits = depthbits;
tstencilbits = stencilbits;
taccumbits = accumbits;
if ((i % 4) == 3)
{ // reduce colorbits
@@ -367,6 +377,12 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, tdepthbits );
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, tstencilbits );
// leilei - accumulation buffer motion blur
SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, accumbits );
SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, accumbits );
SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, accumbits );
SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, accumbits );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, samples ? 1 : 0 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, samples );
@@ -455,10 +471,13 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
if( r_tvMode->integer ){
// HIJACKED >:)
glConfig.vidWidth = 640;
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;
@@ -728,6 +747,10 @@ 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
// leilei - move motionblur cvar here to get it to not upset the other renderers when setting up an accumulation buffer
r_motionblur = ri.Cvar_Get( "r_motionblur", "0", CVAR_LATCH | CVAR_ARCHIVE );
if( ri.Cvar_VariableIntegerValue( "com_abnormalExit" ) )
{
ri.Cvar_Set( "r_mode", va( "%d", R_MODE_FALLBACK ) );