A bunch of things

- s_interrupt - allows sounds to be interrupted by the same sound or entity channel
- new dynamic light calculation for vertex lighting, affecting vertex color (no projected dlight textures)
- rgbGen material for allowing calculation for diffuse, specular, emmissive vertex colors by hex values
- rgbMod shader command allowing new vertex color effects
- removed deprecated R_ParseStageSimple, it never worked as intended
- r_slowness gone. Use llvmpipe, PCem, or a slow computer instead.
- Spring cleaning of old deprecated/broken post-process GLSL experiments
- r_anime broke in 2015
- r_tvMode - well, shaderglass exists now
- r_motionblur - Bad technique, too much memory
- t_pslettize - slow, relies on shader's lookup of a vector table
- r_film - bad on well-lit maps
- r_retroAA - this broke early too. also looked bad. would rather implement FSAA 4x
- cl_consoleScale : makes the console more 640x480 sized on any higher res. Also affects notify messages, so you can read chat easier
- cl_consoleColor also affects the line at the bottom. Also new default colors
- If consoleShader can't load (which will happen with some mods), it will fallback to a flat-colored console.
- Generic'd the red/blue team names.  We will not be having missionpack clans.
- SDL2: Clicking the red X now does something: you can leave!!! If it sucks.... hit da bricks!! real winners quit
- s_xmp_startPattern - makes the tracker song play a different pattern (for use with sub-songs)
- fixed xmp playback as xmp explicitly requires a length of the module now. Fixes issue #96
- suppress the warning about non-22khz music, as mods are playing at the mixer's rate always, and this warning regards a much earlier (1999) unstable sound mixer.
- deprecating r_modelshader because the shader got stale, old, buggy, and amd hates it now
- r_shadeMethod will be something else (and not shader-based)
- r_lightmapColorNorm : Make normalization of bright luxels an option, default is 1 (q3 behavior).
- r_lightmapColorNorm 0 = no normalization, straight clamp, like Nightdive's vision of Quake2
- r_lightmapColorNorm 2 = experiment: normalize, but add some luminance on while maintaining the hue by normalizing again. This tries to restore more range on fully saturated colors
- dropped SHADER_MAX_VERTEXES back to 1000 because raising it causes various unexpected issues, so dialing it down for now
- raise MAX_IMAGE_ANIMATIONS to 16 because I've got a cool water shader using it and 8 is too choppy
- Crash fix for older (<=2001) mods by trimming the string shared with ui module, so no overflow for them
- jettisoning old proposed mme particle system that was never ever hooked up properly.
- other small warning cleanup
- r_shadeMethod : 0/1 = q3 behavior, 2 = ue1-ish behavior, 3 = mix of 1 and 2, -1 = one uniform color, 150-666 = a lod range to change between the 3
- r_monolightmaps : refactor - goes to the light data instead of the calculations and images
- removed r_greyscale because this is a data-modifying novelty that would complicate support for loading compressed texture formats. This is better off as a post-process shader
- environment mapping refactor, rewrite and cleanup
- removed a lot of deprecated rgbGens
- removed r_texdump (it never worked)
- remove a few leftover broken postprocess things
- Internal GLSL brightness shader, so gamma control can work without the glsl/brightness_fp.glsl file when r_ext_vertex_shader is 1 and r_alternateBrightness is 2.
- r_skyTess - an attempt to make the complexity of skydomes an option so it could use less polygons. Has no effect on skyboxes
This commit is contained in:
leilei-
2025-05-20 06:30:51 -04:00
committed by GitHub
parent 74046d7a5c
commit 513c538fba
32 changed files with 1617 additions and 8090 deletions

View File

@@ -517,6 +517,8 @@ DRAWING
==============================================================================
*/
extern cvar_t *cl_consoleScale; // leilei - scale the console
/*
================
@@ -536,7 +538,7 @@ void Con_DrawInput (void) {
re.SetColor( con.color );
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' );
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' ,2);
Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y,
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue );
@@ -587,7 +589,7 @@ void Con_DrawNotify (void)
currentColor = (text[x]>>8) % NUMBER_OF_COLORS;
re.SetColor( g_color_table[currentColor] );
}
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff );
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff ,2);
}
v += SMALLCHAR_HEIGHT;
@@ -636,6 +638,17 @@ void Con_DrawSolidConsole( float frac ) {
int currentColor;
vec4_t color;
if (cl_consoleScale->integer && (cls.glconfig.vidWidth > SCREEN_WIDTH))
{
lines = SCREEN_HEIGHT * frac;
if (lines <= 0)
return;
if (lines > SCREEN_HEIGHT )
lines = SCREEN_HEIGHT;
}
else
{
lines = cls.glconfig.vidHeight * frac;
if (lines <= 0)
return;
@@ -646,6 +659,7 @@ void Con_DrawSolidConsole( float frac ) {
// on wide screens, we will center the text
con.xadjust = 0;
SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL );
}
// draw the background
y = frac * SCREEN_HEIGHT;
@@ -667,9 +681,31 @@ void Con_DrawSolidConsole( float frac ) {
}
}
color[0] = 1;
color[1] = 0;
color[2] = 0;
// leilei - normalize our custom color for the line
//color[0] = 1;
//color[1] = 0; // was 1 pre-1.25
//color[2] = 0;
// leilei - normalize from our custom console color and apply it to the line
{
float max;
float rgb[3];
rgb[0] = cl_consoleColor[0]->value;
rgb[1] = cl_consoleColor[1]->value;
rgb[2] = cl_consoleColor[2]->value;
max = rgb[0] + rgb[1] + rgb[2] / 3;
if (max > 0)
{
color[0] = rgb[0] / max;
color[1] = rgb[1] / max;
color[2] = rgb[2] / max;
}
}
if( !cl_consoleType->integer )
color[3] = 1;
SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color );
@@ -677,14 +713,24 @@ void Con_DrawSolidConsole( float frac ) {
// draw the version number
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
re.SetColor( g_color_table[ColorIndex(cl_consoleAccent->integer)] );
i = strlen( Q3_VERSION );
for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x] );
if (cl_consoleScale->integer && (cls.glconfig.vidWidth > SCREEN_WIDTH)){
for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( SCREEN_WIDTH - ( i - x + 1 ) * SMALLCHAR_WIDTH,
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x], 1 );
}
}
else
{
for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x], 0 );
}
}
// draw the text
@@ -697,9 +743,9 @@ void Con_DrawSolidConsole( float frac ) {
if (con.display != con.current)
{
// draw arrows to show the buffer is backscrolled
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
re.SetColor( g_color_table[ColorIndex(cl_consoleAccent->integer)] );
for (x=0 ; x<con.linewidth ; x+=4)
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' );
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' ,2);
y -= SMALLCHAR_HEIGHT;
rows--;
}
@@ -733,7 +779,7 @@ void Con_DrawSolidConsole( float frac ) {
currentColor = (text[x]>>8) % NUMBER_OF_COLORS;
re.SetColor( g_color_table[currentColor] );
}
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff );
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff, 2 );
}
}

View File

@@ -378,7 +378,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
i = drawLen - strlen( str );
if ( size == SMALLCHAR_WIDTH ) {
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar, 2 );
} else {
str[0] = cursorChar;
str[1] = 0;

View File

@@ -124,6 +124,8 @@ cvar_t *cl_consoleType;
cvar_t *cl_consoleColor[4];
cvar_t *cl_consoleHeight;
cvar_t *cl_consoleAccent; // leilei - change version and line color
cvar_t *cl_consoleScale; // leilei - scale the console
clientActive_t cl;
clientConnection_t clc;
@@ -3115,6 +3117,11 @@ void CL_InitRenderer( void ) {
cls.charSetShader = re.RegisterShader( "gfx/2d/bigchars" );
cls.whiteShader = re.RegisterShader( "white" );
cls.consoleShader = re.RegisterShader( "console" );
if (!cls.consoleShader) // leilei - fallback console type if it fails
{
Cvar_Set("cl_consoleType", "2");
Com_Printf( "Console shader failed to load, falling back to simple console\n");
}
g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2;
g_consoleField.widthInChars = g_console_field_width;
}
@@ -3552,12 +3559,14 @@ void CL_Init( void ) {
cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE);
cl_consoleType = Cvar_Get( "cl_consoleType", "0", CVAR_ARCHIVE );
cl_consoleColor[0] = Cvar_Get( "cl_consoleColorRed", "1", CVAR_ARCHIVE );
cl_consoleColor[1] = Cvar_Get( "cl_consoleColorGreen", "0", CVAR_ARCHIVE );
cl_consoleColor[2] = Cvar_Get( "cl_consoleColorBlue", "0", CVAR_ARCHIVE );
cl_consoleColor[0] = Cvar_Get( "cl_consoleColorRed", "0.104", CVAR_ARCHIVE );
cl_consoleColor[1] = Cvar_Get( "cl_consoleColorGreen", "0.187", CVAR_ARCHIVE );
cl_consoleColor[2] = Cvar_Get( "cl_consoleColorBlue", "0.312", CVAR_ARCHIVE );
cl_consoleColor[3] = Cvar_Get( "cl_consoleColorAlpha", "0.8", CVAR_ARCHIVE );
cl_consoleHeight = Cvar_Get("cl_consoleHeight", "0.5", CVAR_ARCHIVE);
cl_consoleAccent = Cvar_Get("cl_consoleAccent", "61" , CVAR_ARCHIVE); // leilei - change version and scroll color
cl_consoleScale = Cvar_Get ("cl_consoleScale" , "1" , CVAR_ARCHIVE); // leilei - console/notify text scale
// userinfo
Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE );
@@ -3567,8 +3576,8 @@ void CL_Init( void ) {
Cvar_Get ("headmodel", "sarge", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("team_model", "james", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("team_headmodel", "*james", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("g_redTeam", "Stroggs", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("g_blueTeam", "Pagans", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("g_redTeam", "Red", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("g_blueTeam", "Blue", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("color1", "4", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("color2", "5", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("handicap", "100", CVAR_USERINFO | CVAR_ARCHIVE );

View File

@@ -84,6 +84,35 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) {
}
}
/*
================
SCR_AdjustFrom480
leilei - Adjusted for resolution and screen aspect ratio.... but from vertical only so the aspect is ok
================
*/
void SCR_AdjustFrom480( float *x, float *y, float *w, float *h ) {
float yscale;
// scale for screen sizes
yscale = cls.glconfig.vidHeight / 480.0;
if ( x ) {
*x *= yscale;
}
if ( y ) {
*y *= yscale;
}
if ( w ) {
*w *= yscale;
}
if ( h ) {
*h *= yscale;
}
}
/*
================
SCR_FillRect
@@ -157,32 +186,78 @@ static void SCR_DrawChar( int x, int y, float size, int ch ) {
** SCR_DrawSmallChar
** small chars are drawn at native screen resolution
*/
void SCR_DrawSmallChar( int x, int y, int ch ) {
void SCR_DrawSmallChar( int x, int y, int ch, int scalemode ) {
int row, col;
float frow, fcol;
float size;
ch &= 255;
if ((scalemode) && (cl_consoleScale->integer) && (cls.glconfig.vidWidth > SCREEN_WIDTH))
{
// leilei - ideally, I want to have the same amount of lines as 640x480 on any higher resolution to keep it readable,
// while horizontally it's also like 640x480 but keeping up a gap to the right so the characters are still 1:2 aspect.
// like idTech 4.
// in 640x480 on a normal pulled down console, there are 12 lines, 6.5 lines on a half pull, and 29 for a full console
int row, col;
float frow, fcol;
float ax, ay, aw, ah;
float size;
ch &= 255;
if ( ch == ' ' ) {
return;
}
if ( y < -SMALLCHAR_HEIGHT ) {
return;
}
ax = x;
ay = y;
aw = SMALLCHAR_WIDTH ;
ah = SMALLCHAR_HEIGHT;
if (scalemode == 2)
SCR_AdjustFrom480( &ax, &ay, &aw, &ah );
else
SCR_AdjustFrom640( &ax, &ay, &aw, &ah );
if ( ch == ' ' ) {
return;
row = ch>>4;
col = ch&15;
frow = row*0.0625;
fcol = col*0.0625;
size = 0.0625;
re.DrawStretchPic( ax, ay, aw, ah,
fcol, frow,
fcol + size, frow + size,
cls.charSetShader );
}
if ( y < -SMALLCHAR_HEIGHT ) {
return;
else
{
ch &= 255;
if ( ch == ' ' ) {
return;
}
if ( y < -SMALLCHAR_HEIGHT ) {
return;
}
row = ch>>4;
col = ch&15;
frow = row*0.0625;
fcol = col*0.0625;
size = 0.0625;
re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
fcol, frow,
fcol + size, frow + size,
cls.charSetShader );
}
row = ch>>4;
col = ch&15;
frow = row*0.0625;
fcol = col*0.0625;
size = 0.0625;
re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
fcol, frow,
fcol + size, frow + size,
cls.charSetShader );
}
@@ -286,7 +361,7 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
continue;
}
}
SCR_DrawSmallChar( xx, y, *s );
SCR_DrawSmallChar( xx, y, *s, 2 );
xx += SMALLCHAR_WIDTH;
s++;
}

View File

@@ -433,6 +433,9 @@ extern cvar_t *cl_consoleKeys;
extern cvar_t *cl_consoleType;
extern cvar_t *cl_consoleColor[4];
extern cvar_t *cl_consoleScale;
extern cvar_t *cl_consoleAccent;
extern cvar_t *cl_consoleHeight;
#ifdef USE_MUMBLE
@@ -582,7 +585,7 @@ void SCR_DrawNamedPic( float x, float y, float width, float height, const char *
void SCR_DrawBigString( int x, int y, const char *s, float alpha, qboolean noColorEscape ); // draws a string with embedded color control characters with fade
void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color, qboolean noColorEscape ); // ignores embedded color control characters
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape );
void SCR_DrawSmallChar( int x, int y, int ch );
void SCR_DrawSmallChar( int x, int y, int ch, int scalemode );
//

View File

@@ -1,476 +0,0 @@
/*
===========================================================================
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;
//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;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,35 +0,0 @@
/*
===========================================================================
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 );

View File

@@ -1,51 +0,0 @@
/*
===========================================================================
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

@@ -43,7 +43,10 @@ void sound_deinit(void);
static float fadey;
extern cvar_t *s_xmp_startPattern;
static int startpat;
static int gopat;
extern int samplingrate; // from snd_dma
void S_XMP_StartSong ( void )
@@ -58,6 +61,29 @@ void S_XMP_EndSong ( void )
}
// TODO: A callback to set this appropriately from game context (monster sight, level triggers)
void S_XMP_CheckForFade ( void )
{
gopat = s_xmp_startPattern->integer;
if ((gopat != startpat))
{
fadey -= 0.025f;
// Com_Printf("AHHHFADING TO PATTERN %i!!! %f\n", startpat, fadey);
xmp_set_player(xmpsong, XMP_PLAYER_VOLUME, (fadey * 128));
}
if ((startpat != gopat) && (fadey < 0.01))
{
startpat = gopat;
xmp_set_position(xmpsong, startpat);
xmp_set_player(xmpsong, XMP_PLAYER_VOLUME, 128);
fadey = 1;
}
}
int aintistreaming = 0;
@@ -79,7 +105,7 @@ S_XMP_CodecOpenStream
=================
*/
// FIXME: there's a memory leak here if you start the same song many many many many times.
// FIXME: there's a memory leak here if you start the same song many many many many times?
snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
{
// First let's close whatever song we had....
@@ -123,14 +149,21 @@ snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
xmpsong = xmp_create_context();
int itsloaded = 0;
itsloaded = xmp_load_module_from_memory(xmpsong, buffer, 0);
itsloaded = xmp_load_module_from_memory(xmpsong, buffer, thelength);
// Free our memory and close the file.
Hunk_FreeTempMemory(buffer);
FS_FCloseFile(file); // unfortunately these do not help with the leak
if (itsloaded == 0)
itsloaded = xmp_start_player(xmpsong, xmpspeed, 0); // TODO: do sample rate of the mixer.
{
itsloaded = xmp_start_player(xmpsong, xmpspeed, 0);
startpat=s_xmp_startPattern->integer;
gopat = startpat;
fadey = 1.0;
xmp_set_player(xmpsong, XMP_PLAYER_VOLUME, 128);
xmp_set_position(xmpsong, startpat);
}
if (itsloaded == 0) {
// Com_Printf("XMP loaded our buffer of the file %s which is %i long \n", filename, thelength);
@@ -197,6 +230,8 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
return 0;
}
S_XMP_CheckForFade();
return bytes;
}

View File

@@ -576,6 +576,30 @@ static void S_Base_StartSoundEx( vec3_t origin, int entityNum, int entchannel, s
}
ch = s_channels;
// leilei - check if this sound is already playing and kill it
if (s_interrupts->integer == 1)
{
for ( i = 0; i < MAX_CHANNELS ; i++, ch++ ) {
if (ch->entnum == entityNum && ch->thesfx == sfx)
{
S_ChannelFree(ch);
}
}
}
// leilei - check if this channel is being used, and kill that too
else if (s_interrupts->integer == 2)
{
for ( i = 0; i < MAX_CHANNELS ; i++, ch++ ) {
if (ch->entnum == entityNum && ch->entchannel == entchannel && ch->thesfx && (entchannel != CHAN_AUTO))
{
S_ChannelFree(ch);
}
}
}
inplay = 0;
for ( i = 0; i < MAX_CHANNELS ; i++, ch++ ) {
if (ch->entnum == entityNum && ch->thesfx == sfx) {
@@ -1408,9 +1432,11 @@ static void S_OpenBackgroundStream( const char *filename ) {
return;
}
if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", filename );
}
// leilei - commented out, as we have music beyond this rate, and this warning is meant for an older
// iteration of q3's sound engine that couldn't handle other rates.
// if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
// Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", filename );
// }
}

View File

@@ -199,6 +199,8 @@ extern cvar_t *s_musicVolume;
extern cvar_t *s_muted;
extern cvar_t *s_doppler;
extern cvar_t *s_interrupts;
extern cvar_t *s_testsound;
qboolean S_LoadSound( sfx_t *sfx );
@@ -239,6 +241,8 @@ extern short *sfxScratchBuffer;
extern sfx_t *sfxScratchPointer;
extern int sfxScratchIndex;
extern cvar_t *s_xmp_startPattern;
qboolean S_Base_Init( soundInterface_t *si );
// OpenAL stuff

View File

@@ -34,6 +34,9 @@ cvar_t *s_backend;
cvar_t *s_muteWhenMinimized;
cvar_t *s_muteWhenUnfocused;
cvar_t *s_interrupts;
cvar_t *s_xmp_startPattern;
static soundInterface_t si;
/*
@@ -485,9 +488,10 @@ void S_Init( void )
s_muted = Cvar_Get("s_muted", "0", CVAR_ROM);
s_doppler = Cvar_Get( "s_doppler", "1", CVAR_ARCHIVE );
s_backend = Cvar_Get( "s_backend", "", CVAR_ROM );
s_interrupts = Cvar_Get( "s_interrupts", "0", CVAR_ARCHIVE ); // leilei - pre-1.25 sound behavior
s_muteWhenMinimized = Cvar_Get( "s_muteWhenMinimized", "0", CVAR_ARCHIVE );
s_muteWhenUnfocused = Cvar_Get( "s_muteWhenUnfocused", "0", CVAR_ARCHIVE );
s_xmp_startPattern = Cvar_Get( "s_xmp_startPattern", "0", CVAR_CHEAT ); // leilei - starting pattern for song
cv = Cvar_Get( "s_initsound", "1", 0 );
if( !cv->integer ) {
Com_Printf( "Sound disabled.\n" );

View File

@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// A user mod should never modify this file
#ifdef STANDALONE
#define PRODUCT_NAME "ioq3+oa"
#define PRODUCT_NAME "OpenArena"
#define BASEGAME "baseoa"
#define CLIENT_WINDOW_TITLE "OpenArena"
#define CLIENT_WINDOW_MIN_TITLE "OA"

View File

@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
// surface geometry should not exceed these limits
#define SHADER_MAX_VERTEXES 4000
#define SHADER_MAX_VERTEXES 1000
#define SHADER_MAX_INDEXES (6*SHADER_MAX_VERTEXES)

View File

@@ -1062,9 +1062,6 @@ RB_SetGL2D
================
*/
extern int tvWidth;
extern int tvHeight;
extern int vresWidth;
extern int vresHeight;
@@ -1456,148 +1453,6 @@ const void *RB_ClearDepth(const void *data)
return (const void *)(cmd + 1);
}
extern cvar_t *r_slowness; // leilei - experimental variable slowness
extern cvar_t *r_slowness_cpu; // leilei - experimental variable slowness
extern cvar_t *r_slowness_gpu; // leilei - experimental variable slowness
// leilei - motion blur hack
float motiontime;
float motion_finished;
int motionframe;
int motionpasses;
int numofmotionpasses;
int inmotion;
int mblurred; // tells the renderer if we are rendering to a motion blur accum buffer instead of our drawing buffer
int mpasses; // how many passes of motion blur we should render.
float motioner;
void R_TVScreen( void );
void R_RetroAAScreen( void );
void R_MblurScreen( void );
void R_MblurScreenPost( void );
void RB_UpdateMotionBlur (void){
// leilei - motion blur hack
numofmotionpasses = 4;
numofmotionpasses = backEnd.refdef.time - backEnd.refdef.floatTime / 1000.0f;
motioner = (backEnd.refdef.time - motiontime);
numofmotionpasses = (int)motioner / 3;
// unfortunately doing this with some math just causes it to loop
if (numofmotionpasses == 4) numofmotionpasses = 0;
else if (numofmotionpasses == 3) numofmotionpasses = 1;
else if (numofmotionpasses == 2) numofmotionpasses = 2;
else if (numofmotionpasses == 1) numofmotionpasses = 3;
else if (numofmotionpasses == 0) numofmotionpasses = 4;
//else numofmotionpasses = 0;
//ri.Printf( PRINT_WARNING, "hah %i\n", numofmotionpasses);
mpasses = floor(numofmotionpasses);
if (mpasses > 4) mpasses = 4;
if (mpasses < 1) return; // JUST DONT!!
motion_finished = (1000.0f / r_motionblur_fps->integer / 5 / mpasses);
if (motionpasses > numofmotionpasses){
motionpasses = 0;
}
if (motionframe > 5){
// do an accumulating post process
motionpasses += 1;
// R_MotionBlur_BackupScreen(10 + motionpasses);
R_MotionBlur_BackupScreen(11); // back it up in there...
motionframe = 1;
//return;
}
if (backEnd.refdef.time > motiontime){
R_MotionBlur_BackupScreen(motionframe); // back it up in there...
motionframe += 1;
R_MblurScreen();
motiontime = backEnd.refdef.time + motion_finished;
inmotion = 1;
}
else
inmotion = 0;
}
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;
int mblurredframes;
int mblurredframestotal;
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;
if (r_tvMode->integer > -1) 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_LOAD, 1.0f);
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
@@ -1613,15 +1468,6 @@ const void *RB_SwapBuffers( const void *data ) {
RB_EndSurface();
}
if (r_motionblur->integer > 2){
{
mtime = backEnd.refdef.time + (1000.0f / r_motionblur_fps->integer);
mblurred = 0;
RB_UpdateMotionBlur();
}
}
// texture swapping test
if ( r_showImages->integer ) {
RB_ShowImages();
@@ -1638,21 +1484,8 @@ 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 that represents our video buffer
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, degrading our precious VGA signals
R_TVScreen(); // leilei - tv operation comes last, this is a SCREEN
cmd = (const swapBuffersCommand_t *)data;
// we measure overdraw by reading back the stencil buffer and
@@ -1689,17 +1522,11 @@ const void *RB_SwapBuffers( const void *data ) {
backEnd.donewater = qfalse;
backEnd.donepostproc = qfalse;
backEnd.doneAltBrightness = qfalse;
backEnd.doneFilm = qfalse;
backEnd.doneleifx = qfalse;
backEnd.doneanime = qfalse;
backEnd.donepalette = qfalse;
backEnd.donemblur = qfalse;
backEnd.doneSurfaces = qfalse;
backEnd.doneSun = qfalse;
backEnd.doneSunFlare = qfalse;
backEnd.donentsc = qfalse;
backEnd.donetv = qfalse;
backEnd.doneraa = qfalse;
backEnd.doneParticles = qfalse;
// leilei - only reset this every 15hz to keep it fast and synchronized
@@ -1707,35 +1534,7 @@ const void *RB_SwapBuffers( const void *data ) {
backEnd.doneFlareTests = qfalse;
backEnd.flareTestTime = backEnd.refdef.time + 100.0f;
}
// leilei - artificial slowness (mapper debug) - this might be windows only
#ifdef _WIN32
if (r_slowness->integer > 2){
// Should be roughly equiv to a P2 300 at value 1.0 (target system)
float cpuspeed = r_slowness_cpu->value;
float gpuspeed = r_slowness_gpu->value;
if (cpuspeed < 1) cpuspeed = 1;
if (gpuspeed < 1) gpuspeed = 1; // avoid div0
float slowit = (float)(((float)(backEnd.pc.c_surfaces) / 16) + ((float)backEnd.pc.c_vertexes / 64) + 5400.0f);
slowit /= cpuspeed; // yeah it's the cpu
float blowit = ((float)(backEnd.pc.c_surfaces / 32) + (backEnd.pc.c_indexes / 1324 * (float)(glConfig.vidWidth * glConfig.vidHeight / 1100)));
blowit /= gpuspeed; // yeah it's the gpu
if (blowit > slowit) slowit = blowit; // GPU bottleneck
else if (slowit > blowit) blowit = slowit; // CPU bottlebeck
if (slowit > 8500) slowit = 8500; // but not too much?
Sleep(slowit); // FORCE A SLEEP!! HAHAHAHA!!!
}
#endif
time_last = backEnd.refdef.time;
return (const void *)(cmd + 1);
}
@@ -1748,7 +1547,6 @@ void RB_ExecuteRenderCommands( const void *data ) {
int t1, t2;
t1 = ri.Milliseconds ();
time_now = t1;
while ( 1 ) {
data = PADP(data, sizeof(void *));
@@ -1762,7 +1560,6 @@ void RB_ExecuteRenderCommands( const void *data ) {
leifxmode = 0;
R_PostprocessScreen();
R_BloomScreen();
R_FilmScreen();
data = RB_StretchPic( data );
break;
case RC_DRAW_SURFS:
@@ -1776,7 +1573,6 @@ void RB_ExecuteRenderCommands( const void *data ) {
leifxmode = 0;
R_PostprocessScreen();
R_BloomScreen();
R_FilmScreen();
data = RB_SwapBuffers( data );
break;
case RC_SCREENSHOT:

File diff suppressed because it is too large Load Diff

View File

@@ -108,16 +108,69 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) {
r = in[0] << shift;
g = in[1] << shift;
b = in[2] << shift;
// normalize by color instead of saturating to white
if ( ( r | g | b ) > 255 ) {
int max;
max = r > g ? r : g;
max = max > b ? max : b;
r = r * 255 / max;
g = g * 255 / max;
b = b * 255 / max;
// leilei - handle light desaturation here instead, so we can also mono the lightgrid and have one less redundant clamp
if( r_monolightmaps->value > 0)
{
float saturated = (r * 0.22126) + (g * 0.7152) + (b * 0.0722);
float ml = r_monolightmaps->value; // sanitize
if (ml>1) ml=1; if (ml<0) ml=0;
r = saturated + (r - saturated) * ( 1-ml );
g = saturated + (g - saturated) * ( 1-ml );
b = saturated + (b - saturated) * ( 1-ml );
}
if (r_lightmapColorNorm->integer == 2) // leilei
{
float lum, invader = 0;
// get luma from base color
lum = (0.22126*r + 0.7152*g + 0.0722*b); // thanks wiki
// normalize by color instead of saturating to white
if ( ( r | g | b ) > 255 ) {
int max;
max = r > g ? r : g;
max = max > b ? max : b;
r = r * 255 / max;
g = g * 255 / max;
b = b * 255 / max;
invader = lum - (0.22126*r + 0.7152*g + 0.0722*b); // get the differences from the normalized color
invader *= (invader/255);
r += invader;
g += invader;
b += invader;
// Normalize... again!!!
max = r > g ? r : g;
max = max > b ? max : b;
r = r * 255 / max;
g = g * 255 / max;
b = b * 255 / max;
}
}
else if (r_lightmapColorNorm->integer) // leilei - made this an option for trying normal clamp
{
// normalize by color instead of saturating to white
if ( ( r | g | b ) > 255 ) {
int max;
max = r > g ? r : g;
max = max > b ? max : b;
r = r * 255 / max;
g = g * 255 / max;
b = b * 255 / max;
}
}
else
{
if ( r > 255 ) r = 255;
if ( g > 255 ) g = 255;
if ( b > 255 ) b = 255;
}
out[0] = r;
@@ -299,7 +352,6 @@ static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) {
// leilei - placeholder hack
if (tr.placeholderTextureAvail == 1 && !Q_strncmp( dsh->shader, "textures", 8 ))
{
// return tr.placeholderTextureShader;
shader = R_FindShader( "placeholder_texture", lightmapNum, qtrue );
return shader;
}

View File

@@ -126,6 +126,7 @@ typedef enum {
int softwaremode; // leilei - detect for software mode
int voodootype; // leilei - detect for voodoo revision
char extensions_string_full [BIG_INFO_STRING]; // leilei - gl extensions crash workaround
/** From renderer_opengl2 (v28) */
static qboolean GLimp_HaveExtension(const char *ext)
@@ -331,6 +332,11 @@ void GLimp_InitExtraExtensions()
Q_strncpyz( buf, glConfig.renderer_string, sizeof(buf) );
Q_strlwr( buf );
// leilei - we are done with our extensions string, if it's too long we can just trim it so we won't hardlock old qvms with an overflow.
Q_strncpyz( extensions_string_full, (char *) qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) ); // copy to a global for gfxinfo
char butt[640];
Q_strncpyz( glConfig.extensions_string, (char *) qglGetString (GL_EXTENSIONS), sizeof( butt ) );
//
// this is where hardware specific workarounds that should be

View File

@@ -213,18 +213,18 @@ void R_InitPalette( void ) {
byte *buff;
int i, v;
ri.Printf( PRINT_ALL, "INIT PALETTE......\n");
ri.Printf( PRINT_ALL, "R_InitPalette: \n");
ri.FS_ReadFile("gfx/palette.lmp", (void **)&buff);
if(!buff){
ri.Printf( PRINT_ALL, "PALLETE FALED :(!\n" );
ri.Printf( PRINT_ALL, "PALETTE FAILED\n" );
paletteavailable = 0; // Don't have a palette
paletteenabled = 0; // Don't do 8-bit textures
return;
}
palettemain = buff;
ri.Printf( PRINT_ALL, "PALETTE LOADDEEEED!!!!!!!!!!!!1\n" );
ri.Printf( PRINT_ALL, "PALETTE LOADED\n" );
paletteavailable = 1; // Do have a palette
if (palettedTextureSupport) {
@@ -1033,79 +1033,6 @@ int hqresample = 0; // leilei - high quality texture resampling
// Currently 0 as there is an alignment issue I haven't fixed.
int isicon; // leilei - for determining if it's an icon.
char dumpname[ MAX_QPATH ]; // leilei - name for texture dumping
static void DumpTex( unsigned *data,
int width, int height )
{
// leilei - Do crazy dumping crap
byte *scan;
byte *baffer, *alffer, *flipper;
scan = ((byte *)data);
int padlen = 0;
int be, ber;
int scrale = width * height;
int hasalf = 0;
float countw = 0;
#if 0
int scravg = width + height / 2;
int quality = 85; // estimate quality from total size
if (scravg > 511) quality = 42; // huge textures
else if (scravg > 255) quality = 62; // large textures
else if (scravg > 127) quality = 72; // large textures
else if (scravg < 127) quality = 95; // tiny textures
#endif
baffer = ri.Hunk_AllocateTempMemory( width * height * 3 );
flipper = ri.Hunk_AllocateTempMemory( width * height * 3 );
alffer = ri.Hunk_AllocateTempMemory( width * height * 3 );
// TODO: Save alpha separately
// I'm gonna flip......
int alfcnt = 0;
for (be=0; be<scrale; be++){
int bib;
if (countw > width)
countw = 0;
else
countw++;
ber = scrale - be - 1;
bib = be;
if (bib < 0) bib = 0;
if (bib > scrale) bib = 0;
baffer[bib*3] = scan[ber*4];
baffer[bib*3+1] = scan[ber*4+1];
baffer[bib*3+2] = scan[ber*4+2];
alffer[bib*3] = scan[ber*4+3];
alffer[bib*3+1] = scan[ber*4+3];
alffer[bib*3+2] = scan[ber*4+3];
if (scan[ber*4+3] > 1){ hasalf = 1;}
if (scan[ber*4+3] == 255){ alfcnt += 1; }
}
// NOW FIX IT
//memcount = (width * 3 + padlen) * height;
if ((width > 16) && (height > 16)){
RE_SaveJPG( va("dump/%s.jpg", dumpname), 85,width, height, baffer, padlen);
if (hasalf) {
RE_SaveJPG( va("dump/%s_alpha.jpg", dumpname), 85,width, height, alffer, padlen);
}
}
ri.Printf( PRINT_ALL, "TEXDUMP: %s \n", dumpname );
// if ( baffer != 0 )
ri.Hunk_FreeTempMemory( baffer );
// if ( alffer != 0 )
ri.Hunk_FreeTempMemory( alffer );
ri.Hunk_FreeTempMemory( flipper );
}
static void Upload32( unsigned *data,
int width, int height,
@@ -1129,9 +1056,6 @@ static void Upload32( unsigned *data,
int forceBits = 0;
if (lightMap && r_parseStageSimple->integer) hackoperation = 4;
//
// convert to exact power of 2 sizes
//
@@ -1208,12 +1132,8 @@ static void Upload32( unsigned *data,
//
if ( isicon ){
if (r_iconmip->integer){
// Auto-determine from resolution division
if (r_iconmip->integer == 1){
int wadth, haght, dev = 0;
@@ -1266,8 +1186,6 @@ static void Upload32( unsigned *data,
scaled_height = 1;
}
//
// clamp to the current upper OpenGL limit
// scale both axis down equally so we don't have to
@@ -1301,7 +1219,6 @@ static void Upload32( unsigned *data,
int r, g, b;
vec3_t rgb;
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];
@@ -1409,152 +1326,11 @@ static void Upload32( unsigned *data,
}
if(r_textureDither->integer) // possibly the stupidest texture dithering ever
{
#ifdef DONTEVENTHINKABOUTTHIS
int passes = r_textureDither->integer;
int that;
/* LEIFX FILTER C PORT PROTOTYPE SCRATCH AREA
No vectors, only ints ints ints Obviously can be refactored with SSE */
#define FILTCAP (0.075 * 255)
#define FILTCAPG (FILTCAP / 2)
for (that=0;that<passes;that++){
for ( i = 0; i < c-1; i++ )
{
int ren;
int r1,g1,b1;
int r2,g2,b2;
int rd,gd,bd;
// texturdither was here, will return properly someday.
/* Grab Pixels to Sample From */
r1 = scan[i*4];
g1 = scan[i*4+1];
b1 = scan[i*4+2];
r2 = scan[(i+1)*4];
g2 = scan[(i+1)*4 + 1];
b2 = scan[(i+1)*4 + 2];
/* Find differences */
rd = r2 - r1;
gd = g2 - g1;
bd = b2 - b1;
if (rd > FILTCAP ) rd = FILTCAP;
if (gd > FILTCAPG) gd = FILTCAPG;
if (bd > FILTCAP ) bd = FILTCAP;
if (rd < -FILTCAP ) rd = -FILTCAP;
if (gd < -FILTCAPG) gd = -FILTCAPG;
if (bd < -FILTCAP ) bd = -FILTCAP;
/* Add our Differences */
r1 += (rd/3);
g1 += (gd/3);
b1 += (bd/3);
/* Obligatory clamping part */
if (r1 < 0) r1 = 0;
if (g1 < 0) g1 = 0;
if (b1 < 0) b1 = 0;
if (r1 > 255) r1 = 255;
if (g1 > 255) g1 = 255;
if (b1 > 255) b1 = 255;
if (r2 < 0) r2 = 0;
if (g2 < 0) g2 = 0;
if (b2 < 0) b2 = 0;
if (r2 > 255) r2 = 255;
if (g2 > 255) g2 = 255;
if (b2 > 255) b2 = 255;
/* Put processed image back into the buffer */
scan[i*4] = r1;
scan[i*4 + 1] = g1;
scan[i*4 + 2] = b1;
}
}
#endif
for ( i = 0; i < c; i++ )
{
int ren = (crandom() * 4);
int rg,gg,bb;
rg = scan[i*4];
gg = scan[i*4+1];
bb = scan[i*4+2];
//if ((rg / 64) != ceil(rg / 64))
rg = scan[i*4] + ren;
//if ((gg / 32) != ceil(gg / 32))
gg = scan[i*4 + 1] + (ren / 2);
//if ((bb / 64) != ceil(bb / 64))
bb = scan[i*4 + 2] + ren;
if (rg < 0) rg = 0;
if (gg < 0) gg = 0;
if (bb < 0) bb = 0;
if (rg > 255) rg = 255;
if (gg > 255) gg = 255;
if (bb > 255) bb = 255;
scan[i*4] = rg;
scan[i*4 + 1] = gg;
scan[i*4 + 2] = bb;
}
}
if( r_greyscale->value )
{
// leilei - replaced with saturation processing
for ( i = 0; i < c; i++ )
{
float saturated = (scan[i*4] * 0.333) + (scan[i*4 + 1] * 0.333) + (scan[i*4 + 2] * 0.333);
scan[i*4] = saturated + (scan[i*4] - saturated) * (1-r_greyscale->value);
scan[i*4 + 1] = saturated + (scan[i*4 + 1] - saturated) * (1-r_greyscale->value);
scan[i*4 + 2] = saturated + (scan[i*4 + 2] - saturated) * (1-r_greyscale->value);
if (scan[i*4] > 255) scan[i*4] = 255;
if (scan[i*4 + 1] > 255) scan[i*4 + 1] = 255;
if (scan[i*4 + 2] > 255) scan[i*4 + 2] = 255;
}
}
if(lightMap)
{
if( r_monolightmaps->value )
{
for ( i = 0; i < c; i++ )
{
float saturated = (scan[i*4] * 0.333) + (scan[i*4 + 1] * 0.333) + (scan[i*4 + 2] * 0.333);
scan[i*4] = saturated + (scan[i*4] - saturated) * (1-r_monolightmaps->value);
scan[i*4 + 1] = saturated + (scan[i*4 + 1] - saturated) * (1-r_monolightmaps->value );
scan[i*4 + 2] = saturated + (scan[i*4 + 2] - saturated) * (1-r_monolightmaps->value );
if (scan[i*4] > 255) scan[i*4] = 255;
if (scan[i*4 + 1] > 255) scan[i*4 + 1] = 255;
if (scan[i*4 + 2] > 255) scan[i*4 + 2] = 255;
}
}
if(r_greyscale->integer)
internalFormat = GL_LUMINANCE;
else if(r_monolightmaps->integer)
if(r_monolightmaps->integer)
internalFormat = GL_LUMINANCE;
else
internalFormat = GL_RGB;
@@ -1617,16 +1393,6 @@ static void Upload32( unsigned *data,
// select proper internal format
if ( samples == 3 )
{
if(r_greyscale->integer)
{
if(r_texturebits->integer == 16 || forceBits == 16)
internalFormat = GL_LUMINANCE8;
else if(r_texturebits->integer == 32 || forceBits == 32)
internalFormat = GL_LUMINANCE16;
else
internalFormat = GL_LUMINANCE;
}
else
{
if ( glConfig.textureCompression == TC_S3TC_ARB )
{
@@ -1667,16 +1433,6 @@ static void Upload32( unsigned *data,
}
else if ( samples == 4 )
{
if(r_greyscale->integer)
{
if(r_texturebits->integer == 16 || forceBits == 16)
internalFormat = GL_LUMINANCE8_ALPHA8;
else if(r_texturebits->integer == 32 || forceBits == 32)
internalFormat = GL_LUMINANCE16_ALPHA16;
else
internalFormat = GL_LUMINANCE_ALPHA;
}
else
{
if ( glConfig.textureCompression == TC_S3TC_ARB )
{
@@ -2218,12 +1974,6 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height,
GL_Bind(image);
// leilei - texture dumping
if (r_texdump->integer) {
COM_StripExtension( name, dumpname, MAX_QPATH ); // leilei - transfer name for texdump
DumpTex( (unsigned *)pic, image->width, image->height);
}
if (paletteavailable && r_texturebits->integer == 8 && !isLightmap && !depthimage && !force32upload) {
Upload8( (unsigned *)pic, image->width, image->height,
image->flags & IMGFLAG_MIPMAP,

View File

@@ -71,7 +71,6 @@ cvar_t *r_skipBackEnd;
cvar_t *r_stereoEnabled;
cvar_t *r_anaglyphMode;
cvar_t *r_greyscale;
cvar_t *r_monolightmaps;
cvar_t *r_ignorehwgamma;
@@ -196,7 +195,6 @@ cvar_t *r_flareMethod; // method of flare intensity
cvar_t *r_flareQuality; // testing quality of the flares.
cvar_t *r_flareSun; // type of flare to use for the sun
cvar_t *r_flareDelay; // time delay for medium quality flare testing
cvar_t *r_flaresMotionBlur; // Stretch blur
cvar_t *r_specMode;
//cvar_t *r_waveMode;
@@ -205,45 +203,31 @@ cvar_t *r_flaresDlightShrink;
cvar_t *r_flaresDlightFade;
cvar_t *r_flaresDlightOpacity;
cvar_t *r_flaresDlightScale;
cvar_t *r_lightmapColorNorm;
//cvar_t *r_flaresSurfradii;
cvar_t *r_alternateBrightness; // leilei - linux overbright fix
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_modelshader; // Leilei
cvar_t *r_shadeMethod; // Leilei
cvar_t *r_particles; // Leilei - particle effects motif
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_skytess; // leilei - lower detail of skies
cvar_t *r_leidebug; // Leilei - debug
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_fps; // Leilei - motionblur framerated
cvar_t *r_slowness; // Leilei - the cvar that slows everything down. use with caution.
cvar_t *r_slowness_cpu; // Leilei
cvar_t *r_slowness_gpu; // Leilei
cvar_t *r_textureDither; // leilei - Dithered texture
cvar_t *r_texdump; // Leilei - debug - texture dump as they load, players should never need to use this!
// leilei - fallback shader hack
#ifdef USE_FALLBACK_GLSL
extern const char *fallbackShader_anime_vp;
extern const char *fallbackShader_anime_fp;
extern const char *fallbackShader_anime_film_vp;
extern const char *fallbackShader_anime_film_fp;
extern const char *fallbackShader_brightness_vp;
extern const char *fallbackShader_brightness_fp;
extern const char *fallbackShader_leifx_dither_vp;
@@ -254,10 +238,6 @@ extern const char *fallbackShader_leifx_gamma_vp;
extern const char *fallbackShader_leifx_gamma_fp;
extern const char *fallbackShader_leifx_vgasignal_vp;
extern const char *fallbackShader_leifx_vgasignal_fp;
extern const char *fallbackShader_motionblur_accum_vp;
extern const char *fallbackShader_motionblur_accum_fp;
extern const char *fallbackShader_motionblur_post_vp;
extern const char *fallbackShader_motionblur_post_fp;
#endif
@@ -587,24 +567,12 @@ RB_TakeScreenshotCmd
==================
*/
extern int tvWidth;
extern int tvHeight;
const void *RB_TakeScreenshotCmd( const void *data )
{
const screenshotCommand_t *cmd;
cmd = (const screenshotCommand_t *)data;
// leilei - hack for tvmode
if (r_tvMode->integer > -1) {
if (cmd->jpeg)
RB_TakeScreenshotJPEG( cmd->x, cmd->y, tvWidth, tvHeight, cmd->fileName);
else
RB_TakeScreenshot( cmd->x, cmd->y, tvWidth, tvHeight, cmd->fileName);
}
if (cmd->jpeg)
RB_TakeScreenshotJPEG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName);
else
@@ -1029,6 +997,7 @@ void R_PrintLongString(const char *string)
GfxInfo_f
================
*/
extern char extensions_string_full [BIG_INFO_STRING]; // leilei - gl extensions crash workaround
void GfxInfo_f( void )
{
const char *enablestrings[] = {
@@ -1044,7 +1013,7 @@ void GfxInfo_f( void )
ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string );
ri.Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string );
ri.Printf( PRINT_ALL, "GL_EXTENSIONS: " );
R_PrintLongString( glConfig.extensions_string );
R_PrintLongString( extensions_string_full );//R_PrintLongString( glConfig.extensions_string ); // leilei - gl extensions crash workaround
ri.Printf( PRINT_ALL, "\n" );
ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize );
ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS_ARB: %d\n", glConfig.numTextureUnits );
@@ -1202,10 +1171,9 @@ void R_Register( void )
r_subdivisions = ri.Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH);
r_stereoEnabled = ri.Cvar_Get( "r_stereoEnabled", "0", CVAR_ARCHIVE | CVAR_LATCH);
r_ignoreFastPath = ri.Cvar_Get( "r_ignoreFastPath", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH);
ri.Cvar_CheckRange(r_greyscale, 0, 1, qfalse);
r_monolightmaps = ri.Cvar_Get("r_monolightmaps", "0", CVAR_ARCHIVE | CVAR_LATCH);
ri.Cvar_CheckRange(r_monolightmaps, 0, 1, qfalse);
//
// temporary latched variables that can only change over a restart
@@ -1262,6 +1230,7 @@ void R_Register( void )
r_nocurves = ri.Cvar_Get ("r_nocurves", "0", CVAR_CHEAT );
r_drawworld = ri.Cvar_Get ("r_drawworld", "1", CVAR_CHEAT );
r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0 );
r_portalOnly = ri.Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT );
@@ -1322,45 +1291,30 @@ void R_Register( void )
r_flareSun = ri.Cvar_Get( "r_flareSun", "0" , CVAR_ARCHIVE); // it's 0 because mappers expect 0.
r_flareDelay = ri.Cvar_Get( "r_flareDelay", "100" , CVAR_CHEAT); // update delay for flare pixel read checking.
r_flaresMotionBlur = ri.Cvar_Get( "r_flaresMotionBlur", "0" , CVAR_ARCHIVE ); // fake motion blur on flares
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_modelshader = ri.Cvar_Get( "r_modelshader", "0" , CVAR_ARCHIVE | CVAR_LATCH); // leilei - load and use special shaders for lightDiffuse models
r_shadeMethod = ri.Cvar_Get( "r_shadeMethod", "0" , CVAR_ARCHIVE); // leilei - Alternative lightingDiffuse
r_skytess = ri.Cvar_Get( "r_skyTess", "8", CVAR_ARCHIVE ); // leilei - sky detail adjustment
r_detailTextureScale = ri.Cvar_Get( "r_detailtextureScale", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - adjust scale of detail textures
r_detailTextureLayers = ri.Cvar_Get( "r_detailtextureLayers", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - add more detail layers
r_ntsc = ri.Cvar_Get( "r_ntsc", "0" , CVAR_ARCHIVE | CVAR_LATCH); // leilei - ntsc filter
//r_tvMode = ri.Cvar_Get( "r_tvMode", "0" , CVAR_ARCHIVE | CVAR_LATCH);
r_retroAA = ri.Cvar_Get( "r_retroAA", "0" , CVAR_ARCHIVE | CVAR_LATCH);
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_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_particles = ri.Cvar_Get( "r_particles", "0" , CVAR_ARCHIVE | CVAR_LATCH);
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.
r_slowness_cpu = ri.Cvar_Get( "r_slowness_cpu", "300" , CVAR_ARCHIVE); // it's 0 because you want it to be the fastest possible by default.
r_slowness_gpu = ri.Cvar_Get( "r_slowness_gpu", "96" , CVAR_ARCHIVE); // it's 0 because you want it to be the fastest possible by default.
r_iconmip = ri.Cvar_Get ("r_iconmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - icon mip
r_iconBits = ri.Cvar_Get ("r_iconBits", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - icon bits
r_lightmapBits = ri.Cvar_Get ("r_lightmapBits", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - lightmap color bits
r_lightmapColorNorm = ri.Cvar_Get ("r_lightmapColorNorm", "1", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - lightmap color normalization
r_textureDither = ri.Cvar_Get ("r_textureDither", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - dithered textures
r_texdump = ri.Cvar_Get( "r_texdump", "0", CVAR_CHEAT ); // leilei - debug - texture dumping
// make sure all the commands added here are also
// removed in R_Shutdown
ri.Cmd_AddCommand( "imagelist", R_ImageList_f );
@@ -1422,12 +1376,6 @@ static glslProgram_t *R_GLSL_AllocProgram(void)
program->u_ViewOrigin = -1;
program->u_Normal = -1;
program->u_mpass1 = -1;
program->u_mpass2 = -1;
program->u_mpass3 = -1;
program->u_mpass4 = -1;
program->rubyTextureSize = -1;
program->rubyInputSize = -1;
program->rubyOutputSize = -1;
@@ -1489,21 +1437,6 @@ void R_GLSL_Init(void)
Q_strncpyz(programFragmentObjects[0], "glsl/sky_fp.glsl", sizeof(programFragmentObjects[0]));
tr.skyProgram = RE_GLSL_RegisterProgram("sky", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
Q_strncpyz(programVertexObjects[0], "glsl/anime_vp.glsl", sizeof(programVertexObjects[0]));
Q_strncpyz(programFragmentObjects[0], "glsl/anime_fp.glsl", sizeof(programFragmentObjects[0]));
tr.animeProgram = RE_GLSL_RegisterProgram("anime", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
Q_strncpyz(programVertexObjects[0], "glsl/anime_film_vp.glsl", sizeof(programVertexObjects[0]));
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]));
tr.leiFXDitherProgram = RE_GLSL_RegisterProgram("leifx_dither", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
@@ -1519,33 +1452,58 @@ void R_GLSL_Init(void)
Q_strncpyz(programFragmentObjects[0], "glsl/leifx_filter_fp.glsl", sizeof(programFragmentObjects[0]));
tr.leiFXFilterProgram = RE_GLSL_RegisterProgram("leifx_filter", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
Q_strncpyz(programVertexObjects[0], "glsl/motionblur_accum_vp.glsl", sizeof(programVertexObjects[0]));
Q_strncpyz(programFragmentObjects[0], "glsl/motionblur_accum_fp.glsl", sizeof(programFragmentObjects[0]));
tr.motionBlurProgram = RE_GLSL_RegisterProgram("motionblur_accum", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
Q_strncpyz(programVertexObjects[0], "glsl/motionblur_post_vp.glsl", sizeof(programVertexObjects[0]));
Q_strncpyz(programFragmentObjects[0], "glsl/motionblur_post_fp.glsl", sizeof(programFragmentObjects[0]));
tr.motionBlurPostProgram = RE_GLSL_RegisterProgram("motionblur_post", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
Q_strncpyz(programVertexObjects[0], "glsl/brightness_vp.glsl", sizeof(programVertexObjects[0]));
Q_strncpyz(programFragmentObjects[0], "glsl/brightness_fp.glsl", sizeof(programFragmentObjects[0]));
tr.BrightnessProgram = RE_GLSL_RegisterProgram("brightness", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
if (!(tr.BrightnessProgram = RE_GLSL_RegisterProgram("brightness", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1)))
{
// load it through this code
ri.Printf( PRINT_ALL, "----- Trying to load Brightness Shader internally!!! \n" );
Q_strncpyz(programVertexObjects[0], "glsl/crt_vp.glsl", sizeof(programVertexObjects[0]));
Q_strncpyz(programFragmentObjects[0], "glsl/crt_fp.glsl", sizeof(programFragmentObjects[0]));
tr.CRTProgram = RE_GLSL_RegisterProgram("crt", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
const GLchar *brightnessfp = \
"#version 120 \n"
"uniform sampler2D u_Texture0; \n"
"varying vec2 texture_coordinate;\n"
"uniform float u_CC_Overbright; \n"
"uniform float u_CC_Gamma; \n"
"void main()\n"
"{\n"
"gl_FragColor = texture2D(u_Texture0, texture_coordinate); \n"
"vec3 color;\n"
"vec3 colord;\n"
"int coloredr;\n"
"int coloredg;\n"
"int coloredb;\n"
"color.r = 1;\n"
"color.g = 1;\n"
"color.b = 1;\n"
"int yeh = 0;\n"
"float ohyes;\n"
"// Overbrights\n"
"gl_FragColor *= (u_CC_Overbright + 1);\n"
"// Gamma Correction\n"
"float gamma = u_CC_Gamma;\n"
"gl_FragColor.r = pow(gl_FragColor.r, 1.0 / gamma);\n"
"gl_FragColor.g = pow(gl_FragColor.g, 1.0 / gamma);\n"
"gl_FragColor.b = pow(gl_FragColor.b, 1.0 / gamma);\n"
"}\n";
Q_strncpyz(programVertexObjects[0], "glsl/ntsc_encode_vp.glsl", sizeof(programVertexObjects[0]));
Q_strncpyz(programFragmentObjects[0], "glsl/ntsc_encode_fp.glsl", sizeof(programFragmentObjects[0]));
tr.NTSCEncodeProgram = RE_GLSL_RegisterProgram("ntsc_encode", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
const GLchar *brightnessvp = \
"varying vec2 texture_coordinate;\n"
"varying vec2 texture_coordinate2;\n"
"varying vec2 texture_coordinate3;\n"
"varying vec2 texture_coordinate4;\n"
"varying vec2 texture_coordinate5;\n"
"varying float scale;\n"
"uniform float u_CC_Overbright;\n"
"uniform float u_CC_Gamma;\n"
"void main()\n"
"{\n"
"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"
"texture_coordinate = vec2(gl_MultiTexCoord0); \n"
"}\n";
Q_strncpyz(programVertexObjects[0], "glsl/ntsc_decode_vp.glsl", sizeof(programVertexObjects[0]));
Q_strncpyz(programFragmentObjects[0], "glsl/ntsc_decode_fp.glsl", sizeof(programFragmentObjects[0]));
tr.NTSCDecodeProgram = RE_GLSL_RegisterProgram("ntsc_decode", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
Q_strncpyz(programVertexObjects[0], "glsl/ntsc_bleed_vp.glsl", sizeof(programVertexObjects[0]));
Q_strncpyz(programFragmentObjects[0], "glsl/ntsc_bleed_fp.glsl", sizeof(programFragmentObjects[0]));
tr.NTSCBleedProgram = RE_GLSL_RegisterProgram("ntsc_bleed", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1);
tr.BrightnessProgram = RE_GLSL_RegisterProgramRaw("brightnessInternal", (const char *)brightnessvp, 1, (const char *)brightnessfp, 1);
}
if (strcmp( (const char *)r_postprocess->string, "none" )) {
sprintf(p,"glsl/%s_vp.glsl",r_postprocess->string);
@@ -1621,7 +1579,6 @@ void R_Init( void )
R_BloomInit();
R_PostprocessingInit();
R_AltBrightnessInit(); // leilei - alternate brightness
R_WaterInit(); // leilei - water test
max_polys = r_maxpolys->integer;
if (max_polys < MAX_POLYS)
max_polys = MAX_POLYS;

View File

@@ -86,8 +86,6 @@ typedef struct {
vec3_t axis[3]; // orientation in world
vec3_t viewOrigin; // viewParms->or.origin in local coordinates
float modelMatrix[16];
vec3_t viewOriginOld; // leilei - motionBlur
vec3_t viewOriginOlder; // leilei - motionBlur
} orientationr_t;
//===============================================================================
@@ -187,6 +185,7 @@ typedef enum {
CGEN_FOG, // standard fog
CGEN_CONST, // fixed color
CGEN_VERTEX_LIT, // leilei - tess.vertexColors * tr.identityLight * ambientlight*directlight
CGEN_MATERIAL, // leilei - material system
CGEN_LIGHTING_DIFFUSE_SPECULAR // leilei - LIGHTING_DIFFUSE, capped by specular exponent
} colorGen_t;
@@ -196,8 +195,6 @@ typedef enum {
TCGEN_LIGHTMAP,
TCGEN_TEXTURE,
TCGEN_ENVIRONMENT_MAPPED,
TCGEN_ENVIRONMENT_CELSHADE_MAPPED,
TCGEN_ENVIRONMENT_CELSHADE_LEILEI, // leilei - cel hack
TCGEN_ENVIRONMENT_MAPPED_WATER, // leilei - fake water reflection
TCGEN_EYE_LEFT, // eyes
TCGEN_EYE_RIGHT, // eyes
@@ -265,6 +262,17 @@ typedef enum {
TMOD_ENTITY_TRANSLATE
} texMod_t;
// leilei - rgbMod - color modulations
typedef enum {
CMOD_BAD,
CMOD_GLOW,
CMOD_LIGHTING,
CMOD_NORMALIZETOALPHA,
CMOD_NORMALIZETOALPHAFAST,
CMOD_UVCOL,
CMOD_OPAQUE
} colorMod_t;
#define MAX_SHADER_DEFORMS 3
typedef struct {
deform_t deformation; // vertex coordinate modification type
@@ -308,7 +316,7 @@ typedef struct {
} texModInfo_t;
#define MAX_IMAGE_ANIMATIONS 8
#define MAX_IMAGE_ANIMATIONS 16 // leilei - was 8
typedef struct {
image_t *image[MAX_IMAGE_ANIMATIONS];
@@ -355,12 +363,22 @@ typedef struct {
int isGLSL;
int isBlend; // leilei - for leifx
qboolean isLeiShade; // leilei - for the automatic shader
qhandle_t program;
int imgWidth;
int imgHeight; //leilei for glsl shaders
colorMod_t rgbMod; // leilei - rgbMod
int rgbModCol;
int rgbModMode;
int matAmb; // leilei - material ambience
int matDif; // leilei - material diffuse
int matSpec; // leilei - material specular
int matEmis; // leilei - material emissive
int matHard; // leilei - material specular hardness
int matAlpha; // leilei - material alpha
} shaderStage_t;
struct shaderCommands_s;
@@ -858,7 +876,7 @@ typedef struct {
unsigned v_FogColor;
GLint u_Greyscale;
int v_Greyscale;
int v_Greyscale;
GLint u_IdentityLight;
float v_IdentityLight;
@@ -908,22 +926,6 @@ typedef struct {
GLint u_ActualScreenSizeX;
GLint u_ActualScreenSizeY;
// leilei - motion blur vars
GLfloat u_MotionBlurX;// OBSOLETE
GLfloat u_MotionBlurY;// OBSOLETE
GLint u_ViewMotion;// OBSOLETE
vec3_t v_ViewMotion;// OBSOLETE
GLint u_mpass1; // 1-5
GLint u_mpass2; // 6-10
GLint u_mpass3; // 11-15
GLint u_mpass4; // 16-20
GLint u_mpasses; // How many passes of Motion do we have anyhow?
// leilei - 'compatibility' with ruby shader vars (HACK HACK HACK)
GLint rubyInputSize;
@@ -1098,17 +1100,11 @@ typedef struct {
qboolean doneBloom; // done bloom this frame
qboolean donepostproc; // done postprocess this frame
qboolean doneleifx; // leilei - done leifxing this frame
qboolean doneanime; // leilei - done animeing this frame
qboolean doneAltBrightness; // leilei - done alternate brightness this frame
qboolean doneFilm; // leilei - done film filtering this frame
qboolean doneSun; // leilei - done drawing a sun
qboolean doneSunFlare; // leilei - done drawing a sun flare
qboolean donemblur; // leilei - done motionblur this frame
qboolean donewater; // leilei - done water this frame
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 donepalette; // leilei - done paletting this frame
qboolean doneSurfaces; // done any 3d surfaces already
qboolean doneParticles; // done any particle movement
qboolean doneFlareTests; // leilei - done testing flares
@@ -1167,16 +1163,7 @@ typedef struct {
qhandle_t leiFXDitherProgram; // leilei
qhandle_t leiFXGammaProgram; // leilei
qhandle_t leiFXFilterProgram; // leilei
qhandle_t animeProgram; // leilei
qhandle_t animeFilmProgram; // leilei
qhandle_t motionBlurProgram; // leilei
qhandle_t motionBlurPostProgram; // leilei
qhandle_t BrightnessProgram; // leilei
qhandle_t CRTProgram; // leilei
qhandle_t NTSCEncodeProgram; // leilei
qhandle_t NTSCDecodeProgram; // leilei
qhandle_t NTSCBleedProgram; // leilei
qhandle_t paletteProgram; // leilei
int numPrograms;
glslProgram_t *programs[MAX_PROGRAMS];
@@ -1362,8 +1349,6 @@ extern cvar_t *r_skipBackEnd;
extern cvar_t *r_anaglyphMode;
extern cvar_t *r_greyscale;
extern cvar_t *r_monolightmaps;
extern cvar_t *r_ignoreGLErrors;
@@ -1395,31 +1380,13 @@ extern cvar_t *r_flaresDlightFade;
extern cvar_t *r_flaresDlightOpacity;
extern cvar_t *r_flaresDlightScale;
extern cvar_t *r_flaresMotionBlur;
//extern cvar_t *r_flaresSurfradii;
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_modelshader; // Leilei - new model shading
extern cvar_t *r_shadeMethod; // Leilei - new model shading methods
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_tvFilter; // Leilei - filter to use
extern cvar_t *r_retroAA; // Leilei - old console anti aliasing
extern cvar_t *r_suggestiveThemes; // Leilei - mature content
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!
extern cvar_t *r_particles; // Leilei - particles!
@@ -1428,14 +1395,15 @@ extern cvar_t *r_iconmip; // leilei - icon mip - picmip for 2d icons
extern cvar_t *r_iconBits; // leilei - icon color depth for 2d icons
extern cvar_t *r_lightmapBits; // leilei - lightmap color depth
extern cvar_t *r_texdump; // leilei - texture dumping
extern cvar_t *r_lightmapColorNorm; // leilei - lightmap color normalize
extern cvar_t *r_detailTextureScale; // leilei - scale tweak the detail textures, 0 doesn't tweak at all.
extern cvar_t *r_detailTextureLayers; // leilei - add in more smaller detail texture layers, expensive!
extern cvar_t *r_textureDither; // leilei - apply dithering for lower texture bits
extern cvar_t *r_skytess; // leilei - adjusts the subdivisions of the sky (max 8, min 1)
//====================================================================
void R_SwapBuffers( int );
@@ -1919,14 +1887,6 @@ static ID_INLINE void R_GLSL_SetUniform_u_zFar(glslProgram_t *program, GLfloat v
qglUniform1fARB(program->u_zFar, value);
}
static ID_INLINE void R_GLSL_SetUniform_u_MotionBlurX(glslProgram_t *program, GLfloat value) {
qglUniform1fARB(program->u_MotionBlurX, value);
}
static ID_INLINE void R_GLSL_SetUniform_u_MotionBlurY(glslProgram_t *program, GLfloat value) {
qglUniform1fARB(program->u_MotionBlurY, value);
}
static ID_INLINE void R_GLSL_SetUniform_u_CC_Brightness(glslProgram_t *program, GLfloat value) {
qglUniform1fARB(program->u_CC_Brightness, value);
@@ -1953,10 +1913,6 @@ static ID_INLINE void R_GLSL_SetUniform_u_CC_Overbright(glslProgram_t *program,
}
static ID_INLINE void R_GLSL_SetUniform_u_mpasses(glslProgram_t *program, GLint value) {
qglUniform1iARB(program->u_mpasses, value);
}
static ID_INLINE void R_GLSL_SetUniform_u_ActualScreenSizeX(glslProgram_t *program, GLint value) {
qglUniform1iARB(program->u_ActualScreenSizeX, value);
}
@@ -1992,15 +1948,9 @@ static ID_INLINE void R_GLSL_SetUniform_rubyOutputSize(glslProgram_t *program, c
// qglUniform3fARB(program->rubyOutputSize, value, valub, 1.0);
}
static ID_INLINE void R_GLSL_SetUniform_Mpass1(glslProgram_t *program, GLint value) {qglUniform1iARB(program->u_mpass1, value);}
static ID_INLINE void R_GLSL_SetUniform_Mpass2(glslProgram_t *program, GLint value) {qglUniform1iARB(program->u_mpass2, value);}
static ID_INLINE void R_GLSL_SetUniform_Mpass3(glslProgram_t *program, GLint value) {qglUniform1iARB(program->u_mpass3, value);}
static ID_INLINE void R_GLSL_SetUniform_Mpass4(glslProgram_t *program, GLint value) {qglUniform1iARB(program->u_mpass4, value);}
void R_GLSL_Init(void);
qhandle_t RE_GLSL_RegisterProgram(const char *name, const char *programVertexObjects, int numVertexObjects, const char *programFragmentObjects, int numFragmentObjects);
qhandle_t RE_GLSL_RegisterProgramRaw(const char *name, const char *programVertexObjects, int numVertexObjects, const char *programFragmentObjects, int numFragmentObjects);
void R_GLSL_UseProgram(qhandle_t index);
void RB_GLSL_StageIteratorGeneric(void);
void RB_GLSL_StageIteratorVertexLitTexture(void);
@@ -2154,13 +2104,10 @@ void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t
void RB_DeformTessGeometry( void );
void RB_CalcEnvironmentTexCoords( float *dstTexCoords );
void RB_CalcCelTexCoords( float *dstTexCoords ); // leilei - cel hack
void RB_CalcEnvironmentTexCoordsJO( float *dstTexCoords ); // leilei
void RB_CalcEnvironmentTexCoordsR( float *dstTexCoords ); // leilei
void RB_CalcEnvironmentTexCoordsEx( float *st, int xx, int yy, int mode ); // leilei - extra envmapping
void RB_CalcEyes( float *st, qboolean theothereye); // leilei - eyes
void RB_CalcEnvironmentCelShadeTexCoords( float *dstTexCoords );
void RB_CalcEnvironmentTexCoordsNew( float *dstTexCoords );
void RB_CalcEnvironmentTexCoordsHW(void);
void RB_CalcFogTexCoords( float *dstTexCoords );
void RB_CalcScrollTexCoords( const float scroll[2], float *dstTexCoords );
void RB_CalcRotateTexCoords( float rotSpeed, float *dstTexCoords );
@@ -2175,19 +2122,18 @@ void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors );
void RB_CalcAlphaFromEntity( unsigned char *dstColors );
void RB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors );
void RB_CalcStretchTexCoords( const waveForm_t *wf, float *texCoords );
void RB_CalcLightscaleTexCoords( float *texCoords );
void RB_CalcAtlasTexCoords( const atlas_t *at, float *st );
void RB_CalcColorFromEntity( unsigned char *dstColors );
void RB_CalcColorFromOneMinusEntity( unsigned char *dstColors );
void RB_CalcSpecularAlpha( unsigned char *alphas );
void RB_CalcSpecularAlphaNew( unsigned char *alphas );
void RB_CalcGlowBlend( unsigned char *colors, int glowcol, int fx ); // leilei - rgbMod
void RB_CalcUVColor( unsigned char *colors, int glowcol, int fx ); // leilei - rgbMod
void RB_CalcNormalizeToAlpha( unsigned char *colors); // leilei - rgbMod
void RB_CalcDiffuseColor( unsigned char *colors );
void RB_CalcUniformColor( unsigned char *colors );
void RB_CalcDynamicColor( unsigned char *colors );
void RB_CalcDiffuseColor_Specular( unsigned char *colors ); // leilei - specular hack
void RB_CalcFlatAmbient( unsigned char *colors ); // leilei - cel hack
void RB_CalcFlatDirect( unsigned char *colors ); // leilei - cel hack
void RB_CalcNormal( unsigned char *colors ); // leilei - normal hack
void RB_CalcMaterials( unsigned char *colors, int ambient, int diffuse, int specular, int emissive, int spechard, int alpha ); // leilei - materials
void RB_CalcVertLights( unsigned char *colors ); // leilei - dynamic vertex lights
/*
=============================================================
@@ -2347,12 +2293,7 @@ void RE_TakeVideoFrame( int width, int height,
//Bloom Stuff
void R_BloomInit( void );
void R_WaterInit( void );
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);
@@ -2360,14 +2301,10 @@ void R_PostprocessingInit(void);
// leilei
void R_BrightScreen( void );
void R_AltBrightnessInit( void );
void R_FilmScreen( void ); // leilei - film effect
extern int softwaremode;
extern int leifxmode;
extern int voodootype; // 0 - none 1 - Voodoo Graphics 2 - Voodoo2, 3 - Voodoo Banshee/3, 4 - Voodoo4/5
void RB_UpdateMotionBlur (void);
void R_MotionBlur_BackupScreen(int which);
void R_AddParticles (void);
void R_RenderParticles (void);
void R_ClearParticles (void);

View File

@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "tr_local.h"
static float ProjectRadius( float r, vec3_t location )
float ProjectRadius( float r, vec3_t location )
{
float pr;
float dist;

View File

@@ -245,7 +245,21 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa
if ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) {
return;
}
dl = &backEndData->dlights[r_numdlights++];
// leilei - r_monolightmaps also desaturate vertex dynamic lights
float ml = r_monolightmaps->value; // sanitize
if (ml>1) ml=1; if (ml<0) ml=0;
if( ml )
{
float saturated = (r * 0.22126) + (g * 0.7152) + (b * 0.0722);
r = saturated + (r - saturated) * ( 1-ml );
g = saturated + (g - saturated) * ( 1-ml );
b = saturated + (b - saturated) * ( 1-ml );
}
VectorCopy (org, dl->origin);
dl->radius = intensity;
dl->color[0] = r;
@@ -361,7 +375,7 @@ void RE_RenderScene( const refdef_t *fd ) {
// turn off dynamic lighting globally by clearing all the
// dlights if it needs to be disabled or if vertex lighting is enabled
if ( r_dynamiclight->integer == 0 ||
r_vertexLight->integer == 1 ||
// r_vertexLight->integer == 1 || // leilei - commented this out, as we can now do dynamic lights with vertex light
glConfig.hardwareType == GLHW_PERMEDIA2 ) {
tr.refdef.num_dlights = 0;
}

View File

@@ -502,31 +502,6 @@ static void ProjectDlightTexture_altivec( void ) {
origin2 = dl->transformed[2];
radius = dl->radius;
scale = 1.0f / radius;
if(r_greyscale->integer)
{
float luminance;
luminance = LUMA(dl->color[0], dl->color[1], dl->color[2]) * 255.0f;
floatColor[0] = floatColor[1] = floatColor[2] = luminance;
}
else if(r_monolightmaps->integer)
{
float luminance;
luminance = LUMA(dl->color[0], dl->color[1], dl->color[2]) * 255.0f;
floatColor[0] = floatColor[1] = floatColor[2] = luminance;
}
else if(r_greyscale->value)
{
float luminance;
luminance = LUMA(dl->color[0], dl->color[1], dl->color[2]) * 255.0f;
floatColor[0] = LERP(dl->color[0] * 255.0f, luminance, r_greyscale->value);
floatColor[1] = LERP(dl->color[1] * 255.0f, luminance, r_greyscale->value);
floatColor[2] = LERP(dl->color[2] * 255.0f, luminance, r_greyscale->value);
}
else
{
floatColor[0] = dl->color[0] * 255.0f;
floatColor[1] = dl->color[1] * 255.0f;
@@ -673,35 +648,9 @@ static void ProjectDlightTexture_scalar( void ) {
radius = dl->radius;
scale = 1.0f / radius;
if(r_greyscale->integer)
{
float luminance;
luminance = LUMA(dl->color[0], dl->color[1], dl->color[2]) * 255.0f;
floatColor[0] = floatColor[1] = floatColor[2] = luminance;
}
else if(r_monolightmaps->integer)
{
float luminance;
luminance = LUMA(dl->color[0], dl->color[1], dl->color[2]) * 255.0f;
floatColor[0] = floatColor[1] = floatColor[2] = luminance;
}
else if(r_greyscale->value)
{
float luminance;
luminance = LUMA(dl->color[0], dl->color[1], dl->color[2]) * 255.0f;
floatColor[0] = LERP(dl->color[0] * 255.0f, luminance, r_greyscale->value);
floatColor[1] = LERP(dl->color[1] * 255.0f, luminance, r_greyscale->value);
floatColor[2] = LERP(dl->color[2] * 255.0f, luminance, r_greyscale->value);
}
else
{
floatColor[0] = dl->color[0] * 255.0f;
floatColor[1] = dl->color[1] * 255.0f;
floatColor[2] = dl->color[2] * 255.0f;
}
floatColor[0] = dl->color[0] * 255.0f;
floatColor[1] = dl->color[1] * 255.0f;
floatColor[2] = dl->color[2] * 255.0f;
for ( i = 0 ; i < tess.numVertexes ; i++, texCoords += 2, colors += 4 ) {
int clip = 0;
@@ -807,6 +756,7 @@ static void ProjectDlightTexture( void ) {
return;
}
#endif
if ( !r_vertexLight->integer )
ProjectDlightTexture_scalar();
}
@@ -875,49 +825,19 @@ static void ComputeColors( shaderStage_t *pStage )
Com_Memset( tess.svars.colors, tr.identityLightByte, tess.numVertexes * 4 );
break;
case CGEN_LIGHTING_DIFFUSE:
if (r_shownormals->integer > 1 || (pStage->isLeiShade)){
RB_CalcNormal( ( unsigned char * ) tess.svars.colors ); // leilei - debug normals, or use the normals as a color for a lighting shader
break;
}
RB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );
if(r_monolightmaps->integer)
{
int scale;
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][0] = tess.svars.colors[i][1] = tess.svars.colors[i][2] = scale;
}
}
break;
case CGEN_LIGHTING_UNIFORM:
RB_CalcUniformColor( ( unsigned char * ) tess.svars.colors );
break;
case CGEN_LIGHTING_DYNAMIC:
RB_CalcDynamicColor( ( unsigned char * ) tess.svars.colors );
RB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );
break;
case CGEN_LIGHTING_FLAT_AMBIENT:
RB_CalcFlatAmbient( ( unsigned char * ) tess.svars.colors );
if(r_monolightmaps->integer)
{
int scale;
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][0] = tess.svars.colors[i][1] = tess.svars.colors[i][2] = scale;
}
for ( i = 0; i < tess.numVertexes; i++ ) {
*(int *)tess.svars.colors[i] = *(int *)pStage->constantColor;
}
break;
case CGEN_LIGHTING_FLAT_DIRECT:
RB_CalcFlatDirect( ( unsigned char * ) tess.svars.colors );
if(r_monolightmaps->integer)
{
int scale;
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][0] = tess.svars.colors[i][1] = tess.svars.colors[i][2] = scale;
}
for ( i = 0; i < tess.numVertexes; i++ ) {
*(int *)tess.svars.colors[i] = *(int *)pStage->constantColor;
}
break;
case CGEN_EXACT_VERTEX:
@@ -944,35 +864,10 @@ static void ComputeColors( shaderStage_t *pStage )
}
}
break;
case CGEN_VERTEX_LIT: // leilei - mixing vertex colors with lighting through a glorious light hack
{ // should only be used for entity models, not map assets!
vec3_t dcolor, acolor; // to save the color from actual light
vec3_t vcolor;
int y;
// Backup our colors
VectorCopy( backEnd.currentEntity->ambientLight, acolor );
VectorCopy( backEnd.currentEntity->directedLight, dcolor );
VectorCopy( backEnd.currentEntity->e.shaderRGBA, vcolor );
// Make our vertex color take over
for(y=0;y<3;y++){
backEnd.currentEntity->ambientLight[y] *= (vcolor[y] / 255);
if (backEnd.currentEntity->ambientLight[y] < 1) backEnd.currentEntity->ambientLight[y] = 1; // black!!!
if (backEnd.currentEntity->ambientLight[y] > 255) backEnd.currentEntity->ambientLight[y] = 255; // white!!!!!
// backEnd.currentEntity->ambientLight[y] *= (vcolor[y] / 255);
// backEnd.currentEntity->directedLight[y] *= (vcolor[y] / 255);
}
// run it through our favorite preferred lighting calculation functions
RB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );
// Restore light color for any other stage that doesn't do it
VectorCopy( acolor, backEnd.currentEntity->ambientLight);
VectorCopy( dcolor, backEnd.currentEntity->directedLight);
case CGEN_VERTEX_LIT: // leilei - for world only
{
Com_Memcpy( tess.svars.colors, tess.vertexColors, tess.numVertexes * sizeof( tess.vertexColors[0] ) );
RB_CalcVertLights( ( unsigned char * ) tess.svars.colors );
}
break;
case CGEN_ONE_MINUS_VERTEX:
@@ -1015,59 +910,11 @@ static void ComputeColors( shaderStage_t *pStage )
case CGEN_ONE_MINUS_ENTITY:
RB_CalcColorFromOneMinusEntity( ( unsigned char * ) tess.svars.colors );
break;
case CGEN_LIGHTING_DIFFUSE_SPECULAR: // leilei - specular hack
if (r_shownormals->integer > 1 || (pStage->isLeiShade)){
RB_CalcNormal( ( unsigned char * ) tess.svars.colors ); // leilei - debug normals, or use the normals as a color for a lighting shader
break;
}
RB_CalcDiffuseColor_Specular( ( unsigned char * ) tess.svars.colors );
if(r_monolightmaps->integer)
{
int scale;
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][0] = tess.svars.colors[i][1] = tess.svars.colors[i][2] = scale;
}
}
case CGEN_MATERIAL:
RB_CalcMaterials( ( unsigned char * ) tess.svars.colors, pStage->matAmb, pStage->matDif, pStage->matSpec, pStage->matEmis, pStage->matHard, pStage->matAlpha );
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
//
@@ -1153,6 +1000,34 @@ static void ComputeColors( shaderStage_t *pStage )
break;
}
//
// rgbMod
//
switch ( pStage->rgbMod )
{
case CMOD_GLOW:
RB_CalcGlowBlend( ( unsigned char * ) tess.svars.colors, pStage->rgbModCol, pStage->rgbModMode );
break;
case CMOD_UVCOL:
RB_CalcUVColor( ( unsigned char * ) tess.svars.colors, pStage->rgbModCol, pStage->rgbModMode );
break;
case CMOD_NORMALIZETOALPHA:
RB_CalcNormalizeToAlpha( ( unsigned char * ) tess.svars.colors );
break;
case CMOD_NORMALIZETOALPHAFAST: // TODO: use first vert
RB_CalcNormalizeToAlpha( ( unsigned char * ) tess.svars.colors );
break;
case CMOD_OPAQUE:
for ( i = 0; i < tess.numVertexes; i++ )
tess.svars.colors[i][3] = 0xff;
break;
case CMOD_LIGHTING:
// TODO
break;
case CMOD_BAD:
return;
}
//
// fog adjustment for colors to fade out as fog increases
//
@@ -1174,30 +1049,43 @@ static void ComputeColors( shaderStage_t *pStage )
}
}
// if in greyscale rendering mode turn all color values into greyscale.
if(r_greyscale->integer)
{
int scale;
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][0] = tess.svars.colors[i][1] = tess.svars.colors[i][2] = scale;
}
}
else if(r_greyscale->value)
{
float scale;
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][0] = LERP(tess.svars.colors[i][0], scale, r_greyscale->value);
tess.svars.colors[i][1] = LERP(tess.svars.colors[i][1], scale, r_greyscale->value);
tess.svars.colors[i][2] = LERP(tess.svars.colors[i][2], scale, r_greyscale->value);
}
}
}
/*
===============
ComputeUVColors
===============
*/
static void ComputeUVColors( shaderStage_t *pStage )
{
//
// rgbMod
//
switch ( pStage->rgbMod )
{
case CMOD_GLOW:
// we do this elsewhere
break;
case CMOD_UVCOL:
RB_CalcUVColor( ( unsigned char * ) tess.svars.colors, pStage->rgbModCol, pStage->rgbModMode );
break;
case CMOD_NORMALIZETOALPHA:
break;
case CMOD_NORMALIZETOALPHAFAST: // TODO: use first vert
break;
case CMOD_OPAQUE:
break;
case CMOD_LIGHTING:
break;
case CMOD_BAD:
return;
}
}
/*
===============
ComputeTexCoords
@@ -1243,13 +1131,7 @@ static void ComputeTexCoords( shaderStage_t *pStage ) {
RB_CalcEnvironmentTexCoords( ( float * ) tess.svars.texcoords[b] );
break;
case TCGEN_ENVIRONMENT_MAPPED_WATER:
RB_CalcEnvironmentTexCoordsJO( ( float * ) tess.svars.texcoords[b] );
break;
case TCGEN_ENVIRONMENT_CELSHADE_MAPPED:
RB_CalcEnvironmentCelShadeTexCoords( ( float * ) tess.svars.texcoords[b] );
break;
case TCGEN_ENVIRONMENT_CELSHADE_LEILEI:
RB_CalcCelTexCoords( ( float * ) tess.svars.texcoords[b] );
RB_CalcEnvironmentTexCoordsEx( ( float * ) tess.svars.texcoords[b], 0, 1, 1 );
break;
case TCGEN_EYE_LEFT:
RB_CalcEyes( ( float * ) tess.svars.texcoords[b], 1);
@@ -1301,10 +1183,6 @@ static void ComputeTexCoords( shaderStage_t *pStage ) {
( float * ) tess.svars.texcoords[b] );
break;
case TMOD_LIGHTSCALE:
RB_CalcLightscaleTexCoords( ( float * ) tess.svars.texcoords[b] );
break;
case TMOD_TRANSFORM:
RB_CalcTransformTexCoords( &pStage->bundle[b].texMods[tm],
( float * ) tess.svars.texcoords[b] );
@@ -1373,10 +1251,6 @@ void GLSL_Feeder(shaderStage_t *pStage, shaderCommands_t *input)
if (program->u_FogColor > -1 && tess.fogNum)
R_GLSL_SetUniform_FogColor(program, (tr.world->fogs + tess.fogNum)->colorInt);
/* greyscale */
if (program->u_Greyscale > -1)
R_GLSL_SetUniform_Greyscale(program, r_greyscale->integer);
/* identity light */
if (program->u_IdentityLight > -1)
R_GLSL_SetUniform_IdentityLight(program, tr.identityLight);
@@ -1468,11 +1342,6 @@ void GLSL_Feeder(shaderStage_t *pStage, shaderCommands_t *input)
R_BindAnimatedImage(&pStage->bundle[7]);
}
if (program->u_mpass1 > -1 && pStage->bundle[1].image[0]) { GL_SelectTexture(11); qglEnable(GL_TEXTURE_2D); R_BindAnimatedImage(&pStage->bundle[11]);}
if (program->u_mpass2 > -1 && pStage->bundle[1].image[0]) { GL_SelectTexture(12); qglEnable(GL_TEXTURE_2D); R_BindAnimatedImage(&pStage->bundle[12]);}
if (program->u_mpass3 > -1 && pStage->bundle[1].image[0]) { GL_SelectTexture(13); qglEnable(GL_TEXTURE_2D); R_BindAnimatedImage(&pStage->bundle[13]);}
if (program->u_mpass4 > -1 && pStage->bundle[1].image[0]) { GL_SelectTexture(14); qglEnable(GL_TEXTURE_2D); R_BindAnimatedImage(&pStage->bundle[14]);}
/* time */
if (program->u_Time > -1)
R_GLSL_SetUniform_Time(program, input->shaderTime);
@@ -1488,11 +1357,6 @@ void GLSL_Clean(void)
{
glslProgram_t *program;
program = tr.programs[glState.currentProgram];
if (program->u_mpass1 > -1) { GL_SelectTexture(11); qglDisable(GL_TEXTURE_2D); }
if (program->u_mpass2 > -1) { GL_SelectTexture(12); qglDisable(GL_TEXTURE_2D); }
if (program->u_mpass3 > -1) { GL_SelectTexture(13); qglDisable(GL_TEXTURE_2D); }
if (program->u_mpass4 > -1) { GL_SelectTexture(14); qglDisable(GL_TEXTURE_2D); }
/* disable texture unit 7 */
if (program->u_Texture7 > -1)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -25,6 +25,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define SKY_SUBDIVISIONS 8
#define HALF_SKY_SUBDIVISIONS (SKY_SUBDIVISIONS/2)
// leilei - optimizing sky
static int SkySub = 8;
static int HalfSkySub = 4;
static float s_cloudTexCoords[6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2];
static float s_cloudTexP[6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1];
@@ -309,6 +313,7 @@ static void MakeSkyVec( float s, float t, int axis, float outSt[2], vec3_t outXY
float boxSize;
boxSize = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
b[0] = s*boxSize;
b[1] = t*boxSize;
b[2] = boxSize;
@@ -367,11 +372,11 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
GL_Bind( image );
for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t < maxs[1]+HALF_SKY_SUBDIVISIONS; t++ )
for ( t = mins[1]+HalfSkySub; t < maxs[1]+HalfSkySub; t++ )
{
qglBegin( GL_TRIANGLE_STRIP );
for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ )
for ( s = mins[0]+HalfSkySub; s <= maxs[0]+HalfSkySub; s++ )
{
qglTexCoord2fv( s_skyTexCoords[t][s] );
qglVertex3fv( s_skyPoints[t][s] );
@@ -398,10 +403,10 @@ static void DrawSkyBox( shader_t *shader )
int sky_mins_subd[2], sky_maxs_subd[2];
int s, t;
sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
sky_mins[0][i] = floor( sky_mins[0][i] * HalfSkySub ) / HalfSkySub;
sky_mins[1][i] = floor( sky_mins[1][i] * HalfSkySub ) / HalfSkySub;
sky_maxs[0][i] = ceil( sky_maxs[0][i] * HalfSkySub ) / HalfSkySub;
sky_maxs[1][i] = ceil( sky_maxs[1][i] * HalfSkySub ) / HalfSkySub;
if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||
( sky_mins[1][i] >= sky_maxs[1][i] ) )
@@ -409,38 +414,38 @@ static void DrawSkyBox( shader_t *shader )
continue;
}
sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS;
sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS;
sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS;
sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS;
sky_mins_subd[0] = sky_mins[0][i] * HalfSkySub;
sky_mins_subd[1] = sky_mins[1][i] * HalfSkySub;
sky_maxs_subd[0] = sky_maxs[0][i] * HalfSkySub;
sky_maxs_subd[1] = sky_maxs[1][i] * HalfSkySub;
if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS )
sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;
else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS )
sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;
if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS )
sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS;
else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS )
sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;
if ( sky_mins_subd[0] < -HalfSkySub )
sky_mins_subd[0] = -HalfSkySub;
else if ( sky_mins_subd[0] > HalfSkySub )
sky_mins_subd[0] = HalfSkySub;
if ( sky_mins_subd[1] < -HalfSkySub )
sky_mins_subd[1] = -HalfSkySub;
else if ( sky_mins_subd[1] > HalfSkySub )
sky_mins_subd[1] = HalfSkySub;
if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS )
sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;
else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS )
sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;
if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS )
sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS;
else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS )
sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;
if ( sky_maxs_subd[0] < -HalfSkySub )
sky_maxs_subd[0] = -HalfSkySub;
else if ( sky_maxs_subd[0] > HalfSkySub )
sky_maxs_subd[0] = HalfSkySub;
if ( sky_maxs_subd[1] < -HalfSkySub )
sky_maxs_subd[1] = -HalfSkySub;
else if ( sky_maxs_subd[1] > HalfSkySub )
sky_maxs_subd[1] = HalfSkySub;
//
// iterate through the subdivisions
//
for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
for ( t = sky_mins_subd[1]+HalfSkySub; t <= sky_maxs_subd[1]+HalfSkySub; t++ )
{
for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
for ( s = sky_mins_subd[0]+HalfSkySub; s <= sky_maxs_subd[0]+HalfSkySub; s++ )
{
MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
MakeSkyVec( ( s - HalfSkySub ) / ( float ) HalfSkySub,
( t - HalfSkySub ) / ( float ) HalfSkySub,
i,
s_skyTexCoords[t][s],
s_skyPoints[t][s] );
@@ -463,9 +468,9 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad
tHeight = maxs[1] - mins[1] + 1;
sWidth = maxs[0] - mins[0] + 1;
for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ )
for ( t = mins[1]+HalfSkySub; t <= maxs[1]+HalfSkySub; t++ )
{
for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ )
for ( s = mins[0]+HalfSkySub; s <= maxs[0]+HalfSkySub; s++ )
{
VectorAdd( s_skyPoints[t][s], backEnd.viewParms.or.origin, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0];
@@ -516,7 +521,7 @@ static void FillCloudBox( const shader_t *shader, int stage )
if ( 1 ) // FIXME? shader->sky.fullClouds )
{
MIN_T = -HALF_SKY_SUBDIVISIONS;
MIN_T = -HalfSkySub;
// still don't want to draw the bottom, even if fullClouds
if ( i == 5 )
@@ -537,15 +542,15 @@ static void FillCloudBox( const shader_t *shader, int stage )
continue;
case 4: // top
default:
MIN_T = -HALF_SKY_SUBDIVISIONS;
MIN_T = -HalfSkySub;
break;
}
}
sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
sky_mins[0][i] = floor( sky_mins[0][i] * HalfSkySub ) / HalfSkySub;
sky_mins[1][i] = floor( sky_mins[1][i] * HalfSkySub ) / HalfSkySub;
sky_maxs[0][i] = ceil( sky_maxs[0][i] * HalfSkySub ) / HalfSkySub;
sky_maxs[1][i] = ceil( sky_maxs[1][i] * HalfSkySub ) / HalfSkySub;
if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||
( sky_mins[1][i] >= sky_maxs[1][i] ) )
@@ -553,38 +558,38 @@ static void FillCloudBox( const shader_t *shader, int stage )
continue;
}
sky_mins_subd[0] = ri.ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS);
sky_mins_subd[1] = ri.ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS);
sky_maxs_subd[0] = ri.ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS);
sky_maxs_subd[1] = ri.ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS);
sky_mins_subd[0] = ri.ftol(sky_mins[0][i] * HalfSkySub);
sky_mins_subd[1] = ri.ftol(sky_mins[1][i] * HalfSkySub);
sky_maxs_subd[0] = ri.ftol(sky_maxs[0][i] * HalfSkySub);
sky_maxs_subd[1] = ri.ftol(sky_maxs[1][i] * HalfSkySub);
if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS )
sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;
else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS )
sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;
if ( sky_mins_subd[0] < -HalfSkySub )
sky_mins_subd[0] = -HalfSkySub;
else if ( sky_mins_subd[0] > HalfSkySub )
sky_mins_subd[0] = HalfSkySub;
if ( sky_mins_subd[1] < MIN_T )
sky_mins_subd[1] = MIN_T;
else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS )
sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;
else if ( sky_mins_subd[1] > HalfSkySub )
sky_mins_subd[1] = HalfSkySub;
if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS )
sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;
else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS )
sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;
if ( sky_maxs_subd[0] < -HalfSkySub )
sky_maxs_subd[0] = -HalfSkySub;
else if ( sky_maxs_subd[0] > HalfSkySub )
sky_maxs_subd[0] = HalfSkySub;
if ( sky_maxs_subd[1] < MIN_T )
sky_maxs_subd[1] = MIN_T;
else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS )
sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;
else if ( sky_maxs_subd[1] > HalfSkySub )
sky_maxs_subd[1] = HalfSkySub;
//
// iterate through the subdivisions
//
for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
for ( t = sky_mins_subd[1]+HalfSkySub; t <= sky_maxs_subd[1]+HalfSkySub; t++ )
{
for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
for ( s = sky_mins_subd[0]+HalfSkySub; s <= sky_maxs_subd[0]+HalfSkySub; s++ )
{
MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
MakeSkyVec( ( s - HalfSkySub ) / ( float ) HalfSkySub,
( t - HalfSkySub ) / ( float ) HalfSkySub,
i,
NULL,
s_skyPoints[t][s] );
@@ -644,19 +649,30 @@ void R_InitSkyTexCoords( float heightCloud )
vec3_t skyVec;
vec3_t v;
// leilei - sky optimizations
SkySub = r_skytess->integer;
HalfSkySub = r_skytess->integer / 2;
if (SkySub < 2) SkySub = 2;
if (SkySub > 8) SkySub = 8;
if (HalfSkySub < 1) HalfSkySub = 1;
if (HalfSkySub > 4) HalfSkySub = 4;
// init zfar so MakeSkyVec works even though
// a world hasn't been bounded
backEnd.viewParms.zFar = 1024;
for ( i = 0; i < 6; i++ )
{
for ( t = 0; t <= SKY_SUBDIVISIONS; t++ )
for ( t = 0; t <= SkySub; t++ )
{
for ( s = 0; s <= SKY_SUBDIVISIONS; s++ )
for ( s = 0; s <= SkySub; s++ )
{
// compute vector from view origin to sky side integral point
MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
MakeSkyVec( ( s - HalfSkySub ) / ( float ) HalfSkySub,
( t - HalfSkySub ) / ( float ) HalfSkySub,
i,
NULL,
skyVec );
@@ -705,6 +721,7 @@ void RB_DrawSun( void ) {
if ( !backEnd.skyRenderedThisView ) {
return;
}
// TODO: Add a sun check for sky shaders explicitly requesting for the sun, to keep compatibility with sun-less skies.
if ( !r_drawSun->integer ) {
return;
}
@@ -838,7 +855,9 @@ void RB_StageIteratorSky( void ) {
// r_showsky will let all the sky blocks be drawn in
// front of everything to allow developers to see how
// much sky is getting sucked in
if ( r_showsky->integer ) {
if ( r_showsky->integer == 2) {
qglDepthRange( 0.0, 1.0 ); // leilei - pvr1 imitation
} else if ( r_showsky->integer ) {
qglDepthRange( 0.0, 0.0 );
} else {
qglDepthRange( 1.0, 1.0 );

View File

@@ -51,12 +51,6 @@ typedef void *QGLContext;
static QGLContext opengl_context;
#endif
int tvMode; // leilei - tvmode
int tvWidth;
int tvHeight;
int tvinterlace = 1; // leilei - interlace value for height
float tvAspectW; // leilei - for aspect correction
//int vresWidth;
//int vresHeight;
@@ -80,11 +74,6 @@ static const SDL_VideoInfo *videoInfo = NULL;
#endif
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_tvFilter; // leilei - tv filter
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
cvar_t *r_centerWindow;
@@ -280,7 +269,6 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
int sdlcolorbits;
int colorbits, depthbits, stencilbits;
int tcolorbits, tdepthbits, tstencilbits;
int accumbits; // leilei - motionblur
int samples;
int i = 0;
SDL_Surface *icon = NULL;
@@ -438,12 +426,6 @@ 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
@@ -519,12 +501,6 @@ 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 );
@@ -651,12 +627,6 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
}
#endif
//
// leilei - TV MODE
//
tvWidth = glConfig.vidWidth;
tvHeight = glConfig.vidHeight;
vresWidth = glConfig.vidWidth;
vresHeight = glConfig.vidHeight;
@@ -665,44 +635,10 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
vresWidth = 640;
vresHeight = 480;
//tvAspectW = 1.0; // no change
if( r_tvMode->integer > -1){
if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, r_tvMode->integer ) )
{
glConfig.vidWidth = 640; // if we can't do a mode then do this mode
glConfig.vidHeight = 480;
}
if (glConfig.vidWidth > tvWidth) glConfig.vidWidth = tvWidth; // clamp
if (glConfig.vidHeight > tvHeight) glConfig.vidHeight = tvHeight; // clamp
// 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 ){
float ttw = (float)glConfig.vidWidth / ((float)tvWidth * (float)((float)glConfig.vidHeight/(float)tvHeight)); // 640 / 853 = 0.75 = ASPECT VALUE
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
#if SDL_MAJOR_VERSION != 2
screen = vidscreen;
#endif
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);
@@ -967,15 +903,6 @@ void GLimp_Init( void )
r_sdlDriver = ri.Cvar_Get( "r_sdlDriver", "", CVAR_ROM );
r_allowResize = ri.Cvar_Get( "r_allowResize", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_centerWindow = ri.Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE | CVAR_LATCH );
// leilei - tv mode hack
r_tvMode = ri.Cvar_Get( "r_virtualMode", "-1", 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_tvFilter = ri.Cvar_Get( "r_tvFilter", "1", CVAR_LATCH | CVAR_ARCHIVE );
// 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" ) )
{

View File

@@ -1204,6 +1204,7 @@ static void IN_ProcessEvents( void )
case SDL_WINDOWEVENT_MAXIMIZED: Cvar_SetValue( "com_minimized", 0 ); break;
case SDL_WINDOWEVENT_FOCUS_LOST: Cvar_SetValue( "com_unfocused", 1 ); break;
case SDL_WINDOWEVENT_FOCUS_GAINED: Cvar_SetValue( "com_unfocused", 0 ); break;
case SDL_WINDOWEVENT_CLOSE: Cbuf_ExecuteText(EXEC_NOW, "quit Closed window\n"); break;
}
break;
#else

View File

@@ -677,8 +677,7 @@ void SV_Init (void)
Cvar_Get ("sv_dlURL", "", CVAR_SERVERINFO | CVAR_ARCHIVE);
sv_master[0] = Cvar_Get("sv_master1", MASTER_SERVER_NAME, 0);
sv_master[1] = Cvar_Get("sv_master2", "master.ioquake3.org", 0);
for(index = 2; index < MAX_MASTER_SERVERS; index++)
for(index = 1; index < MAX_MASTER_SERVERS; index++)
sv_master[index] = Cvar_Get(va("sv_master%d", index + 1), "", CVAR_ARCHIVE);
sv_reconnectlimit = Cvar_Get ("sv_reconnectlimit", "3", 0);