mirror of
https://github.com/nzp-team/fteqw.git
synced 2025-01-20 15:31:02 +00:00
old fixes including for rgb_gen_topcolor in shaders
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3098 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
7f90f66bfc
commit
9fc7a20e9c
2 changed files with 98 additions and 59 deletions
|
@ -347,7 +347,7 @@ int R_LoadTexture(char *name, int width, int height, void *data, void *palette,
|
|||
#define R_LoadTexture8(skinname,width,height,data,usemips,alpha) ((qrenderer == QR_DIRECT3D)?D3D_LoadTexture(skinname, width, height, data, usemips, alpha):GL_LoadTexture(skinname, width, height, data, usemips, alpha))
|
||||
#define R_LoadTexture32(skinname,width,height,data,usemips,alpha) ((qrenderer == QR_DIRECT3D)?D3D_LoadTexture32(skinname, width, height, data, usemips, alpha):GL_LoadTexture32(skinname, width, height, data, usemips, alpha))
|
||||
#define R_LoadTextureFB(skinname,width,height,data,usemips,alpha) ((qrenderer == QR_DIRECT3D)?D3D_LoadTextureFB(skinname, width, height, data, usemips, alpha):GL_LoadTextureFB(skinname, width, height, data, usemips, alpha))
|
||||
#define R_LoadTexture8Bump(skinname,width,height,data,usemips,alpha) ((qrenderer == QR_DIRECT3D)?/*D3D_LoadTexture8Bump(skinname, width, height, data, usemips, alpha)*/NULL:GL_LoadTexture8Bump(skinname, width, height, data, usemips, alpha))
|
||||
#define R_LoadTexture8Bump(skinname,width,height,data,usemips,alpha) ((qrenderer == QR_DIRECT3D)?D3D_LoadTexture8Bump(skinname, width, height, data, usemips, alpha):GL_LoadTexture8Bump(skinname, width, height, data, usemips, alpha))
|
||||
|
||||
#define R_FindTexture(name) ((qrenderer == QR_DIRECT3D)?D3D_FindTexture(name):GL_FindTexture(name))
|
||||
#define R_LoadCompressed(name) ((qrenderer == QR_DIRECT3D)?D3D_LoadCompressed(name):GL_LoadCompressed(name))
|
||||
|
|
|
@ -1268,12 +1268,18 @@ void R_ModifyTextureCoords ( shaderpass_t *pass, int unit )
|
|||
r_texNums[unit] = R_ShaderpassTex(pass);
|
||||
|
||||
// we're smart enough not to copy data and simply switch the pointer
|
||||
if ( !pass->numtcmods ) {
|
||||
if ( pass->tcgen == TC_GEN_BASE ) {
|
||||
if (!pass->numtcmods)
|
||||
{
|
||||
if (pass->tcgen == TC_GEN_BASE)
|
||||
{
|
||||
qglTexCoordPointer(2, GL_FLOAT, 0, coordsArray);
|
||||
} else if ( pass->tcgen == TC_GEN_LIGHTMAP ) {
|
||||
}
|
||||
else if (pass->tcgen == TC_GEN_LIGHTMAP)
|
||||
{
|
||||
qglTexCoordPointer(2, GL_FLOAT, 0, lightmapCoordsArray);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qglTexCoordPointer(2, GL_FLOAT, 0, R_VertexTCBase(pass->tcgen, unit));
|
||||
}
|
||||
return;
|
||||
|
@ -1293,7 +1299,8 @@ void R_ModifyTextureCoords ( shaderpass_t *pass, int unit )
|
|||
sint = R_FastSin(cost);
|
||||
cost = R_FastSin(cost + 0.25);
|
||||
|
||||
for ( j = 0; j < numVerts; j++, tcArray += 2 ) {
|
||||
for (j = 0; j < numVerts; j++, tcArray += 2)
|
||||
{
|
||||
t1 = cost * (tcArray[0] - 0.5f) - sint * (tcArray[1] - 0.5f) + 0.5f;
|
||||
t2 = cost * (tcArray[1] - 0.5f) + sint * (tcArray[0] - 0.5f) + 0.5f;
|
||||
tcArray[0] = t1;
|
||||
|
@ -1305,7 +1312,8 @@ void R_ModifyTextureCoords ( shaderpass_t *pass, int unit )
|
|||
t1 = tcmod->args[0];
|
||||
t2 = tcmod->args[1];
|
||||
|
||||
for ( j = 0; j < numVerts; j++, tcArray += 2 ) {
|
||||
for (j = 0; j < numVerts; j++, tcArray += 2)
|
||||
{
|
||||
tcArray[0] = tcArray[0] * t1;
|
||||
tcArray[1] = tcArray[1] * t2;
|
||||
}
|
||||
|
@ -1315,7 +1323,8 @@ void R_ModifyTextureCoords ( shaderpass_t *pass, int unit )
|
|||
t1 = tcmod->args[2] + r_localShaderTime * tcmod->args[3];
|
||||
t2 = tcmod->args[1];
|
||||
|
||||
for ( j = 0; j < numVerts; j++, tcArray += 2 ) {
|
||||
for (j = 0; j < numVerts; j++, tcArray += 2)
|
||||
{
|
||||
tcArray[0] = tcArray[0] + R_FastSin (tcArray[0]*t2+t1) * t2;
|
||||
tcArray[1] = tcArray[1] + R_FastSin (tcArray[1]*t2+t1) * t2;
|
||||
}
|
||||
|
@ -1328,7 +1337,8 @@ void R_ModifyTextureCoords ( shaderpass_t *pass, int unit )
|
|||
t1 = t1 ? 1.0f / t1 : 1.0f;
|
||||
t2 = 0.5f - 0.5f * t1;
|
||||
|
||||
for ( j = 0; j < numVerts; j++, tcArray += 2 ) {
|
||||
for (j = 0; j < numVerts; j++, tcArray += 2)
|
||||
{
|
||||
tcArray[0] = tcArray[0] * t1 + t2;
|
||||
tcArray[1] = tcArray[1] * t1 + t2;
|
||||
}
|
||||
|
@ -1338,14 +1348,16 @@ void R_ModifyTextureCoords ( shaderpass_t *pass, int unit )
|
|||
t1 = tcmod->args[0] * r_localShaderTime;
|
||||
t2 = tcmod->args[1] * r_localShaderTime;
|
||||
|
||||
for ( j = 0; j < numVerts; j++, tcArray += 2 ) {
|
||||
for (j = 0; j < numVerts; j++, tcArray += 2)
|
||||
{
|
||||
tcArray[0] = tcArray[0] + t1;
|
||||
tcArray[1] = tcArray[1] + t2;
|
||||
}
|
||||
break;
|
||||
|
||||
case SHADER_TCMOD_TRANSFORM:
|
||||
for ( j = 0; j < numVerts; j++, tcArray += 2 ) {
|
||||
for (j = 0; j < numVerts; j++, tcArray += 2)
|
||||
{
|
||||
t1 = tcArray[0];
|
||||
t2 = tcArray[1];
|
||||
tcArray[0] = t1 * tcmod->args[0] + t2 * tcmod->args[2] + tcmod->args[4];
|
||||
|
@ -1386,9 +1398,12 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
rgbgenfunc = &pass->rgbgen_func;
|
||||
alphagenfunc = &pass->alphagen_func;
|
||||
|
||||
if ( noArray ) {
|
||||
if (noArray)
|
||||
{
|
||||
numColors = 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
numColors = numVerts;
|
||||
}
|
||||
|
||||
|
@ -1397,6 +1412,7 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
|
||||
switch (pass->rgbgen)
|
||||
{
|
||||
default:
|
||||
case RGB_GEN_IDENTITY:
|
||||
memset ( bArray, 255, sizeof(byte_vec4_t)*numColors );
|
||||
break;
|
||||
|
@ -1453,7 +1469,11 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
{
|
||||
int rc, gc, bc;
|
||||
R_FetchTopColour(&rc, &gc, &bc);
|
||||
for ( i = 0; i < numColors; i++, bArray += 4, vArray += 4 ) {
|
||||
|
||||
R_LightArrays((byte_vec4_t*)vArray, numColors, normalsArray);
|
||||
|
||||
for (i = 0; i < numColors; i++, bArray += 4, vArray += 4)
|
||||
{
|
||||
bArray[0] = (vArray[0]*rc)>>8;
|
||||
bArray[1] = (vArray[1]*gc)>>8;
|
||||
bArray[2] = (vArray[2]*bc)>>8;
|
||||
|
@ -1465,7 +1485,11 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
{
|
||||
int rc, gc, bc;
|
||||
R_FetchBottomColour(&rc, &gc, &bc);
|
||||
for ( i = 0; i < numColors; i++, bArray += 4, vArray += 4 ) {
|
||||
|
||||
R_LightArrays((byte_vec4_t*)vArray, numColors, normalsArray);
|
||||
|
||||
for (i = 0; i < numColors; i++, bArray += 4, vArray += 4)
|
||||
{
|
||||
bArray[0] = (vArray[0]*rc)>>8;
|
||||
bArray[1] = (vArray[1]*gc)>>8;
|
||||
bArray[2] = (vArray[2]*bc)>>8;
|
||||
|
@ -1475,7 +1499,8 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
|
||||
|
||||
case RGB_GEN_ONE_MINUS_VERTEX:
|
||||
for ( i = 0; i < numColors; i++, bArray += 4, vArray += 4 ) {
|
||||
for (i = 0; i < numColors; i++, bArray += 4, vArray += 4)
|
||||
{
|
||||
bArray[0] = 255 - vArray[0];
|
||||
bArray[1] = 255 - vArray[1];
|
||||
bArray[2] = 255 - vArray[2];
|
||||
|
@ -1492,9 +1517,6 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
R_LightArrays((byte_vec4_t*)bArray, numColors, normalsArray);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bArray = colorArray[0];
|
||||
|
@ -1502,8 +1524,10 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
|
||||
switch (pass->alphagen)
|
||||
{
|
||||
default:
|
||||
case ALPHA_GEN_IDENTITY:
|
||||
for ( i = 0; i < numColors; i++, bArray += 4 ) {
|
||||
for (i = 0; i < numColors; i++, bArray += 4)
|
||||
{
|
||||
bArray[3] = 255;
|
||||
}
|
||||
break;
|
||||
|
@ -1511,7 +1535,8 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
case ALPHA_GEN_CONST:
|
||||
b = FloatToByte ( alphagenfunc->args[0] );
|
||||
|
||||
for ( i = 0; i < numColors; i++, bArray += 4 ) {
|
||||
for (i = 0; i < numColors; i++, bArray += 4)
|
||||
{
|
||||
bArray[3] = b;
|
||||
}
|
||||
break;
|
||||
|
@ -1522,7 +1547,8 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
a = FTABLE_EVALUATE ( table, a ) * alphagenfunc->args[1] + alphagenfunc->args[0];
|
||||
b = FloatToByte ( bound (0.0f, a, 1.0f) );
|
||||
|
||||
for ( i = 0; i < numColors; i++, bArray += 4 ) {
|
||||
for (i = 0; i < numColors; i++, bArray += 4)
|
||||
{
|
||||
bArray[3] = b;
|
||||
}
|
||||
break;
|
||||
|
@ -1534,13 +1560,15 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
clamp ( a, 0.0f, 1.0f );
|
||||
b = FloatToByte ( a );
|
||||
|
||||
for ( i = 0; i < numColors; i++, bArray += 4 ) {
|
||||
for (i = 0; i < numColors; i++, bArray += 4)
|
||||
{
|
||||
bArray[3] = b;
|
||||
}
|
||||
break;
|
||||
|
||||
case ALPHA_GEN_VERTEX:
|
||||
for ( i = 0; i < numColors; i++, bArray += 4, vArray += 4 ) {
|
||||
for (i = 0; i < numColors; i++, bArray += 4, vArray += 4)
|
||||
{
|
||||
bArray[3] = vArray[3];
|
||||
}
|
||||
break;
|
||||
|
@ -1563,13 +1591,17 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
AngleVectors(currententity->angles, axis[0], axis[1], axis[2]);
|
||||
VectorSubtract(r_origin, currententity->origin, t);
|
||||
|
||||
if ( !Matrix3_Compare (axis, axisDefault) ) {
|
||||
if (!Matrix3_Compare(axis, axisDefault))
|
||||
{
|
||||
Matrix3_Multiply_Vec3(axis, t, v );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorCopy(t, v);
|
||||
}
|
||||
|
||||
for ( i = 0; i < numColors; i++, bArray += 4 ) {
|
||||
for (i = 0; i < numColors; i++, bArray += 4)
|
||||
{
|
||||
VectorSubtract(v, vertexArray[i], t);
|
||||
a = DotProduct(t, normalsArray[i] ) * Q_rsqrt(DotProduct(t,t));
|
||||
a = a * a * a * a * a;
|
||||
|
@ -1617,16 +1649,21 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
|
||||
c = DotProduct ( diff, fog_vpn );
|
||||
a = (1.0f - bound ( 0, c, 1.0f )) * (1.0 / 255.0);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
vdist = PlaneDiff ( diff, fogplane );
|
||||
|
||||
if ( vdist < 0 ) {
|
||||
if ( vdist < 0 )
|
||||
{
|
||||
VectorSubtract ( diff, r_origin, diff );
|
||||
|
||||
c = vdist / ( vdist - dist );
|
||||
c *= DotProduct ( diff, fog_vpn );
|
||||
a = (1.0f - bound ( 0, c, 1.0f )) * (1.0 / 255.0);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
a = 1.0 / 255.0;
|
||||
}
|
||||
}
|
||||
|
@ -1636,7 +1673,9 @@ void R_ModifyColor ( meshbuffer_t *mb, shaderpass_t *pass )
|
|||
bArray[0] = FloatToByte ( (float)bArray[0]*a );
|
||||
bArray[1] = FloatToByte ( (float)bArray[1]*a );
|
||||
bArray[2] = FloatToByte ( (float)bArray[2]*a );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
bArray[3] = FloatToByte ( (float)bArray[3]*a );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue