mirror of
https://github.com/ReactionQuake3/reaction.git
synced 2025-01-23 01:50:41 +00:00
Appying the differences between v11 and v12 renderers
This commit is contained in:
parent
e8c2e6ba5b
commit
23fb28d4c9
10 changed files with 1198 additions and 1277 deletions
|
@ -914,7 +914,6 @@ Used for cinematics.
|
|||
void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
|
||||
int i, j;
|
||||
int start, end;
|
||||
matrix_t matrix;
|
||||
|
||||
if ( !tr.registered ) {
|
||||
return;
|
||||
|
@ -1022,22 +1021,13 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
|
|||
|
||||
if (glRefConfig.glsl && r_arb_shader_objects->integer)
|
||||
{
|
||||
shaderProgram_t *sp = &tr.genericShader[0];
|
||||
shaderProgram_t *sp = &tr.textureOnlyShader;
|
||||
|
||||
GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD);
|
||||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniform_ModelViewProjectionMatrix(sp, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniform_FogAdjustColors(sp, 0);
|
||||
GLSL_SetUniform_DeformGen(sp, DGEN_NONE);
|
||||
GLSL_SetUniform_TCGen0(sp, TCGEN_TEXTURE);
|
||||
Matrix16Identity(matrix);
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniform_Texture1Env(sp, 0);
|
||||
GLSL_SetUniform_ColorGen(sp, CGEN_IDENTITY);
|
||||
GLSL_SetUniform_AlphaGen(sp, AGEN_IDENTITY);
|
||||
GLSL_SetUniformMatrix16(sp, TEXTUREONLY_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ int c_subdivisions;
|
|||
int c_gridVerts;
|
||||
|
||||
//===============================================================================
|
||||
/*
|
||||
#if 0
|
||||
static void HSVtoRGB( float h, float s, float v, float rgb[3] )
|
||||
{
|
||||
int i;
|
||||
|
@ -742,7 +742,9 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, i
|
|||
cv->numTriangles -= badTriangles;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
===============
|
||||
ParseFlare
|
||||
|
@ -773,6 +775,7 @@ static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int
|
|||
flare->normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
@ -2795,6 +2798,10 @@ void R_MergeLeafSurfaces(void)
|
|||
|
||||
default:
|
||||
break;
|
||||
|
||||
// never happens, but silences a compile warning
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ void R_PerformanceCounters( void ) {
|
|||
{
|
||||
ri.Printf( PRINT_ALL, "VBO draws: static %i dynamic %i\nMultidraws: %i merged %i\n",
|
||||
backEnd.pc.c_staticVboDraws, backEnd.pc.c_dynamicVboDraws, backEnd.pc.c_multidraws, backEnd.pc.c_multidrawsMerged );
|
||||
ri.Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i lightmap %i fog %i dlight %i\n",
|
||||
backEnd.pc.c_glslShaderBinds, backEnd.pc.c_genericDraws, backEnd.pc.c_lightmappedDraws, backEnd.pc.c_fogDraws, backEnd.pc.c_dlightDraws);
|
||||
}
|
||||
|
||||
Com_Memset( &tr.pc, 0, sizeof( tr.pc ) );
|
||||
|
|
|
@ -83,10 +83,10 @@ void Matrix16Transform( const matrix_t in1, const vec4_t in2, vec4_t out )
|
|||
|
||||
qboolean Matrix16Compare( const matrix_t a, const matrix_t b )
|
||||
{
|
||||
return (a[ 0] == b[ 0] && a[ 4] == b[ 4] && a[ 8] == b[ 8] && a[12] == b[12] &&
|
||||
a[ 1] == b[ 1] && a[ 5] == b[ 5] && a[ 9] == b[ 9] && a[13] == b[13] &&
|
||||
a[ 2] == b[ 2] && a[ 6] == b[ 6] && a[10] == b[10] && a[14] == b[14] &&
|
||||
a[ 3] == b[ 3] && a[ 7] == b[ 7] && a[11] == b[11] && a[15] == b[15]);
|
||||
return !(a[ 0] != b[ 0] || a[ 4] != b[ 4] || a[ 8] != b[ 8] || a[12] != b[12] ||
|
||||
a[ 1] != b[ 1] || a[ 5] != b[ 5] || a[ 9] != b[ 9] || a[13] != b[13] ||
|
||||
a[ 2] != b[ 2] || a[ 6] != b[ 6] || a[10] != b[10] || a[14] != b[14] ||
|
||||
a[ 3] != b[ 3] || a[ 7] != b[ 7] || a[11] != b[11] || a[15] != b[15]);
|
||||
}
|
||||
|
||||
void Matrix16Dump( const matrix_t in )
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -677,6 +677,15 @@ enum
|
|||
GLSLDEF_COUNT = 0x0010,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GLSL_INT,
|
||||
GLSL_FLOAT,
|
||||
GLSL_VEC2,
|
||||
GLSL_VEC3,
|
||||
GLSL_VEC4,
|
||||
GLSL_MAT16
|
||||
};
|
||||
|
||||
// Tr3B - shaderProgram_t represents a pair of one
|
||||
// GLSL vertex and one GLSL fragment shader
|
||||
|
@ -690,841 +699,101 @@ typedef struct shaderProgram_s
|
|||
uint32_t attribs; // vertex array attributes
|
||||
|
||||
// uniform parameters
|
||||
GLint u_Texture0Map;
|
||||
GLint u_Texture1Map;
|
||||
GLint u_Texture2Map;
|
||||
GLint u_Texture3Map;
|
||||
|
||||
GLint u_PortalRange;
|
||||
float t_PortalRange;
|
||||
|
||||
GLint u_FogAdjustColors;
|
||||
int t_FogAdjustColors;
|
||||
|
||||
GLint u_FogDistance;
|
||||
vec4_t t_FogDistance;
|
||||
|
||||
GLint u_FogDepth;
|
||||
vec4_t t_FogDepth;
|
||||
|
||||
GLint u_FogEyeT;
|
||||
float t_FogEyeT;
|
||||
|
||||
GLint u_ModelMatrix; // model -> world
|
||||
matrix_t t_ModelMatrix;
|
||||
|
||||
GLint u_ModelViewProjectionMatrix;
|
||||
matrix_t t_ModelViewProjectionMatrix;
|
||||
|
||||
GLint u_AlphaTest;
|
||||
alphaTest_t t_AlphaTest;
|
||||
|
||||
GLint u_ColorGen;
|
||||
colorGen_t t_ColorGen;
|
||||
|
||||
GLint u_AlphaGen;
|
||||
alphaGen_t t_AlphaGen;
|
||||
|
||||
GLint u_TCGen0;
|
||||
texCoordGen_t t_TCGen0;
|
||||
|
||||
GLint u_TCGen1;
|
||||
texCoordGen_t t_TCGen1;
|
||||
|
||||
GLint u_TCGen0Vector0;
|
||||
vec4_t t_TCGen0Vector0;
|
||||
|
||||
GLint u_TCGen0Vector1;
|
||||
vec4_t t_TCGen0Vector1;
|
||||
|
||||
GLint u_TCGen1Vector0;
|
||||
vec4_t t_TCGen1Vector0;
|
||||
|
||||
GLint u_TCGen1Vector1;
|
||||
vec4_t t_TCGen1Vector1;
|
||||
|
||||
GLint u_DeformGen;
|
||||
deformGen_t t_DeformGen;
|
||||
|
||||
GLint u_DeformWave;
|
||||
vec4_t t_DeformWave;
|
||||
|
||||
GLint u_DeformBulge;
|
||||
vec3_t t_DeformBulge;
|
||||
|
||||
GLint u_DeformSpread;
|
||||
float t_DeformSpread;
|
||||
|
||||
GLint u_Time;
|
||||
float t_Time;
|
||||
|
||||
GLint u_Color;
|
||||
vec4_t t_Color;
|
||||
|
||||
GLint u_AmbientLight;
|
||||
vec3_t t_AmbientLight;
|
||||
|
||||
GLint u_DirectedLight;
|
||||
vec3_t t_DirectedLight;
|
||||
|
||||
GLint u_LightDir;
|
||||
vec3_t t_LightDir;
|
||||
|
||||
GLint u_ViewOrigin;
|
||||
vec4_t t_ViewOrigin;
|
||||
|
||||
GLint u_Texture0Matrix;
|
||||
matrix_t t_Texture0Matrix;
|
||||
|
||||
GLint u_Texture1Matrix;
|
||||
matrix_t t_Texture1Matrix;
|
||||
|
||||
GLint u_Texture1Env;
|
||||
uint32_t t_Texture1Env;
|
||||
|
||||
GLint u_Texture2Matrix;
|
||||
matrix_t t_Texture2Matrix;
|
||||
|
||||
GLint u_Texture3Matrix;
|
||||
matrix_t t_Texture3Matrix;
|
||||
|
||||
GLint u_VertexLerp;
|
||||
float t_VertexLerp;
|
||||
|
||||
int numUniforms;
|
||||
GLint *uniforms;
|
||||
GLint *uniformTypes;
|
||||
int *uniformBufferOffsets;
|
||||
char *uniformBuffer;
|
||||
} shaderProgram_t;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
LIGHTMAPPED_UNIFORM_MODELVIEWPROJECTIONMATRIX = 0,
|
||||
LIGHTMAPPED_UNIFORM_TEXTURE0MATRIX,
|
||||
LIGHTMAPPED_UNIFORM_TEXTURE1ENV,
|
||||
LIGHTMAPPED_UNIFORM_TEXTURE0MAP,
|
||||
LIGHTMAPPED_UNIFORM_TEXTURE1MAP,
|
||||
LIGHTMAPPED_UNIFORM_COUNT
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
TEXTUREONLY_UNIFORM_MODELVIEWPROJECTIONMATRIX = 0,
|
||||
TEXTUREONLY_UNIFORM_TEXTURE0MAP,
|
||||
TEXTUREONLY_UNIFORM_COUNT
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
FOGPASS_UNIFORM_FOGDISTANCE = 0,
|
||||
FOGPASS_UNIFORM_FOGDEPTH,
|
||||
FOGPASS_UNIFORM_FOGEYET,
|
||||
FOGPASS_UNIFORM_DEFORMGEN,
|
||||
FOGPASS_UNIFORM_DEFORMWAVE,
|
||||
FOGPASS_UNIFORM_DEFORMBULGE,
|
||||
FOGPASS_UNIFORM_DEFORMSPREAD,
|
||||
FOGPASS_UNIFORM_TIME,
|
||||
FOGPASS_UNIFORM_COLOR,
|
||||
FOGPASS_UNIFORM_MODELVIEWPROJECTIONMATRIX,
|
||||
FOGPASS_UNIFORM_VERTEXLERP,
|
||||
FOGPASS_UNIFORM_COUNT
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
DLIGHT_UNIFORM_DLIGHTINFO = 0,
|
||||
DLIGHT_UNIFORM_DEFORMGEN,
|
||||
DLIGHT_UNIFORM_DEFORMWAVE,
|
||||
DLIGHT_UNIFORM_DEFORMBULGE,
|
||||
DLIGHT_UNIFORM_DEFORMSPREAD,
|
||||
DLIGHT_UNIFORM_TIME,
|
||||
DLIGHT_UNIFORM_COLOR,
|
||||
DLIGHT_UNIFORM_MODELVIEWPROJECTIONMATRIX,
|
||||
DLIGHT_UNIFORM_VERTEXLERP,
|
||||
DLIGHT_UNIFORM_COUNT
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
GENERIC_UNIFORM_TEXTURE0MAP = 0,
|
||||
GENERIC_UNIFORM_TEXTURE1MAP,
|
||||
GENERIC_UNIFORM_TEXTURE0MATRIX,
|
||||
GENERIC_UNIFORM_TEXTURE1ENV,
|
||||
GENERIC_UNIFORM_VIEWORIGIN,
|
||||
GENERIC_UNIFORM_TCGEN0,
|
||||
GENERIC_UNIFORM_TCGEN0VECTOR0,
|
||||
GENERIC_UNIFORM_TCGEN0VECTOR1,
|
||||
GENERIC_UNIFORM_DEFORMGEN,
|
||||
GENERIC_UNIFORM_DEFORMWAVE,
|
||||
GENERIC_UNIFORM_DEFORMBULGE,
|
||||
GENERIC_UNIFORM_DEFORMSPREAD,
|
||||
GENERIC_UNIFORM_COLORGEN,
|
||||
GENERIC_UNIFORM_ALPHAGEN,
|
||||
GENERIC_UNIFORM_COLOR,
|
||||
GENERIC_UNIFORM_AMBIENTLIGHT,
|
||||
GENERIC_UNIFORM_DIRECTEDLIGHT,
|
||||
GENERIC_UNIFORM_LIGHTDIR,
|
||||
GENERIC_UNIFORM_PORTALRANGE,
|
||||
GENERIC_UNIFORM_FOGDISTANCE,
|
||||
GENERIC_UNIFORM_FOGDEPTH,
|
||||
GENERIC_UNIFORM_FOGEYET,
|
||||
GENERIC_UNIFORM_FOGADJUSTCOLORS,
|
||||
GENERIC_UNIFORM_MODELVIEWPROJECTIONMATRIX,
|
||||
GENERIC_UNIFORM_TIME,
|
||||
GENERIC_UNIFORM_VERTEXLERP,
|
||||
GENERIC_UNIFORM_COUNT
|
||||
};
|
||||
|
||||
//
|
||||
// Tr3B: these are fire wall functions to avoid expensive redundant glUniform* calls
|
||||
#define USE_UNIFORM_FIREWALL 1
|
||||
//#define LOG_GLSL_UNIFORMS 1
|
||||
|
||||
#if defined(LOG_GLSL_UNIFORMS)
|
||||
extern cvar_t *r_logFile; // number of frames to emit GL logs
|
||||
void GLimp_LogComment(char *comment);
|
||||
#define GLimp_LogUniformComment(...) GLimp_LogComment(__VA_ARGS__)
|
||||
#else
|
||||
#define GLimp_LogUniformComment(...)
|
||||
#endif
|
||||
|
||||
// *INDENT-OFF*
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_Texture0Matrix(shaderProgram_t * program, const matrix_t m)
|
||||
{
|
||||
if (program->u_Texture0Matrix == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(Matrix16Compare(program->t_Texture0Matrix, m))
|
||||
return;
|
||||
|
||||
Matrix16Copy(m, program->t_Texture0Matrix);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_Texture0Matrix( program = %s, "
|
||||
"matrix = \n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n",
|
||||
program->name,
|
||||
m[0], m[4], m[8], m[12],
|
||||
m[1], m[5], m[9], m[13],
|
||||
m[2], m[6], m[10], m[14],
|
||||
m[3], m[7], m[11], m[15]));
|
||||
|
||||
qglUniformMatrix4fvARB(program->u_Texture0Matrix, 1, GL_FALSE, m);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_Texture1Matrix(shaderProgram_t * program, const matrix_t m)
|
||||
{
|
||||
if (program->u_Texture1Matrix == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(Matrix16Compare(program->t_Texture1Matrix, m))
|
||||
return;
|
||||
|
||||
Matrix16Copy(m, program->t_Texture1Matrix);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_Texture1Matrix( program = %s, "
|
||||
"matrix = \n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n",
|
||||
program->name,
|
||||
m[0], m[4], m[8], m[12],
|
||||
m[1], m[5], m[9], m[13],
|
||||
m[2], m[6], m[10], m[14],
|
||||
m[3], m[7], m[11], m[15]));
|
||||
|
||||
qglUniformMatrix4fvARB(program->u_Texture1Matrix, 1, GL_FALSE, m);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_Texture1Env(shaderProgram_t * program, uint32_t env)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
if (program->u_Texture1Env == -1)
|
||||
return;
|
||||
|
||||
switch ( env )
|
||||
{
|
||||
case GL_MODULATE:
|
||||
value = 1;
|
||||
break;
|
||||
case GL_REPLACE:
|
||||
value = 2;
|
||||
break;
|
||||
case GL_DECAL:
|
||||
value = 3;
|
||||
break;
|
||||
case GL_ADD:
|
||||
value = 4;
|
||||
break;
|
||||
default:
|
||||
value = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_Texture1Env == value)
|
||||
return;
|
||||
|
||||
program->t_Texture1Env = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_Texture1Env( program = %s, value = %i ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1iARB(program->u_Texture1Env, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_Texture2Matrix(shaderProgram_t * program, const matrix_t m)
|
||||
{
|
||||
if (program->u_Texture2Matrix == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(Matrix16Compare(program->t_Texture2Matrix, m))
|
||||
return;
|
||||
|
||||
Matrix16Copy(m, program->t_Texture2Matrix);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_Texture2Matrix( program = %s, "
|
||||
"matrix = \n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n",
|
||||
program->name,
|
||||
m[0], m[4], m[8], m[12],
|
||||
m[1], m[5], m[9], m[13],
|
||||
m[2], m[6], m[10], m[14],
|
||||
m[3], m[7], m[11], m[15]));
|
||||
|
||||
qglUniformMatrix4fvARB(program->u_Texture2Matrix, 1, GL_FALSE, m);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_Texture3Matrix(shaderProgram_t * program, const matrix_t m)
|
||||
{
|
||||
if (program->u_Texture3Matrix == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(Matrix16Compare(program->t_Texture3Matrix, m))
|
||||
return;
|
||||
|
||||
Matrix16Copy(m, program->t_Texture3Matrix);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_Texture3Matrix( program = %s, "
|
||||
"matrix = \n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n",
|
||||
program->name,
|
||||
m[0], m[4], m[8], m[12],
|
||||
m[1], m[5], m[9], m[13],
|
||||
m[2], m[6], m[10], m[14],
|
||||
m[3], m[7], m[11], m[15]));
|
||||
|
||||
qglUniformMatrix4fvARB(program->u_Texture3Matrix, 1, GL_FALSE, m);
|
||||
}
|
||||
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_AlphaTest(shaderProgram_t * program, uint32_t stateBits)
|
||||
{
|
||||
alphaTest_t value;
|
||||
|
||||
if (program->u_AlphaTest == -1)
|
||||
return;
|
||||
|
||||
switch (stateBits & GLS_ATEST_BITS)
|
||||
{
|
||||
case GLS_ATEST_GT_0:
|
||||
value = ATEST_GT_0;
|
||||
break;
|
||||
|
||||
case GLS_ATEST_LT_128:
|
||||
value = ATEST_LT_128;
|
||||
break;
|
||||
|
||||
case GLS_ATEST_GE_128:
|
||||
value = ATEST_GE_128;
|
||||
break;
|
||||
|
||||
default:
|
||||
value = ATEST_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
// don't just call LogComment, or we will get
|
||||
// a call to va() every frame!
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniformAlphaTest( program = %s, value = %i ) ---\n", program->name, value));
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_AlphaTest == value)
|
||||
return;
|
||||
|
||||
program->t_AlphaTest = value;
|
||||
#endif
|
||||
|
||||
qglUniform1iARB(program->u_AlphaTest, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_ViewOrigin(shaderProgram_t * program, const vec3_t v)
|
||||
{
|
||||
if (program->u_ViewOrigin == -1)
|
||||
return;
|
||||
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_ViewOrigin, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_ViewOrigin);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_ViewOrigin( program = %s, viewOrigin = ( %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2]));
|
||||
|
||||
qglUniform3fARB(program->u_ViewOrigin, v[0], v[1], v[2]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_TCGen0(shaderProgram_t * program, texCoordGen_t value)
|
||||
{
|
||||
if (program->u_TCGen0 == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_TCGen0 == value)
|
||||
return;
|
||||
|
||||
program->t_TCGen0 = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_TCGen( program = %s, value = %i ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1iARB(program->u_TCGen0, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_TCGen1(shaderProgram_t * program, texCoordGen_t value)
|
||||
{
|
||||
if (program->u_TCGen1 == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_TCGen1 == value)
|
||||
return;
|
||||
|
||||
program->t_TCGen1 = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_TCGen( program = %s, value = %i ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1iARB(program->u_TCGen1, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_TCGen0Vector0(shaderProgram_t * program, const vec4_t v)
|
||||
{
|
||||
if (program->u_TCGen0Vector0 == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_TCGen0Vector0, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_TCGen0Vector0);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_TCGen0Vector0( program = %s, color = ( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2], v[3]));
|
||||
|
||||
qglUniform4fARB(program->u_TCGen0Vector0, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_TCGen0Vector1(shaderProgram_t * program, const vec4_t v)
|
||||
{
|
||||
if (program->u_TCGen0Vector1 == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_TCGen0Vector1, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_TCGen0Vector1);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_TCGen0Vector1( program = %s, color = ( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2], v[3]));
|
||||
|
||||
qglUniform4fARB(program->u_TCGen0Vector1, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
static ID_INLINE void GLSL_SetUniform_TCGen1Vector0(shaderProgram_t * program, const vec4_t v)
|
||||
{
|
||||
if (program->u_TCGen1Vector0 == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_TCGen1Vector0, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_TCGen1Vector0);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_TCGen1Vector0( program = %s, color = ( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2], v[3]));
|
||||
|
||||
qglUniform4fARB(program->u_TCGen1Vector0, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
static ID_INLINE void GLSL_SetUniform_TCGen1Vector1(shaderProgram_t * program, const vec4_t v)
|
||||
{
|
||||
if (program->u_TCGen1Vector1 == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_TCGen1Vector1, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_TCGen1Vector1);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_TCGen1Vector1( program = %s, color = ( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2], v[3]));
|
||||
|
||||
qglUniform4fARB(program->u_TCGen1Vector1, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_DeformGen(shaderProgram_t * program, deformGen_t value)
|
||||
{
|
||||
if (program->u_DeformGen == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_DeformGen == value)
|
||||
return;
|
||||
|
||||
program->t_DeformGen = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_DeformGen( program = %s, value = %i ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1iARB(program->u_DeformGen, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_DeformWave(shaderProgram_t * program, const waveForm_t * wf)
|
||||
{
|
||||
vec4_t v;
|
||||
|
||||
if (program->u_DeformWave == -1)
|
||||
return;
|
||||
|
||||
VectorSet4(v, wf->base, wf->amplitude, wf->phase, wf->frequency);
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare4(program->t_DeformWave, v))
|
||||
return;
|
||||
|
||||
VectorCopy4(v, program->t_DeformWave);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_DeformWave( program = %s, wave form = ( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2], v[3]));
|
||||
|
||||
qglUniform4fARB(program->u_DeformWave, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_DeformBulge(shaderProgram_t * program, const deformStage_t * ds)
|
||||
{
|
||||
vec3_t v;
|
||||
|
||||
if (program->u_DeformBulge == -1)
|
||||
return;
|
||||
|
||||
VectorSet(v, ds->bulgeWidth, ds->bulgeHeight, ds->bulgeSpeed);
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_DeformBulge, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_DeformBulge);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_DeformBulge( program = %s, bulge = ( %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2]));
|
||||
|
||||
qglUniform3fARB(program->u_DeformBulge, v[0], v[1], v[2]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_DeformSpread(shaderProgram_t * program, float value)
|
||||
{
|
||||
if (program->u_DeformSpread == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_DeformSpread == value)
|
||||
return;
|
||||
|
||||
program->t_DeformSpread = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_DeformSpread( program = %s, value = %f ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1fARB(program->u_DeformSpread, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_ColorGen(shaderProgram_t * program, colorGen_t value)
|
||||
{
|
||||
#if 0
|
||||
float floatValue;
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case CGEN_VERTEX:
|
||||
floatValue = 1.0f;
|
||||
break;
|
||||
|
||||
case CGEN_ONE_MINUS_VERTEX:
|
||||
floatValue = -1.0f;
|
||||
break;
|
||||
|
||||
default:
|
||||
floatValue = 0.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_ColorGen == floatValue)
|
||||
return;
|
||||
|
||||
program->t_ColorGen = floatValue;
|
||||
#endif
|
||||
|
||||
qglUniform1fARB(program->u_ColorGen, floatValue);
|
||||
#else
|
||||
if (program->u_ColorGen == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_ColorGen == value)
|
||||
return;
|
||||
|
||||
program->t_ColorGen = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_ColorGen( program = %s, value = %i ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1iARB(program->u_ColorGen, value);
|
||||
#endif
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_AlphaGen(shaderProgram_t * program, alphaGen_t value)
|
||||
{
|
||||
#if 0
|
||||
float floatValue;
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case AGEN_VERTEX:
|
||||
floatValue = 1.0f;
|
||||
break;
|
||||
|
||||
case AGEN_ONE_MINUS_VERTEX:
|
||||
floatValue = -1.0f;
|
||||
break;
|
||||
|
||||
default:
|
||||
floatValue = 0.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_AlphaGen == floatValue)
|
||||
return;
|
||||
|
||||
program->t_AlphaGen = floatValue;
|
||||
#endif
|
||||
|
||||
qglUniform1fARB(program->u_AlphaGen, floatValue);
|
||||
|
||||
#else
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if (program->u_AlphaGen == -1)
|
||||
return;
|
||||
|
||||
if(program->t_AlphaGen == value)
|
||||
return;
|
||||
|
||||
program->t_AlphaGen = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_AlphaGen( program = %s, value = %i ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1iARB(program->u_AlphaGen, value);
|
||||
#endif
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_Color(shaderProgram_t * program, const vec4_t v)
|
||||
{
|
||||
if (program->u_Color == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare4(program->t_Color, v))
|
||||
return;
|
||||
|
||||
VectorCopy4(v, program->t_Color);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_Color( program = %s, color = ( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2], v[3]));
|
||||
|
||||
qglUniform4fARB(program->u_Color, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_AmbientLight(shaderProgram_t * program, const vec3_t v)
|
||||
{
|
||||
if (program->u_AmbientLight == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_AmbientLight, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_AmbientLight);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_AmbientLight( program = %s, color = ( %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2]));
|
||||
|
||||
qglUniform3fARB(program->u_AmbientLight, v[0], v[1], v[2]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_DirectedLight(shaderProgram_t * program, const vec3_t v)
|
||||
{
|
||||
if (program->u_DirectedLight == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_DirectedLight, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_DirectedLight);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_DirectedLight( program = %s, color = ( %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2]));
|
||||
|
||||
qglUniform3fARB(program->u_DirectedLight, v[0], v[1], v[2]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_LightDir(shaderProgram_t * program, const vec3_t v)
|
||||
{
|
||||
if (program->u_LightDir == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare(program->t_LightDir, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_LightDir);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_LightDir( program = %s, color = ( %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2]));
|
||||
|
||||
qglUniform3fARB(program->u_LightDir, v[0], v[1], v[2]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_PortalRange(shaderProgram_t * program, float value)
|
||||
{
|
||||
if (program->u_PortalRange == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_PortalRange == value)
|
||||
return;
|
||||
|
||||
program->t_PortalRange = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_PortalRange( program = %s, value = %f ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1fARB(program->u_PortalRange, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_FogDistance(shaderProgram_t * program, const vec4_t v)
|
||||
{
|
||||
if (program->u_FogDistance == -1)
|
||||
return;
|
||||
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare4(program->t_FogDistance, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_FogDistance);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniformFogDistance( program = %s, viewOrigin = ( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2], v[3]));
|
||||
|
||||
qglUniform4fARB(program->u_FogDistance, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_FogDepth(shaderProgram_t * program, const vec4_t v)
|
||||
{
|
||||
if (program->u_FogDepth == -1)
|
||||
return;
|
||||
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(VectorCompare4(program->t_FogDepth, v))
|
||||
return;
|
||||
|
||||
VectorCopy(v, program->t_FogDepth);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniformFogDepth( program = %s, viewOrigin = ( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n", program->name, v[0], v[1], v[2], v[3]));
|
||||
|
||||
qglUniform4fARB(program->u_FogDepth, v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_FogEyeT(shaderProgram_t * program, float value)
|
||||
{
|
||||
if (program->u_FogEyeT == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_FogEyeT == value)
|
||||
return;
|
||||
|
||||
program->t_FogEyeT = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_FogEyeT( program = %s, value = %f ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1fARB(program->u_FogEyeT, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_FogAdjustColors(shaderProgram_t * program, int value)
|
||||
{
|
||||
if (program->u_FogAdjustColors == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_FogAdjustColors == value)
|
||||
return;
|
||||
|
||||
program->t_FogAdjustColors = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_FogAdjustColors( program = %s, value = %i ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1iARB(program->u_FogAdjustColors, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_ModelMatrix(shaderProgram_t * program, const matrix_t m)
|
||||
{
|
||||
if (program->u_ModelMatrix == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(Matrix16Compare(program->t_ModelMatrix, m))
|
||||
return;
|
||||
|
||||
Matrix16Copy(m, program->t_ModelMatrix);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_ModelMatrix( program = %s, "
|
||||
"matrix = \n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n",
|
||||
program->name,
|
||||
m[0], m[4], m[8], m[12],
|
||||
m[1], m[5], m[9], m[13],
|
||||
m[2], m[6], m[10], m[14],
|
||||
m[3], m[7], m[11], m[15]));
|
||||
|
||||
qglUniformMatrix4fvARB(program->u_ModelMatrix, 1, GL_FALSE, m);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_ModelViewProjectionMatrix(shaderProgram_t * program, const matrix_t m)
|
||||
{
|
||||
if (program->u_ModelViewProjectionMatrix == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(Matrix16Compare(program->t_ModelViewProjectionMatrix, m))
|
||||
return;
|
||||
|
||||
Matrix16Copy(m, program->t_ModelViewProjectionMatrix);
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_ModelViewProjectionMatrix( program = %s, "
|
||||
"matrix = \n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f )\n"
|
||||
"( %5.3f, %5.3f, %5.3f, %5.3f ) ) ---\n",
|
||||
program->name,
|
||||
m[0], m[4], m[8], m[12],
|
||||
m[1], m[5], m[9], m[13],
|
||||
m[2], m[6], m[10], m[14],
|
||||
m[3], m[7], m[11], m[15]));
|
||||
|
||||
qglUniformMatrix4fvARB(program->u_ModelViewProjectionMatrix, 1, GL_FALSE, m);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_Time(shaderProgram_t * program, float value)
|
||||
{
|
||||
if (program->u_Time == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_Time == value)
|
||||
return;
|
||||
|
||||
program->t_Time = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_Time( program = %s, value = %f ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1fARB(program->u_Time, value);
|
||||
}
|
||||
|
||||
static ID_INLINE void GLSL_SetUniform_VertexLerp(shaderProgram_t * program, float value)
|
||||
{
|
||||
if (program->u_VertexLerp == -1)
|
||||
return;
|
||||
|
||||
#if defined(USE_UNIFORM_FIREWALL)
|
||||
if(program->t_VertexLerp == value)
|
||||
return;
|
||||
|
||||
program->t_VertexLerp = value;
|
||||
#endif
|
||||
|
||||
GLimp_LogUniformComment(va("--- GLSL_SetUniform_VertexLerp( program = %s, value = %f ) ---\n", program->name, value));
|
||||
|
||||
qglUniform1fARB(program->u_VertexLerp, value);
|
||||
}
|
||||
|
||||
|
||||
// trRefdef_t holds everything that comes in refdef_t,
|
||||
// as well as the locally generated scene information
|
||||
|
@ -2211,6 +1480,12 @@ typedef struct {
|
|||
int c_flareTests;
|
||||
int c_flareRenders;
|
||||
|
||||
int c_glslShaderBinds;
|
||||
int c_genericDraws;
|
||||
int c_lightmappedDraws;
|
||||
int c_fogDraws;
|
||||
int c_dlightDraws;
|
||||
|
||||
int msec; // total msec for backend run
|
||||
} backEndCounters_t;
|
||||
|
||||
|
@ -2314,6 +1589,10 @@ typedef struct {
|
|||
//
|
||||
|
||||
shaderProgram_t genericShader[GLSLDEF_COUNT];
|
||||
shaderProgram_t lightmappedShader;
|
||||
shaderProgram_t textureOnlyShader;
|
||||
shaderProgram_t fogShader;
|
||||
shaderProgram_t dlightShader;
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
|
@ -2769,10 +2048,12 @@ void RB_StageIteratorGeneric( void );
|
|||
void RB_StageIteratorGenericVBO( void );
|
||||
void RB_StageIteratorSky( void );
|
||||
void RB_StageIteratorVertexLitTexture( void );
|
||||
void RB_StageIteratorLightmappedMultitextureVBOGLSL( void );
|
||||
void RB_StageIteratorLightmappedMultitexture( void );
|
||||
|
||||
void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, byte *color );
|
||||
void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, byte *color, float s1, float t1, float s2, float t2 );
|
||||
void RB_InstantQuad( vec4_t quadVerts[4] );
|
||||
|
||||
void RB_ShowImages( void );
|
||||
|
||||
|
@ -2929,6 +2210,16 @@ void GLSL_VertexAttribsState(uint32_t stateBits);
|
|||
void GLSL_VertexAttribPointers(uint32_t attribBits);
|
||||
void GLSL_BindProgram(shaderProgram_t * program);
|
||||
void GLSL_BindNullProgram(void);
|
||||
|
||||
void GLSL_SetNumUniforms(shaderProgram_t *program, int numUniforms);
|
||||
void GLSL_SetUniformName(shaderProgram_t *program, int uniformNum, const char *name);
|
||||
void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value);
|
||||
void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value);
|
||||
void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v);
|
||||
void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v);
|
||||
void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v);
|
||||
void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const matrix_t matrix);
|
||||
|
||||
shaderProgram_t *GLSL_GetGenericShaderProgram(void);
|
||||
|
||||
/*
|
||||
|
|
|
@ -300,25 +300,16 @@ static void DrawTris (shaderCommands_t *input) {
|
|||
{
|
||||
if (glRefConfig.glsl && r_arb_shader_objects->integer)
|
||||
{
|
||||
matrix_t matrix;
|
||||
shaderProgram_t *sp = &tr.genericShader[0];
|
||||
shaderProgram_t *sp = &tr.textureOnlyShader;
|
||||
|
||||
GLSL_VertexAttribsState(ATTR_POSITION);
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniform_ModelViewProjectionMatrix(sp, glState.modelviewProjection);
|
||||
|
||||
//GLSL_SetUniform_DeformGen(sp, DGEN_NONE);
|
||||
GLSL_SetUniform_TCGen0(sp, TCGEN_IDENTITY);
|
||||
Matrix16Identity(matrix);
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniform_Texture1Env(sp, 0);
|
||||
GLSL_SetUniform_ColorGen(sp, CGEN_IDENTITY);
|
||||
GLSL_SetUniform_AlphaGen(sp, AGEN_IDENTITY);
|
||||
GLSL_SetUniformMatrix16(sp, TEXTUREONLY_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
if (input->multiDrawPrimitives)
|
||||
{
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **) input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -732,7 +723,7 @@ static void DrawMultitexturedVBO( shaderCommands_t *input, int stage ) {
|
|||
|
||||
if (input->multiDrawPrimitives)
|
||||
{
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **) input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1120,7 +1111,6 @@ static void ProjectDlightTextureVBOGLSL( void ) {
|
|||
dlight_t *dl;
|
||||
shaderProgram_t *sp;
|
||||
vec4_t vector;
|
||||
matrix_t matrix;
|
||||
|
||||
if ( !( tess.dlightBits & ( 1 << l ) ) ) {
|
||||
continue; // this surface definately doesn't have any of this light
|
||||
|
@ -1131,28 +1121,69 @@ static void ProjectDlightTextureVBOGLSL( void ) {
|
|||
radius = dl->radius;
|
||||
scale = 1.0f / radius;
|
||||
|
||||
sp = GLSL_GetGenericShaderProgram();
|
||||
sp = &tr.dlightShader;
|
||||
|
||||
backEnd.pc.c_dlightDraws++;
|
||||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniform_TCGen0(sp, TCGEN_DLIGHT);
|
||||
Matrix16Identity(matrix);
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniform_Texture1Env(sp, 0);
|
||||
GLSL_SetUniform_ColorGen(sp, CGEN_DLIGHT);
|
||||
GLSL_SetUniform_AlphaGen(sp, AGEN_CONST);
|
||||
GLSL_SetUniformMatrix16(sp, DLIGHT_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformFloat(sp, DLIGHT_UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
|
||||
|
||||
// u_DeformGen
|
||||
if(!ShaderRequiresCPUDeforms(tess.shader))
|
||||
{
|
||||
deformStage_t *ds;
|
||||
|
||||
// only support the first one
|
||||
ds = &tess.shader->deforms[0];
|
||||
|
||||
switch (ds->deformation)
|
||||
{
|
||||
case DEFORM_WAVE:
|
||||
GLSL_SetUniformInt(sp, DLIGHT_UNIFORM_DEFORMGEN, ds->deformationWave.func);
|
||||
{
|
||||
vec4_t v;
|
||||
waveForm_t *wf = &ds->deformationWave;
|
||||
VectorSet4(v, wf->base, wf->amplitude, wf->phase, wf->frequency);
|
||||
GLSL_SetUniformVec4(sp, DLIGHT_UNIFORM_DEFORMWAVE, v);
|
||||
}
|
||||
GLSL_SetUniformFloat(sp, DLIGHT_UNIFORM_DEFORMSPREAD, ds->deformationSpread);
|
||||
GLSL_SetUniformFloat(sp, DLIGHT_UNIFORM_TIME, tess.shaderTime);
|
||||
break;
|
||||
|
||||
case DEFORM_BULGE:
|
||||
GLSL_SetUniformInt(sp, DLIGHT_UNIFORM_DEFORMGEN, DGEN_BULGE);
|
||||
{
|
||||
vec3_t v;
|
||||
VectorSet(v, ds->bulgeWidth, ds->bulgeHeight, ds->bulgeSpeed);
|
||||
GLSL_SetUniformVec3(sp, DLIGHT_UNIFORM_DEFORMBULGE, v);
|
||||
}
|
||||
GLSL_SetUniformFloat(sp, DLIGHT_UNIFORM_TIME, tess.shaderTime);
|
||||
break;
|
||||
|
||||
default:
|
||||
GLSL_SetUniformInt(sp, DLIGHT_UNIFORM_DEFORMGEN, DGEN_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GLSL_SetUniformInt(sp, DLIGHT_UNIFORM_DEFORMGEN, DGEN_NONE);
|
||||
}
|
||||
|
||||
vector[0] = dl->color[0];
|
||||
vector[1] = dl->color[1];
|
||||
vector[2] = dl->color[2];
|
||||
vector[3] = 1.0f;
|
||||
GLSL_SetUniform_Color(sp, vector);
|
||||
GLSL_SetUniformVec4(sp, DLIGHT_UNIFORM_COLOR, vector);
|
||||
|
||||
vector[0] = origin[0];
|
||||
vector[1] = origin[1];
|
||||
vector[2] = origin[2];
|
||||
vector[3] = scale;
|
||||
GLSL_SetUniform_TCGen0Vector0(sp, vector);
|
||||
GLSL_SetUniformVec4(sp, DLIGHT_UNIFORM_DLIGHTINFO, vector);
|
||||
|
||||
GL_Bind( tr.dlightImage );
|
||||
|
||||
|
@ -1167,7 +1198,7 @@ static void ProjectDlightTextureVBOGLSL( void ) {
|
|||
|
||||
if (tess.multiDrawPrimitives)
|
||||
{
|
||||
R_DrawMultiElementsVBO(tess.multiDrawPrimitives, (const GLvoid **) tess.multiDrawFirstIndex, tess.multiDrawNumIndexes);
|
||||
R_DrawMultiElementsVBO(tess.multiDrawPrimitives, (const GLvoid **)tess.multiDrawFirstIndex, tess.multiDrawNumIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1225,29 +1256,70 @@ Blends a fog texture on top of everything else
|
|||
*/
|
||||
static void RB_FogPassVBOGLSL( void ) {
|
||||
fog_t *fog;
|
||||
vec3_t local;
|
||||
vec4_t color;
|
||||
matrix_t matrix;
|
||||
shaderProgram_t *sp = GLSL_GetGenericShaderProgram();
|
||||
vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0};
|
||||
float eyeT;
|
||||
shaderProgram_t *sp = &tr.fogShader;
|
||||
|
||||
backEnd.pc.c_fogDraws++;
|
||||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
fog = tr.world->fogs + tess.fogNum;
|
||||
|
||||
GLSL_SetUniform_FogAdjustColors(sp, 4);
|
||||
GLSL_SetUniform_TCGen0(sp, TCGEN_IDENTITY);
|
||||
Matrix16Identity(matrix);
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniform_Texture1Env(sp, 0);
|
||||
GLSL_SetUniform_ColorGen(sp, CGEN_CONST);
|
||||
GLSL_SetUniform_AlphaGen(sp, AGEN_CONST);
|
||||
GLSL_SetUniformMatrix16(sp, FOGPASS_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformFloat(sp, FOGPASS_UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
|
||||
|
||||
// u_DeformGen
|
||||
if(!ShaderRequiresCPUDeforms(tess.shader))
|
||||
{
|
||||
deformStage_t *ds;
|
||||
|
||||
// only support the first one
|
||||
ds = &tess.shader->deforms[0];
|
||||
|
||||
switch (ds->deformation)
|
||||
{
|
||||
case DEFORM_WAVE:
|
||||
GLSL_SetUniformInt(sp, FOGPASS_UNIFORM_DEFORMGEN, ds->deformationWave.func);
|
||||
{
|
||||
vec4_t v;
|
||||
waveForm_t *wf = &ds->deformationWave;
|
||||
VectorSet4(v, wf->base, wf->amplitude, wf->phase, wf->frequency);
|
||||
GLSL_SetUniformVec4(sp, FOGPASS_UNIFORM_DEFORMWAVE, v);
|
||||
}
|
||||
GLSL_SetUniformFloat(sp, FOGPASS_UNIFORM_DEFORMSPREAD, ds->deformationSpread);
|
||||
GLSL_SetUniformFloat(sp, FOGPASS_UNIFORM_TIME, tess.shaderTime);
|
||||
break;
|
||||
|
||||
case DEFORM_BULGE:
|
||||
GLSL_SetUniformInt(sp, FOGPASS_UNIFORM_DEFORMGEN, DGEN_BULGE);
|
||||
{
|
||||
vec3_t v;
|
||||
VectorSet(v, ds->bulgeWidth, ds->bulgeHeight, ds->bulgeSpeed);
|
||||
GLSL_SetUniformVec3(sp, FOGPASS_UNIFORM_DEFORMBULGE, v);
|
||||
}
|
||||
GLSL_SetUniformFloat(sp, FOGPASS_UNIFORM_TIME, tess.shaderTime);
|
||||
break;
|
||||
|
||||
default:
|
||||
GLSL_SetUniformInt(sp, FOGPASS_UNIFORM_DEFORMGEN, DGEN_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GLSL_SetUniformInt(sp, FOGPASS_UNIFORM_DEFORMGEN, DGEN_NONE);
|
||||
}
|
||||
|
||||
color[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f;
|
||||
color[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f;
|
||||
color[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f;
|
||||
color[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f;
|
||||
GLSL_SetUniform_Color(sp, color);
|
||||
GLSL_SetUniformVec4(sp, FOGPASS_UNIFORM_COLOR, color);
|
||||
|
||||
#if 0 // already set
|
||||
// from RB_CalcFogTexCoords()
|
||||
VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local );
|
||||
fogDistanceVector[0] = -backEnd.or.modelMatrix[2];
|
||||
|
@ -1278,14 +1350,9 @@ static void RB_FogPassVBOGLSL( void ) {
|
|||
|
||||
fogDistanceVector[3] += 1.0/512;
|
||||
|
||||
//ri.Printf(PRINT_ALL,"eyeT %f fogDistanceVector %f %f %f %f fogDepthVector %f %f %f %f\n", eyeT, fogDistanceVector[0], fogDistanceVector[1], fogDistanceVector[2], fogDistanceVector[3], fogDepthVector[0], fogDepthVector[1], fogDepthVector[2], fogDepthVector[3]);
|
||||
//ri.Printf(PRINT_ALL, "fogsurface %f %f %f %f\n", fog->surface[0], fog->surface[1], fog->surface[2], fog->surface[3]);
|
||||
|
||||
GLSL_SetUniform_TCGen0Vector0(sp, fogDistanceVector);
|
||||
GLSL_SetUniform_TCGen0Vector1(sp, fogDepthVector);
|
||||
GLSL_SetUniform_FogEyeT(sp, eyeT);
|
||||
#endif
|
||||
GL_Bind( tr.fogImage );
|
||||
GLSL_SetUniformVec4(sp, FOGPASS_UNIFORM_FOGDISTANCE, fogDistanceVector);
|
||||
GLSL_SetUniformVec4(sp, FOGPASS_UNIFORM_FOGDEPTH, fogDepthVector);
|
||||
GLSL_SetUniformFloat(sp, FOGPASS_UNIFORM_FOGEYET, eyeT);
|
||||
|
||||
if ( tess.shader->fogPass == FP_EQUAL ) {
|
||||
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL );
|
||||
|
@ -1295,7 +1362,7 @@ static void RB_FogPassVBOGLSL( void ) {
|
|||
|
||||
if (tess.multiDrawPrimitives)
|
||||
{
|
||||
R_DrawMultiElementsVBO(tess.multiDrawPrimitives, (const GLvoid **) tess.multiDrawFirstIndex, tess.multiDrawNumIndexes);
|
||||
R_DrawMultiElementsVBO(tess.multiDrawPrimitives, (const GLvoid **)tess.multiDrawFirstIndex, tess.multiDrawNumIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1879,6 +1946,8 @@ static void ComputeColorMatrix( shaderStage_t *pStage, float *outmatrix, qboolea
|
|||
outmatrix[15] = 0.0f;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -2289,7 +2358,7 @@ static void RB_IterateStagesGenericVBO( shaderCommands_t *input )
|
|||
|
||||
if (input->multiDrawPrimitives)
|
||||
{
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **) input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2324,18 +2393,18 @@ static void DrawMultitexturedVBOGLSL( shaderProgram_t *sp, shaderCommands_t *inp
|
|||
//
|
||||
// base
|
||||
//
|
||||
GLSL_SetUniform_TCGen0(sp, pStage->bundle[0].tcGen);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TCGEN0, pStage->bundle[0].tcGen);
|
||||
if (pStage->bundle[0].tcGen == TCGEN_VECTOR)
|
||||
{
|
||||
vector[3] = 0.0f;
|
||||
VectorCopy(pStage->bundle[0].tcGenVectors[0], vector);
|
||||
GLSL_SetUniform_TCGen0Vector0(sp, vector);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_TCGEN0VECTOR0, vector);
|
||||
VectorCopy(pStage->bundle[0].tcGenVectors[1], vector);
|
||||
GLSL_SetUniform_TCGen0Vector1(sp, vector);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_TCGEN0VECTOR1, vector);
|
||||
}
|
||||
|
||||
ComputeTexMatrix( pStage, 0, matrix );
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_TEXTURE0MATRIX, matrix);
|
||||
|
||||
R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 );
|
||||
|
||||
|
@ -2343,16 +2412,16 @@ static void DrawMultitexturedVBOGLSL( shaderProgram_t *sp, shaderCommands_t *inp
|
|||
// lightmap/secondary pass
|
||||
//
|
||||
if ( r_lightmap->integer ) {
|
||||
GLSL_SetUniform_Texture1Env(sp, GL_REPLACE);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TEXTURE1ENV, GL_REPLACE);
|
||||
} else {
|
||||
GLSL_SetUniform_Texture1Env(sp, tess.shader->multitextureEnv);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TEXTURE1ENV, tess.shader->multitextureEnv);
|
||||
}
|
||||
|
||||
R_BindAnimatedImageToTMU( &pStage->bundle[1], 1 );
|
||||
|
||||
if (input->multiDrawPrimitives)
|
||||
{
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **) input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2385,13 +2454,13 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniform_ModelViewProjectionMatrix(sp, glState.modelviewProjection);
|
||||
GLSL_SetUniform_ViewOrigin(sp, backEnd.or.viewOrigin);
|
||||
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformVec3(sp, GENERIC_UNIFORM_VIEWORIGIN, backEnd.or.viewOrigin);
|
||||
|
||||
GLSL_SetUniform_VertexLerp(sp, glState.vertexAttribsInterpolation);
|
||||
GLSL_SetUniformFloat(sp, GENERIC_UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
|
||||
|
||||
// u_DeformGen
|
||||
if(input->shader->numDeforms)
|
||||
if(!ShaderRequiresCPUDeforms(input->shader))
|
||||
{
|
||||
deformStage_t *ds;
|
||||
|
||||
|
@ -2401,26 +2470,39 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
switch (ds->deformation)
|
||||
{
|
||||
case DEFORM_WAVE:
|
||||
GLSL_SetUniform_DeformGen(sp, ds->deformationWave.func);
|
||||
GLSL_SetUniform_DeformWave(sp, &ds->deformationWave);
|
||||
GLSL_SetUniform_DeformSpread(sp, ds->deformationSpread);
|
||||
GLSL_SetUniform_Time(sp, tess.shaderTime);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_DEFORMGEN, ds->deformationWave.func);
|
||||
{
|
||||
vec4_t v;
|
||||
waveForm_t *wf = &ds->deformationWave;
|
||||
|
||||
VectorSet4(v, wf->base, wf->amplitude, wf->phase, wf->frequency);
|
||||
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_DEFORMWAVE, v);
|
||||
}
|
||||
GLSL_SetUniformFloat(sp, GENERIC_UNIFORM_DEFORMSPREAD, ds->deformationSpread);
|
||||
GLSL_SetUniformFloat(sp, GENERIC_UNIFORM_TIME, tess.shaderTime);
|
||||
break;
|
||||
|
||||
case DEFORM_BULGE:
|
||||
GLSL_SetUniform_DeformGen(sp, DGEN_BULGE);
|
||||
GLSL_SetUniform_DeformBulge(sp, ds);
|
||||
GLSL_SetUniform_Time(sp, tess.shaderTime);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_DEFORMGEN, DGEN_BULGE);
|
||||
{
|
||||
vec3_t v;
|
||||
|
||||
VectorSet(v, ds->bulgeWidth, ds->bulgeHeight, ds->bulgeSpeed);
|
||||
|
||||
GLSL_SetUniformVec3(sp, GENERIC_UNIFORM_DEFORMBULGE, v);
|
||||
}
|
||||
GLSL_SetUniformFloat(sp, GENERIC_UNIFORM_TIME, tess.shaderTime);
|
||||
break;
|
||||
|
||||
default:
|
||||
GLSL_SetUniform_DeformGen(sp, DGEN_NONE);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_DEFORMGEN, DGEN_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GLSL_SetUniform_DeformGen(sp, DGEN_NONE);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_DEFORMGEN, DGEN_NONE);
|
||||
}
|
||||
|
||||
if ( input->fogNum ) {
|
||||
|
@ -2455,9 +2537,9 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
eyeT = 1; // non-surface fog always has eye inside
|
||||
}
|
||||
|
||||
GLSL_SetUniform_FogDistance(sp, fogDistanceVector);
|
||||
GLSL_SetUniform_FogDepth(sp, fogDepthVector);
|
||||
GLSL_SetUniform_FogEyeT(sp, eyeT);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_FOGDISTANCE, fogDistanceVector);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_FOGDEPTH, fogDepthVector);
|
||||
GLSL_SetUniformFloat(sp, GENERIC_UNIFORM_FOGEYET, eyeT);
|
||||
}
|
||||
|
||||
for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
|
||||
|
@ -2484,13 +2566,13 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
|
||||
switch (pStage->alphaGen)
|
||||
{
|
||||
case AGEN_SKIP:
|
||||
case AGEN_IDENTITY:
|
||||
case AGEN_LIGHTING_SPECULAR:
|
||||
case AGEN_VERTEX:
|
||||
case AGEN_ONE_MINUS_VERTEX:
|
||||
case AGEN_PORTAL:
|
||||
break;
|
||||
case AGEN_SKIP:
|
||||
default:
|
||||
setcolor = qtrue;
|
||||
}
|
||||
|
@ -2499,10 +2581,10 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
{
|
||||
vec4_t color;
|
||||
|
||||
// JBravo: silincing a compiler warning about color being uninitialized
|
||||
MAKERGBA(color, 1.f, 1.f, 1.f, 1.f);
|
||||
VectorSet4(color, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
ComputeHelperColor (pStage, color);
|
||||
GLSL_SetUniform_Color(sp, color);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_COLOR, color);
|
||||
}
|
||||
|
||||
if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE)
|
||||
|
@ -2510,29 +2592,29 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
vec3_t vec;
|
||||
|
||||
VectorScale(backEnd.currentEntity->ambientLight, 1.0f / 255.0f, vec);
|
||||
GLSL_SetUniform_AmbientLight(sp, vec);
|
||||
GLSL_SetUniformVec3(sp, GENERIC_UNIFORM_AMBIENTLIGHT, vec);
|
||||
|
||||
VectorScale(backEnd.currentEntity->directedLight, 1.0f / 255.0f, vec);
|
||||
GLSL_SetUniform_DirectedLight(sp, vec);
|
||||
GLSL_SetUniformVec3(sp, GENERIC_UNIFORM_DIRECTEDLIGHT, vec);
|
||||
|
||||
GLSL_SetUniform_LightDir(sp, backEnd.currentEntity->lightDir);
|
||||
GLSL_SetUniformVec3(sp, GENERIC_UNIFORM_LIGHTDIR, backEnd.currentEntity->lightDir);
|
||||
}
|
||||
|
||||
if (pStage->alphaGen == AGEN_PORTAL)
|
||||
{
|
||||
GLSL_SetUniform_PortalRange(sp, tess.shader->portalRange);
|
||||
GLSL_SetUniformFloat(sp, GENERIC_UNIFORM_PORTALRANGE, tess.shader->portalRange);
|
||||
}
|
||||
|
||||
GLSL_SetUniform_ColorGen(sp, pStage->rgbGen);
|
||||
GLSL_SetUniform_AlphaGen(sp, pStage->alphaGen);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_COLORGEN, pStage->rgbGen);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_ALPHAGEN, pStage->alphaGen);
|
||||
|
||||
if ( input->fogNum )
|
||||
{
|
||||
GLSL_SetUniform_FogAdjustColors(sp, pStage->adjustColorsForFog);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_FOGADJUSTCOLORS, pStage->adjustColorsForFog);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLSL_SetUniform_FogAdjustColors(sp, 0);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_FOGADJUSTCOLORS, 0);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -2544,20 +2626,20 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
}
|
||||
else
|
||||
{
|
||||
GLSL_SetUniform_TCGen0(sp, pStage->bundle[0].tcGen);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TCGEN0, pStage->bundle[0].tcGen);
|
||||
if (pStage->bundle[0].tcGen == TCGEN_VECTOR)
|
||||
{
|
||||
vec4_t vector;
|
||||
|
||||
VectorCopy(pStage->bundle[0].tcGenVectors[0], vector);
|
||||
vector[3] = 0.0f;
|
||||
GLSL_SetUniform_TCGen0Vector0(sp, vector);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_TCGEN0VECTOR0, vector);
|
||||
VectorCopy(pStage->bundle[0].tcGenVectors[1], vector);
|
||||
GLSL_SetUniform_TCGen0Vector1(sp, vector);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_TCGEN0VECTOR1, vector);
|
||||
}
|
||||
|
||||
ComputeTexMatrix( pStage, 0, matrix );
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_TEXTURE0MATRIX, matrix);
|
||||
|
||||
//
|
||||
// set state
|
||||
|
@ -2569,7 +2651,7 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
else
|
||||
R_BindAnimatedImage( &pStage->bundle[0] );
|
||||
|
||||
GLSL_SetUniform_Texture1Env(sp, 0);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TEXTURE1ENV, 0);
|
||||
|
||||
//
|
||||
// draw
|
||||
|
@ -2577,7 +2659,7 @@ static void RB_IterateStagesGenericVBOGLSL( shaderCommands_t *input )
|
|||
|
||||
if (input->multiDrawPrimitives)
|
||||
{
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **) input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2728,6 +2810,8 @@ void RB_StageIteratorGenericVBO( void )
|
|||
return;
|
||||
}
|
||||
|
||||
backEnd.pc.c_genericDraws++;
|
||||
|
||||
if (tess.useInternalVBO)
|
||||
{
|
||||
RB_DeformTessGeometry();
|
||||
|
@ -2914,6 +2998,116 @@ void RB_StageIteratorVertexLitTexture( void )
|
|||
|
||||
//define REPLACE_MODE
|
||||
|
||||
void RB_StageIteratorLightmappedMultitextureVBOGLSL( void )
|
||||
{
|
||||
shaderCommands_t *input;
|
||||
unsigned int vertexAttribs = 0;
|
||||
shaderProgram_t *sp;
|
||||
shaderStage_t *pStage;
|
||||
matrix_t matrix;
|
||||
|
||||
input = &tess;
|
||||
|
||||
if (!input->numVertexes || !input->numIndexes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
backEnd.pc.c_lightmappedDraws++;
|
||||
|
||||
vertexAttribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD; //RB_CalcShaderVertexAttribs( input );
|
||||
|
||||
if (tess.useInternalVBO)
|
||||
{
|
||||
RB_UpdateVBOs(vertexAttribs);
|
||||
}
|
||||
else
|
||||
{
|
||||
backEnd.pc.c_staticVboDraws++;
|
||||
}
|
||||
|
||||
//
|
||||
// log this call
|
||||
//
|
||||
if ( r_logFile->integer )
|
||||
{
|
||||
// don't just call LogComment, or we will get
|
||||
// a call to va() every frame!
|
||||
GLimp_LogComment( va("--- RB_StageIteratorLightmappedMultitextureVBOGLSL( %s ) ---\n", tess.shader->name) );
|
||||
}
|
||||
|
||||
//
|
||||
// set face culling appropriately
|
||||
//
|
||||
GL_Cull( input->shader->cullType );
|
||||
|
||||
//
|
||||
// Set vertex attribs and pointers
|
||||
//
|
||||
if (glRefConfig.glsl && r_arb_shader_objects->integer)
|
||||
{
|
||||
GLSL_VertexAttribsState(vertexAttribs);
|
||||
}
|
||||
|
||||
//
|
||||
// Bind lightmapped shader
|
||||
//
|
||||
sp = &tr.lightmappedShader;
|
||||
GLSL_BindProgram(sp);
|
||||
GLSL_SetUniformMatrix16(sp, LIGHTMAPPED_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
pStage = input->xstages[0];
|
||||
GL_State( pStage->stateBits );
|
||||
|
||||
//
|
||||
// base
|
||||
//
|
||||
ComputeTexMatrix( pStage, 0, matrix );
|
||||
GLSL_SetUniformMatrix16(sp, LIGHTMAPPED_UNIFORM_TEXTURE0MATRIX, matrix);
|
||||
|
||||
R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 );
|
||||
|
||||
//
|
||||
// lightmap/secondary pass
|
||||
//
|
||||
#if 0
|
||||
if ( r_lightmap->integer ) {
|
||||
GLSL_SetUniformInt(sp, LIGHTMAPPED_UNIFORM_TEXTURE1ENV, GL_REPLACE);
|
||||
} else {
|
||||
GLSL_SetUniformInt(sp, LIGHTMAPPED_UNIFORM_TEXTURE1ENV, tess.shader->multitextureEnv);
|
||||
}
|
||||
#endif
|
||||
|
||||
R_BindAnimatedImageToTMU( &pStage->bundle[1], 1 );
|
||||
|
||||
//
|
||||
// draw
|
||||
//
|
||||
if (input->multiDrawPrimitives)
|
||||
{
|
||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
R_DrawElementsVBO(input->numIndexes, input->firstIndex);
|
||||
}
|
||||
|
||||
//
|
||||
// now do any dynamic lighting needed
|
||||
//
|
||||
if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE
|
||||
&& !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) {
|
||||
ProjectDlightTextureVBOGLSL();
|
||||
}
|
||||
|
||||
//
|
||||
// now do fog
|
||||
//
|
||||
if ( tess.fogNum && tess.shader->fogPass ) {
|
||||
RB_FogPassVBOGLSL();
|
||||
}
|
||||
}
|
||||
|
||||
void RB_StageIteratorLightmappedMultitexture( void ) {
|
||||
shaderCommands_t *input;
|
||||
|
||||
|
|
|
@ -1656,9 +1656,12 @@ static void ComputeStageIteratorFunc( void )
|
|||
|
||||
if ( glRefConfig.vertexBufferObject && r_arb_vertex_buffer_object->integer )
|
||||
{
|
||||
// VBOs don't support the fast path!
|
||||
if (!(glRefConfig.glsl && r_arb_shader_objects->integer))
|
||||
{
|
||||
// VBOs without shader objects don't support the fast path!
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// see if this can go into the vertex lit fast path
|
||||
|
@ -1676,8 +1679,15 @@ static void ComputeStageIteratorFunc( void )
|
|||
if ( !shader.multitextureEnv )
|
||||
{
|
||||
if ( !shader.numDeforms )
|
||||
{
|
||||
if (glRefConfig.vertexBufferObject && r_arb_vertex_buffer_object->integer && glRefConfig.glsl && r_arb_shader_objects->integer)
|
||||
{
|
||||
//shader.optimalStageIteratorFunc = RB_StageIteratorVertexLitTextureVBOGLSL;
|
||||
}
|
||||
else
|
||||
{
|
||||
shader.optimalStageIteratorFunc = RB_StageIteratorVertexLitTexture;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -1701,9 +1711,16 @@ static void ComputeStageIteratorFunc( void )
|
|||
{
|
||||
if ( !shader.numDeforms )
|
||||
{
|
||||
if ( shader.multitextureEnv )
|
||||
if ( shader.multitextureEnv == GL_MODULATE && !stages[0].adjustColorsForFog )
|
||||
{
|
||||
if (glRefConfig.vertexBufferObject && r_arb_vertex_buffer_object->integer && glRefConfig.glsl && r_arb_shader_objects->integer)
|
||||
{
|
||||
shader.optimalStageIteratorFunc = RB_StageIteratorLightmappedMultitextureVBOGLSL;
|
||||
}
|
||||
else
|
||||
{
|
||||
shader.optimalStageIteratorFunc = RB_StageIteratorLightmappedMultitexture;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -448,22 +448,22 @@ static void DrawSkySideVBO( struct image_s *image, const int mins[2], const int
|
|||
GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD);
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniform_ModelViewProjectionMatrix(sp, glState.modelviewProjection);
|
||||
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniform_FogAdjustColors(sp, 0);
|
||||
GLSL_SetUniform_DeformGen(sp, DGEN_NONE);
|
||||
GLSL_SetUniform_TCGen0(sp, TCGEN_TEXTURE);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_FOGADJUSTCOLORS, 0);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_DEFORMGEN, DGEN_NONE);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TCGEN0, TCGEN_TEXTURE);
|
||||
Matrix16Identity(matrix);
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniform_Texture1Env(sp, 0);
|
||||
GLSL_SetUniform_ColorGen(sp, CGEN_CONST);
|
||||
GLSL_SetUniform_AlphaGen(sp, AGEN_CONST);
|
||||
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_TEXTURE0MATRIX, matrix);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TEXTURE1ENV, 0);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_COLORGEN, CGEN_CONST);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_ALPHAGEN, AGEN_CONST);
|
||||
|
||||
color[0] = tr.identityLight;
|
||||
color[1] = tr.identityLight;
|
||||
color[2] = tr.identityLight;
|
||||
color[3] = 1.0f;
|
||||
GLSL_SetUniform_Color(sp, color);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_COLOR, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -173,8 +173,6 @@ based on Tess_InstantQuad from xreal
|
|||
*/
|
||||
void RB_InstantQuad(vec4_t quadVerts[4])
|
||||
{
|
||||
matrix_t matrix;
|
||||
|
||||
GLimp_LogComment("--- RB_InstantQuad ---\n");
|
||||
|
||||
tess.numVertexes = 0;
|
||||
|
@ -216,25 +214,16 @@ void RB_InstantQuad(vec4_t quadVerts[4])
|
|||
tess.indexes[tess.numIndexes++] = 2;
|
||||
tess.indexes[tess.numIndexes++] = 3;
|
||||
|
||||
// FIXME: A lot of this can probably be removed for speed
|
||||
RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
|
||||
|
||||
if (glRefConfig.glsl && r_arb_shader_objects->integer)
|
||||
{
|
||||
shaderProgram_t *sp = &tr.genericShader[0];
|
||||
shaderProgram_t *sp = &tr.textureOnlyShader;
|
||||
|
||||
GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD);
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniform_ModelViewProjectionMatrix(sp, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniform_FogAdjustColors(sp, 0);
|
||||
GLSL_SetUniform_DeformGen(sp, DGEN_NONE);
|
||||
GLSL_SetUniform_TCGen0(sp, TCGEN_TEXTURE);
|
||||
Matrix16Identity(matrix);
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniform_Texture1Env(sp, 0);
|
||||
GLSL_SetUniform_ColorGen(sp, CGEN_IDENTITY);
|
||||
GLSL_SetUniform_AlphaGen(sp, AGEN_IDENTITY);
|
||||
GLSL_SetUniformMatrix16(sp, TEXTUREONLY_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -592,22 +581,22 @@ static void RB_SurfaceBeam( void )
|
|||
GLSL_VertexAttribsState(ATTR_POSITION);
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniform_ModelViewProjectionMatrix(sp, glState.modelviewProjection);
|
||||
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniform_FogAdjustColors(sp, 0);
|
||||
GLSL_SetUniform_DeformGen(sp, DGEN_NONE);
|
||||
GLSL_SetUniform_TCGen0(sp, TCGEN_IDENTITY);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_FOGADJUSTCOLORS, 0);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_DEFORMGEN, DGEN_NONE);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TCGEN0, TCGEN_IDENTITY);
|
||||
Matrix16Identity(matrix);
|
||||
GLSL_SetUniform_Texture0Matrix(sp, matrix);
|
||||
GLSL_SetUniform_Texture1Env(sp, 0);
|
||||
GLSL_SetUniform_ColorGen(sp, CGEN_CONST);
|
||||
GLSL_SetUniform_AlphaGen(sp, AGEN_CONST);
|
||||
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_TEXTURE0MATRIX, matrix);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_TEXTURE1ENV, 0);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_COLORGEN, CGEN_CONST);
|
||||
GLSL_SetUniformInt(sp, GENERIC_UNIFORM_ALPHAGEN, AGEN_CONST);
|
||||
|
||||
color[0] = 1.0f;
|
||||
color[1] = 0.0f;
|
||||
color[2] = 0.0f;
|
||||
color[3] = 1.0f;
|
||||
GLSL_SetUniform_Color(sp, color);
|
||||
GLSL_SetUniformVec4(sp, GENERIC_UNIFORM_COLOR, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue