Fixed a couple of bugs with entity light atten and cubemap lights

This commit is contained in:
cholleme 2003-08-18 10:14:32 +00:00
parent d50fdaff42
commit a3d00face0
5 changed files with 122 additions and 114 deletions

View file

@ -847,7 +847,7 @@ void ARB_DisableBumpShader(shader_t* shader)
}
void ARB_EnableBumpShader(const transform_t *tr, vec3_t lightOrig,
void ARB_EnableBumpShader(const transform_t *tr, const lightobject_t *lo,
qboolean alias, shader_t* shader)
{
//tex 0 = normal map
@ -871,7 +871,7 @@ void ARB_EnableBumpShader(const transform_t *tr, vec3_t lightOrig,
glScalef(1.0f/(currentshadowlight->radiusv[0]),
1.0f/(currentshadowlight->radiusv[1]),
1.0f/(currentshadowlight->radiusv[2]));
glTranslatef(-lightOrig[0], -lightOrig[1], -lightOrig[2]);
GL_SetupAttenMatrix(tr);
glGetError();
glEnable(GL_VERTEX_PROGRAM_ARB);
@ -925,11 +925,11 @@ void ARB_EnableBumpShader(const transform_t *tr, vec3_t lightOrig,
GL_SelectTexture(GL_TEXTURE0_ARB);
qglProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 0, currentshadowlight->origin[0],
currentshadowlight->origin[1], currentshadowlight->origin[2], 0.0);
qglProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 0, lo->objectorigin[0],
lo->objectorigin[1], lo->objectorigin[2], 0.0);
Arb_checkerror();
qglProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 1, r_refdef.vieworg[0],
r_refdef.vieworg[1], r_refdef.vieworg[2], 0.0);
qglProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 1, lo->objectvieworg[0],
lo->objectvieworg[1], lo->objectvieworg[2], 0.0);
Arb_checkerror();
}
@ -1044,7 +1044,7 @@ void FormatError(); // In gl_bumpgf.c
void ARB_drawTriangleListBump (const vertexdef_t *verts, int *indecies,
int numIndecies, shader_t *shader,
const transform_t *tr)
const transform_t *tr, const lightobject_t *lo)
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, verts->vertexstride, verts->vertices);
@ -1052,7 +1052,7 @@ void ARB_drawTriangleListBump (const vertexdef_t *verts, int *indecies,
GL_AddColor();
glColor3fv(&currentshadowlight->color[0]);
ARB_EnableBumpShader(tr,currentshadowlight->origin,true, shader);
ARB_EnableBumpShader(tr, lo, true, shader);
//bind the correct textures
GL_SelectTexture(GL_TEXTURE0_ARB);
@ -1639,7 +1639,7 @@ void ARB_drawSurfaceListBase (vertexdef_t* verts, msurface_t** surfs,
glDisable(GL_BLEND);
}
void ARB_sendSurfacesTA(msurface_t** surfs, int numSurfaces, const transform_t *tr)
void ARB_sendSurfacesTA(msurface_t** surfs, int numSurfaces, const transform_t *tr, const lightobject_t *lo)
{
int i,j;
glpoly_t *p;
@ -1670,14 +1670,14 @@ void ARB_sendSurfacesTA(msurface_t** surfs, int numSurfaces, const transform_t *
{
// disable previous shader if switching between colored and mono gloss
ARB_DisableBumpShader(lastshader);
ARB_EnableBumpShader(tr,currentshadowlight->origin,true, shader);
ARB_EnableBumpShader(tr, lo, true, shader);
}
else
{
if ( !lastshader )
{
// Enable shader for the first surface
ARB_EnableBumpShader(tr,currentshadowlight->origin,true, shader);
ARB_EnableBumpShader(tr, lo, true, shader);
}
}
@ -1732,7 +1732,7 @@ void ARB_sendSurfacesTA(msurface_t** surfs, int numSurfaces, const transform_t *
void ARB_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs,
int numSurfaces,const transform_t *tr)
int numSurfaces,const transform_t *tr, const lightobject_t *lo)
{
glVertexPointer(3, GL_FLOAT, verts->vertexstride, verts->vertices);
glEnableClientState(GL_VERTEX_ARRAY);
@ -1744,7 +1744,7 @@ void ARB_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs,
GL_AddColor();
glColor3fv(&currentshadowlight->color[0]);
ARB_sendSurfacesTA(surfs,numSurfaces, tr);
ARB_sendSurfacesTA(surfs,numSurfaces, tr, lo);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

View file

@ -55,7 +55,7 @@ void GF3_SetupTcMods(stage_t *s);
Pixel shader for diffuse bump mapping does diffuse bumpmapping with norm cube, self shadowing & dist attent in
1 pass (thanx to the 4 texture units on a gf4)
*/
void GL_EnableDiffuseShaderGF3(const transform_t *tr, vec3_t lightOrig, int stageIndex) {
void GL_EnableDiffuseShaderGF3(const transform_t *tr, const lightobject_t *lo, int stageIndex) {
//tex 0 = normal map
//tex 1 = nomalization cube map (tangent space light vector)
@ -75,7 +75,6 @@ void GL_EnableDiffuseShaderGF3(const transform_t *tr, vec3_t lightOrig, int stag
glPushMatrix();
glLoadIdentity();
if (currentshadowlight->shader->numstages) {
GL_SetupCubeMapMatrix(tr);
if (currentshadowlight->shader->stages[stageIndex].texture[0]->type == GL_TEXTURE_CUBE_MAP_ARB) {
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, currentshadowlight->shader->stages[stageIndex].texture[0]->texnum);
@ -92,6 +91,7 @@ void GL_EnableDiffuseShaderGF3(const transform_t *tr, vec3_t lightOrig, int stag
}
GF3_SetupTcMods(&currentshadowlight->shader->stages[stageIndex]);
GL_SetupCubeMapMatrix(tr);
} else {
glEnable(GL_TEXTURE_3D);
glBindTexture(GL_TEXTURE_3D, atten3d_texture_object);
@ -102,10 +102,7 @@ void GL_EnableDiffuseShaderGF3(const transform_t *tr, vec3_t lightOrig, int stag
1.0f/(currentshadowlight->radiusv[1]),
1.0f/(currentshadowlight->radiusv[2]));
/*glScalef(1/currentshadowlight->radius,
1/currentshadowlight->radius,1/currentshadowlight->radius);
*/
glTranslatef(-lightOrig[0], -lightOrig[1], -lightOrig[2]);
GL_SetupAttenMatrix(tr);
}
glDisable(GL_PER_STAGE_CONSTANTS_NV);
@ -179,10 +176,8 @@ void GL_EnableDiffuseShaderGF3(const transform_t *tr, vec3_t lightOrig, int stag
//qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, diffuse_program_object );
//glEnable( GL_VERTEX_PROGRAM_ARB );
qglBindProgramNV( GL_VERTEX_PROGRAM_NV, diffuse_program_object );
qglProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 24, currentshadowlight->origin[0],
currentshadowlight->origin[1], currentshadowlight->origin[2], 1.0);
qglProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 25, r_refdef.vieworg[0],
r_refdef.vieworg[1], r_refdef.vieworg[2], 1.0);
qglProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 24, lo->objectorigin[0], lo->objectorigin[1], lo->objectorigin[2], 1.0);
qglProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 25, lo->objectvieworg[0], lo->objectvieworg[1], lo->objectvieworg[2], 1.0);
glEnable( GL_VERTEX_PROGRAM_NV );
}
@ -221,7 +216,7 @@ void GL_DisableDiffuseShaderGF3(int stageIndex) {
glDisable( GL_VERTEX_PROGRAM_NV );
}
void GL_EnableSpecularShaderGF3(const transform_t *tr, vec3_t lightOrig, int stageIndex, qboolean alias, qboolean packedGloss) {
void GL_EnableSpecularShaderGF3(const transform_t *tr, const lightobject_t *lo, int stageIndex, qboolean alias, qboolean packedGloss) {
vec3_t scaler = {0.5f, 0.5f, 0.5f};
float invrad = 1/currentshadowlight->radius;
@ -244,9 +239,7 @@ void GL_EnableSpecularShaderGF3(const transform_t *tr, vec3_t lightOrig, int sta
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
if (currentshadowlight->shader->numstages) {
GL_SetupCubeMapMatrix(tr);
if (currentshadowlight->shader->stages[stageIndex].texture[0]->type == GL_TEXTURE_CUBE_MAP_ARB) {
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, currentshadowlight->shader->stages[stageIndex].texture[0]->texnum);
@ -262,18 +255,18 @@ void GL_EnableSpecularShaderGF3(const transform_t *tr, vec3_t lightOrig, int sta
1.0f/(currentshadowlight->radiusv[2]));
}
GF3_SetupTcMods(&currentshadowlight->shader->stages[stageIndex]);
GL_SetupCubeMapMatrix(tr);
} else {
glEnable(GL_TEXTURE_3D);
glBindTexture(GL_TEXTURE_3D, atten3d_texture_object);
glTranslatef(0.5,0.5,0.5);
glScalef(0.5,0.5,0.5);
//glScalef(invrad, invrad, invrad);
glScalef(1.0f/(currentshadowlight->radiusv[0]),
1.0f/(currentshadowlight->radiusv[1]),
1.0f/(currentshadowlight->radiusv[2]));
glTranslatef(-lightOrig[0], -lightOrig[1], -lightOrig[2]);
GL_SetupAttenMatrix(tr);
}
@ -362,19 +355,9 @@ void GL_EnableSpecularShaderGF3(const transform_t *tr, vec3_t lightOrig, int sta
glEnable(GL_REGISTER_COMBINERS_NV);
// Enable the vertex program.
// qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, diffuse_program_object );
// glEnable( GL_VERTEX_PROGRAM_ARB );
//if (alias)
qglBindProgramNV( GL_VERTEX_PROGRAM_NV, specularalias_program_object );
//else
// qglBindProgramNV( GL_VERTEX_PROGRAM_NV, diffuse_program_object );
qglProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 24, currentshadowlight->origin[0],
currentshadowlight->origin[1], currentshadowlight->origin[2], 1.0);
qglProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 25,r_refdef.vieworg[0], r_refdef.vieworg[1], r_refdef.vieworg[2], 1.0);
qglProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 24, lo->objectorigin[0], lo->objectorigin[1], lo->objectorigin[2], 1.0);
qglProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 25, lo->objectvieworg[0], lo->objectvieworg[1], lo->objectvieworg[2], 1.0);
glEnable( GL_VERTEX_PROGRAM_NV );
}
@ -384,7 +367,7 @@ GL_DisableSpecularShaderGF3() ??
Same as GL_DisableDiffuseShaderGF3()
*/
void GL_EnableAttentShaderGF3(vec3_t lightOrig) {
void GL_EnableAttentShaderGF3(const transform_t *tr) {
float invrad = 1/currentshadowlight->radius;
@ -397,9 +380,8 @@ void GL_EnableAttentShaderGF3(vec3_t lightOrig) {
glScalef(1.0f/(currentshadowlight->radiusv[0]),
1.0f/(currentshadowlight->radiusv[1]),
1.0f/(currentshadowlight->radiusv[2]));
glTranslatef(-lightOrig[0],
-lightOrig[1],
-lightOrig[2]);
GL_SetupAttenMatrix(tr);
glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_3D);
@ -590,7 +572,7 @@ void GF3_sendTriangleListTA(const vertexdef_t *verts, int *indecies, int numInde
}
void GF3_drawTriangleListBump (const vertexdef_t *verts, int *indecies, int numIndecies, shader_t *shader, const transform_t *tr) {
void GF3_drawTriangleListBump (const vertexdef_t *verts, int *indecies, int numIndecies, shader_t *shader, const transform_t *tr,const lightobject_t *lo) {
int i, num;
@ -599,7 +581,7 @@ void GF3_drawTriangleListBump (const vertexdef_t *verts, int *indecies, int numI
if (currentshadowlight->shader->numstages) {
//draw attent into dest alpha
GL_DrawAlpha();
GL_EnableAttentShaderGF3(currentshadowlight->origin);
GL_EnableAttentShaderGF3(tr);
GF3_sendTriangleListWV(verts,indecies,numIndecies);
GL_DisableAttentShaderGF3();
GL_ModulateAlphaDrawColor();
@ -613,7 +595,7 @@ void GF3_drawTriangleListBump (const vertexdef_t *verts, int *indecies, int numI
if ((shader->numglossstages > 0) && (shader->numbumpstages > 0)) {
//FIXME: A lot of statechanges for every pass we could only rebind the texture (and some overhead like matrix setup,...)
for(i=0; i<num; i++) {
GL_EnableSpecularShaderGF3(tr,currentshadowlight->origin,i,true,(shader->glossstages[0].type == STAGE_GRAYGLOSS));
GL_EnableSpecularShaderGF3(tr, lo, i,true,(shader->glossstages[0].type == STAGE_GRAYGLOSS));
//bind the correct texture
GL_SelectTexture(GL_TEXTURE0_ARB);
GL_BindAdvanced(shader->bumpstages[0].texture[0]);
@ -628,7 +610,7 @@ void GF3_drawTriangleListBump (const vertexdef_t *verts, int *indecies, int numI
if ((shader->numcolorstages > 0) && (shader->numbumpstages > 0)) {
for(i=0; i<num; i++) {
GL_EnableDiffuseShaderGF3(tr,currentshadowlight->origin,i);
GL_EnableDiffuseShaderGF3(tr, lo, i);
//bind the correct texture
GL_SelectTexture(GL_TEXTURE0_ARB);
GL_BindAdvanced(shader->bumpstages[0].texture[0]);
@ -1415,7 +1397,7 @@ void GF3_sendSurfacesPlain(msurface_t **surfs, int numSurfaces) {
glEnable(GL_CULL_FACE);
}
void GF3_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs, int numSurfaces,const transform_t *tr) {
void GF3_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs, int numSurfaces,const transform_t *tr, const lightobject_t *lo) {
int i, num;
@ -1428,7 +1410,7 @@ void GF3_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs, int numSur
if (currentshadowlight->shader->numstages) {
//draw attent into dest alpha
GL_DrawAlpha();
GL_EnableAttentShaderGF3(currentshadowlight->origin);
GL_EnableAttentShaderGF3(tr);
glTexCoordPointer(3, GL_FLOAT, verts->vertexstride, verts->vertices);
GF3_sendSurfacesPlain(surfs,numSurfaces);
@ -1442,7 +1424,7 @@ void GF3_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs, int numSur
num = (currentshadowlight->shader->numstages == 0) ? 1 : currentshadowlight->shader->numstages;
for (i=0; i<num; i++) {
GL_EnableSpecularShaderGF3(tr,currentshadowlight->origin, i, true,true);
GL_EnableSpecularShaderGF3(tr, lo, i, true,true);
glTexCoordPointer(2, GL_FLOAT, verts->texcoordstride, verts->texcoords);
GF3_sendSurfacesTA(surfs,numSurfaces, true);
GL_DisableDiffuseShaderGF3(i);
@ -1450,7 +1432,7 @@ void GF3_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs, int numSur
for (i=0; i<num; i++) {
GL_EnableDiffuseShaderGF3(tr,currentshadowlight->origin,i);
GL_EnableDiffuseShaderGF3(tr, lo, i);
GF3_sendSurfacesTA(surfs,numSurfaces, false);
GL_DisableDiffuseShaderGF3(i);
}
@ -1508,10 +1490,12 @@ void GF3_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs, int numSur
"MOV o[COL0], v[COL0];"
// Transform vertex by texture matrix and copy to output
"DP4 o[TEX3].x, v[OPOS], c[4];"
"DP4 o[TEX3].y, v[OPOS], c[5];"
"DP4 o[TEX3].z, v[OPOS], c[6];"
"DP4 o[TEX3].w, v[OPOS], c[7];"
"DP4 R0.x, v[OPOS], c[4];"
"DP4 R0.y, v[OPOS], c[5];"
"DP4 R0.z, v[OPOS], c[6];"
"DP4 R0.w, v[OPOS], c[7];"
"RCP R1.x, R0.w;"
"MUL o[TEX3], R0, R1.x;"
"END";
@ -1563,10 +1547,12 @@ void GF3_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs, int numSur
"MOV o[COL0], v[COL0];"
// Transform vertex by texture matrix and copy to output
"DP4 o[TEX3].x, v[OPOS], c[4];"
"DP4 o[TEX3].y, v[OPOS], c[5];"
"DP4 o[TEX3].z, v[OPOS], c[6];"
"DP4 o[TEX3].w, v[OPOS], c[7];"
"DP4 R0.x, v[OPOS], c[4];"
"DP4 R0.y, v[OPOS], c[5];"
"DP4 R0.z, v[OPOS], c[6];"
"DP4 R0.w, v[OPOS], c[7];"
"RCP R1.x, R0.w;"
"MUL o[TEX3], R0, R1.x;"
"END";

View file

@ -285,34 +285,52 @@ void R_WorldToObjectMatrix(entity_t *e, matrix_4x4 result)
GL_SetupCubeMapMatrix
Loads the current matrix with a tranformation used for light filters
-Put object space into world space
-Then put this worldspace into lightspace
=============
*/
void GL_SetupCubeMapMatrix(const transform_t *tr) {
glLoadIdentity();
glRotatef (-currentshadowlight->angles[0], 1, 0, 0);
glRotatef (-currentshadowlight->angles[1], 0, 1, 0);
glRotatef (-currentshadowlight->angles[2], 0, 0, 1);
glRotatef (currentshadowlight->rspeed*cl.time,0,0,1);
glTranslatef(-currentshadowlight->origin[0],
-currentshadowlight->origin[1],
-currentshadowlight->origin[2]);
//if (!world)
// R_RotateForEntity(currententity);
glTranslatef (tr->origin[0], tr->origin[1], tr->origin[2]);
glRotatef (tr->angles[1], 0, 0, 1);
glRotatef (-tr->angles[0], 0, 1, 0);
glRotatef (tr->angles[2], 1, 0, 0);
//Con_Printf("Angles3: %f %f %f\n",tr->angles[0],tr->angles[1],tr->angles[2]);
}
/*
=============
GL_SetupAttenMatrix
Loads the current matrix with a tranformation used for light filters
-Put object space into world space
-Then put this worldspace into lightspace
(Ignore light angles as the boxes don't rotate with the light)
=============
*/
void GL_SetupAttenMatrix(const transform_t *tr) {
glTranslatef(-currentshadowlight->origin[0],
-currentshadowlight->origin[1],
-currentshadowlight->origin[2]);
glTranslatef (tr->origin[0], tr->origin[1], tr->origin[2]);
glRotatef (tr->angles[1], 0, 0, 1);
glRotatef (-tr->angles[0], 0, 1, 0);
glRotatef (tr->angles[2], 1, 0, 0);
}
/**************************************************************
PART2: Geommety sending code
@ -798,11 +816,6 @@ void R_DrawBrushObjectLight(entity_t *e,void (*BrushGeoSender) (entity_t *e)) {
model_t *clmodel;
vec3_t oldlightorigin;
//backup light origin since we will have to translate
//light into model space
VectorCopy (currentshadowlight->origin, oldlightorigin);
currententity = e;
currenttexture = -1;
@ -813,10 +826,8 @@ void R_DrawBrushObjectLight(entity_t *e,void (*BrushGeoSender) (entity_t *e)) {
R_RotateForEntity (e);
e->angles[0] = -e->angles[0]; // stupid quake bug
VectorCopy(((brushlightinstant_t *)e->brushlightinstant)->lightpos,currentshadowlight->origin);
BrushGeoSender(e);
VectorCopy(oldlightorigin,currentshadowlight->origin);
glPopMatrix ();
}
@ -995,9 +1006,6 @@ Same as R_DrawBrushObjectLight but with alias models
*/
void R_DrawAliasObjectLight(entity_t *e,void (*AliasGeoSender) (aliashdr_t *paliashdr, aliasframeinstant_t* instant))
{
int pose, numposes;
//matrix_4x4 transf;
//float org[4],res[4];
aliashdr_t *paliashdr;
alias3data_t *data;
vec3_t oldlightpos, oldvieworg;
@ -1006,8 +1014,6 @@ void R_DrawAliasObjectLight(entity_t *e,void (*AliasGeoSender) (aliashdr_t *pali
currententity = e;
// VectorCopy (currententity->origin, r_entorigin);
// VectorSubtract (r_origin, r_entorigin, modelorg);
glPushMatrix ();
R_RotateForEntity (e);
@ -1037,21 +1043,11 @@ void R_DrawAliasObjectLight(entity_t *e,void (*AliasGeoSender) (aliashdr_t *pali
return;
}
VectorCopy(currentshadowlight->origin,oldlightpos);
VectorCopy(currentshadowlight->origin,currentshadowlight->oldlightorigin);
VectorCopy( r_refdef.vieworg,oldvieworg);
VectorCopy( aliasframeinstant->lightinstant->vieworg, r_refdef.vieworg);
VectorCopy(aliasframeinstant->lightinstant->lightpos ,currentshadowlight->origin);
pose = paliashdr->frames[e->frame].firstpose;
numposes = paliashdr->frames[e->frame].numposes;
//Draw it!
AliasGeoSender(paliashdr,aliasframeinstant);
aliasframeinstant = aliasframeinstant->_next;
VectorCopy(oldvieworg, r_refdef.vieworg);
VectorCopy(oldlightpos,currentshadowlight->origin);
} /* for paliashdr */
glPopMatrix();
@ -1091,6 +1087,8 @@ void R_DrawSpriteModelLight (entity_t *e)
up = vup;
right = vright;
if (frame->shader->flags & SURF_NODRAW) return;
//We don't do full bumpapping on sprites only additive cube*attenuation*colormap
if (!frame->shader->numcolorstages) return;
@ -1138,6 +1136,8 @@ void R_DrawSpriteModelLightWV (entity_t *e)
up = vup;
right = vright;
if (frame->shader->flags & SURF_NODRAW) return;
//We don't do full bumpapping on sprites only additive cube*attenuation*colormap
if (!frame->shader->numcolorstages) return;
GL_BindAdvanced(frame->shader->colorstages[0].texture[0]);

View file

@ -900,8 +900,10 @@ void Parhelia_CreateShaders()
Pixel shader for diffuse bump mapping does diffuse bumpmapping with norm
cube, self shadowing & dist attent in 1 pass
*/
void Parhelia_EnableDiffuseShader(const transform_t *tr, vec3_t lightOrig)
void Parhelia_EnableDiffuseShader(const transform_t *tr, const lightobject_t *lo)
{
float temp[4];
//tex 0 = normal map
//tex 1 = normalization cube map (tangent space light vector)
//tex 2 = color map
@ -911,6 +913,16 @@ void Parhelia_EnableDiffuseShader(const transform_t *tr, vec3_t lightOrig)
glEnable(GL_VERTEX_SHADER_EXT);
qglBindVertexShaderEXT( vertex_shaders );
temp[0] = currentshadowlight->origin[0];
temp[1] = currentshadowlight->origin[1];
temp[2] = currentshadowlight->origin[2];
temp[3] = 1.0f;
qglSetInvariantEXT(lightPos, GL_FLOAT, &temp[0]);
temp[0] = r_refdef.vieworg[0];
temp[1] = r_refdef.vieworg[1];
temp[2] = r_refdef.vieworg[2];
qglSetInvariantEXT(eyePos, GL_FLOAT, &temp[0]);
Parhelia_checkerror();
glEnable(GL_FRAGMENT_SHADER_MTX );
@ -946,7 +958,7 @@ void Parhelia_EnableDiffuseShader(const transform_t *tr, vec3_t lightOrig)
glScalef(1.0f/(currentshadowlight->radiusv[0]),
1.0f/(currentshadowlight->radiusv[1]),
1.0f/(currentshadowlight->radiusv[2]));
glTranslatef(-lightOrig[0], -lightOrig[1], -lightOrig[2]);
GL_SetupAttenMatrix(tr);
qglBindFragShaderMTX( fragment_shaders );
Parhelia_checkerror();
@ -987,12 +999,24 @@ void Parhelia_DisableDiffuseShader()
GL_SelectTexture(GL_TEXTURE0_ARB);
}
void Parhelia_EnableSpecularShader(const transform_t *tr, vec3_t lightOrig,
void Parhelia_EnableSpecularShader(const transform_t *tr, const lightobject_t *lo,
qboolean alias)
{
vec3_t scaler = {0.5f, 0.5f, 0.5f};
float temp[4];
glEnable(GL_VERTEX_SHADER_EXT);
qglBindVertexShaderEXT( vertex_shaders+1 );
temp[0] = currentshadowlight->origin[0];
temp[1] = currentshadowlight->origin[1];
temp[2] = currentshadowlight->origin[2];
temp[3] = 1.0f;
qglSetInvariantEXT(lightPos, GL_FLOAT, &temp[0]);
temp[0] = r_refdef.vieworg[0];
temp[1] = r_refdef.vieworg[1];
temp[2] = r_refdef.vieworg[2];
qglSetInvariantEXT(eyePos, GL_FLOAT, &temp[0]);
Parhelia_checkerror();
glEnable(GL_FRAGMENT_SHADER_MTX );
@ -1033,7 +1057,7 @@ void Parhelia_EnableSpecularShader(const transform_t *tr, vec3_t lightOrig,
glScalef(1.0f/(currentshadowlight->radiusv[0]),
1.0f/(currentshadowlight->radiusv[1]),
1.0f/(currentshadowlight->radiusv[2]));
glTranslatef(-lightOrig[0], -lightOrig[1], -lightOrig[2]);
GL_SetupAttenMatrix(tr);
qglBindFragShaderMTX( fragment_shaders + 2 );
Parhelia_checkerror();
@ -1043,7 +1067,7 @@ void Parhelia_EnableSpecularShader(const transform_t *tr, vec3_t lightOrig,
}
void Parhelia_EnableAttentShader(vec3_t lightOrig)
void Parhelia_EnableAttentShader(const transform_t *tr)
{
glMatrixMode(GL_TEXTURE);
glPushMatrix();
@ -1053,9 +1077,7 @@ void Parhelia_EnableAttentShader(vec3_t lightOrig)
glScalef(1.0f/(currentshadowlight->radiusv[0]),
1.0f/(currentshadowlight->radiusv[1]),
1.0f/(currentshadowlight->radiusv[2]));
glTranslatef(-lightOrig[0],
-lightOrig[1],
-lightOrig[2]);
GL_SetupAttenMatrix(tr);
glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_3D);
@ -1210,13 +1232,13 @@ void Parhelia_sendTriangleListTA(const vertexdef_t *verts, int *indecies,
void Parhelia_drawTriangleListBump (const vertexdef_t *verts, int *indecies,
int numIndecies, shader_t *shader,
const transform_t *tr)
const transform_t *tr, const lightobject_t *lo)
{
if (currentshadowlight->filtercube)
{
//draw attent into dest alpha
GL_DrawAlpha();
Parhelia_EnableAttentShader(currentshadowlight->origin);
Parhelia_EnableAttentShader(tr);
Parhelia_sendTriangleListWV(verts,indecies,numIndecies);
Parhelia_DisableAttentShader();
GL_ModulateAlphaDrawColor();
@ -1227,7 +1249,7 @@ void Parhelia_drawTriangleListBump (const vertexdef_t *verts, int *indecies,
}
glColor3fv(&currentshadowlight->color[0]);
Parhelia_EnableSpecularShader(tr,currentshadowlight->origin,true);
Parhelia_EnableSpecularShader(tr, lo, true);
//bind the correct texture
GL_SelectTexture(GL_TEXTURE0_ARB);
if (shader->numbumpstages > 0)
@ -1239,7 +1261,7 @@ void Parhelia_drawTriangleListBump (const vertexdef_t *verts, int *indecies,
Parhelia_sendTriangleListTA(verts,indecies,numIndecies);
Parhelia_DisableDiffuseShader();
Parhelia_EnableDiffuseShader(tr,currentshadowlight->origin);
Parhelia_EnableDiffuseShader(tr, lo);
//bind the correct texture
GL_SelectTexture(GL_TEXTURE0_ARB);
if (shader->numbumpstages > 0)
@ -1599,7 +1621,7 @@ void Parhelia_sendSurfacesPlain(msurface_t** surfs, int numSurfaces)
}
void Parhelia_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs,
int numSurfaces,const transform_t *tr)
int numSurfaces,const transform_t *tr, const lightobject_t *lo)
{
glVertexPointer(3, GL_FLOAT, verts->vertexstride, verts->vertices);
glEnableClientState(GL_VERTEX_ARRAY);
@ -1611,7 +1633,7 @@ void Parhelia_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs,
{
//draw attent into dest alpha
GL_DrawAlpha();
Parhelia_EnableAttentShader(currentshadowlight->origin);
Parhelia_EnableAttentShader(tr);
glTexCoordPointer(3, GL_FLOAT, verts->vertexstride, verts->vertices);
Parhelia_sendSurfacesPlain(surfs,numSurfaces);
@ -1625,13 +1647,13 @@ void Parhelia_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs,
}
glColor3fv(&currentshadowlight->color[0]);
Parhelia_EnableSpecularShader(tr,currentshadowlight->origin,true);
Parhelia_EnableSpecularShader(tr, lo, true);
glTexCoordPointer(2, GL_FLOAT, verts->texcoordstride, verts->texcoords);
Parhelia_sendSurfacesTA(surfs,numSurfaces);
Parhelia_DisableDiffuseShader();
Parhelia_EnableDiffuseShader(tr,currentshadowlight->origin);
Parhelia_EnableDiffuseShader(tr, lo);
Parhelia_sendSurfacesTA(surfs,numSurfaces);
Parhelia_DisableDiffuseShader();

View file

@ -1099,7 +1099,7 @@ void Radeon_sendTriangleListTA(const vertexdef_t *verts, int *indecies,
void Radeon_drawTriangleListBump (const vertexdef_t *verts, int *indecies,
int numIndecies, shader_t *shader,
const transform_t *tr)
const transform_t *tr, const lightobject_t *lo)
{
GL_AddColor();
glColor3fv(&currentshadowlight->color[0]);
@ -1450,7 +1450,7 @@ void Radeon_sendSurfacesPlain(msurface_t** surfs, int numSurfaces)
}
void Radeon_drawSurfaceListBump (vertexdef_t *verts, msurface_t **surfs,
int numSurfaces,const transform_t *tr)
int numSurfaces,const transform_t *tr, const lightobject_t *lo)
{
glVertexPointer(3, GL_FLOAT, verts->vertexstride, verts->vertices);
glEnableClientState(GL_VERTEX_ARRAY);