ref_gu: efx optimization

This commit is contained in:
Crow-bar
2022-09-05 11:57:37 +03:00
parent bcf838c42f
commit 3afc7134ab
5 changed files with 326 additions and 521 deletions

View File

@@ -47,7 +47,7 @@ static float rgNoise[NOISE_DIVISIONS+1]; // global noise array
static void FracNoise( float *noise, int divs )
{
int div2;
div2 = divs >> 1;
if( divs < 2 ) return;
@@ -198,7 +198,9 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
float flMaxWidth, vLast, vStep, brightness;
vec3_t perp1, vLastNormal;
beamseg_t curSeg;
uint vert_count;
uint vert_color;
if( segments < 2 ) return;
length = VectorLength( delta );
@@ -250,17 +252,18 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
total_segs = segments;
segs_drawn = 0;
#if 1
gu_vert_ftcnv_t* const out = ( gu_vert_ftcnv_t* )extGuBeginPacket( NULL );
unsigned int vert_size = 0;
unsigned int vert_color = 0;
#endif
gu_vert_ftcnv_t* const out = ( gu_vert_ftcnv_t* )extGuBeginPacket( NULL );
vert_count = 0;
vert_color = 0;
// specify all the segments.
for( i = 0; i < segments; i++ )
{
beamseg_t nextSeg;
vec3_t vPoint1, vPoint2;
Assert( noiseIndex < ( NOISE_DIVISIONS << 16 ));
fraction = i * div;
@@ -317,39 +320,28 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
// draw regular segment
VectorMA( curSeg.pos, ( curSeg.width * 0.5f ), vAveNormal, vPoint1 );
VectorMA( curSeg.pos, (-curSeg.width * 0.5f ), vAveNormal, vPoint2 );
#if 1
vert_color = getTriBrightness( brightness );
out[vert_size].u = 0.0f;
out[vert_size].v = curSeg.texcoord;
out[vert_size].c = vert_color;
out[vert_size].nx = vAveNormal[0];
out[vert_size].ny = vAveNormal[1];
out[vert_size].nz = vAveNormal[2];
out[vert_size].x = vPoint1[0];
out[vert_size].y = vPoint1[1];
out[vert_size].z = vPoint1[2];
vert_size++;
out[vert_size].u = 1.0f;
out[vert_size].v = curSeg.texcoord;
out[vert_size].c = vert_color;
out[vert_size].nx = vAveNormal[0];
out[vert_size].ny = vAveNormal[1];
out[vert_size].nz = vAveNormal[2];
out[vert_size].x = vPoint2[0];
out[vert_size].y = vPoint2[1];
out[vert_size].z = vPoint2[2];
vert_size++;
#else
pglTexCoord2f( 0.0f, curSeg.texcoord );
TriBrightness( brightness );
pglNormal3fv( vAveNormal );
pglVertex3fv( vPoint1 );
pglTexCoord2f( 1.0f, curSeg.texcoord );
TriBrightness( brightness );
pglNormal3fv( vAveNormal );
pglVertex3fv( vPoint2 );
#endif
vert_color = getTriBrightness( brightness );
out[vert_count].u = 0.0f;
out[vert_count].v = curSeg.texcoord;
out[vert_count].c = vert_color;
out[vert_count].nx = vAveNormal[0];
out[vert_count].ny = vAveNormal[1];
out[vert_count].nz = vAveNormal[2];
out[vert_count].x = vPoint1[0];
out[vert_count].y = vPoint1[1];
out[vert_count].z = vPoint1[2];
vert_count++;
out[vert_count].u = 1.0f;
out[vert_count].v = curSeg.texcoord;
out[vert_count].c = vert_color;
out[vert_count].nx = vAveNormal[0];
out[vert_count].ny = vAveNormal[1];
out[vert_count].nz = vAveNormal[2];
out[vert_count].x = vPoint2[0];
out[vert_count].y = vPoint2[1];
out[vert_count].z = vPoint2[2];
vert_count++;
}
curSeg = nextSeg;
@@ -376,48 +368,35 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
VectorMA( curSeg.pos, (-curSeg.width * 0.5f ), vLastNormal, vPoint2 );
// specify the points.
#if 1
vert_color = getTriBrightness( brightness );
out[vert_size].u = 0.0f;
out[vert_size].v = curSeg.texcoord;
out[vert_size].c = vert_color;
out[vert_size].nx = vLastNormal[0];
out[vert_size].ny = vLastNormal[1];
out[vert_size].nz = vLastNormal[2];
out[vert_size].x = vPoint1[0];
out[vert_size].y = vPoint1[1];
out[vert_size].z = vPoint1[2];
vert_size++;
out[vert_size].u = 1.0f;
out[vert_size].v = curSeg.texcoord;
out[vert_size].c = vert_color;
out[vert_size].nx = vLastNormal[0];
out[vert_size].ny = vLastNormal[1];
out[vert_size].nz = vLastNormal[2];
out[vert_size].x = vPoint2[0];
out[vert_size].y = vPoint2[1];
out[vert_size].z = vPoint2[2];
vert_size++;
#else
pglTexCoord2f( 0.0f, curSeg.texcoord );
TriBrightness( brightness );
pglNormal3fv( vLastNormal );
pglVertex3fv( vPoint1 );
pglTexCoord2f( 1.0f, curSeg.texcoord );
TriBrightness( brightness );
pglNormal3fv( vLastNormal );
pglVertex3fv( vPoint2 );
#endif
out[vert_count].u = 0.0f;
out[vert_count].v = curSeg.texcoord;
out[vert_count].c = vert_color;
out[vert_count].nx = vLastNormal[0];
out[vert_count].ny = vLastNormal[1];
out[vert_count].nz = vLastNormal[2];
out[vert_count].x = vPoint1[0];
out[vert_count].y = vPoint1[1];
out[vert_count].z = vPoint1[2];
vert_count++;
out[vert_count].u = 1.0f;
out[vert_count].v = curSeg.texcoord;
out[vert_count].c = vert_color;
out[vert_count].nx = vLastNormal[0];
out[vert_count].ny = vLastNormal[1];
out[vert_count].nz = vLastNormal[2];
out[vert_count].x = vPoint2[0];
out[vert_count].y = vPoint2[1];
out[vert_count].z = vPoint2[2];
vert_count++;
}
vLast += vStep; // Advance texture scroll (v axis only)
noiseIndex += noiseStep;
}
#if 1
extGuEndPacket( ( void * )( out + vert_size ) );
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_NORMAL_32BITF | GU_VERTEX_32BITF, vert_size, 0, out );
#endif
extGuEndPacket(( void * )( out + vert_count ));
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_NORMAL_32BITF | GU_VERTEX_32BITF, vert_count, 0, out );
}
/*
@@ -432,6 +411,7 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f
int i, noiseIndex, noiseStep;
float div, length, fraction, factor, vLast, vStep;
vec3_t last1, last2, point, screen, screenLast, tmp, normal;
uint vert_count = 0;
if( segments < 2 )
return;
@@ -453,10 +433,11 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f
// Iterator to resample noise waveform (it needs to be generated in powers of 2)
noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f );
noiseIndex = 0;
#if 1
gu_vert_ftv_t* const out = ( gu_vert_ftv_t* )extGuBeginPacket( NULL );
unsigned int vert_size = 0;
#endif
gu_vert_ftv_t* const out = ( gu_vert_ftv_t* )extGuBeginPacket( NULL );
vert_count = 0;
for( i = 0; i < segments; i++ )
{
float s, c;
@@ -481,7 +462,7 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f
VectorMA( point, factor, RI.vright, point );
}
}
// Transform point into screen space
TriWorldToScreen( point, screen );
@@ -495,40 +476,33 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f
VectorNormalize( tmp );
VectorScale( RI.vup, -tmp[0], normal ); // Build point along noraml line (normal is -y, x)
VectorMA( normal, tmp[1], RI.vright, normal );
// Make a wide line
VectorMA( point, width, normal, last1 );
VectorMA( point, -width, normal, last2 );
vLast += vStep; // advance texture scroll (v axis only)
#if 1
out[vert_size].u = 1.0f;
out[vert_size].v = vLast;
out[vert_size].x = last2[0];
out[vert_size].y = last2[1];
out[vert_size].z = last2[2];
vert_size++;
out[vert_size].u = 0.0f;
out[vert_size].v = vLast;
out[vert_size].x = last1[0];
out[vert_size].y = last1[1];
out[vert_size].z = last1[2];
vert_size++;
#else
TriTexCoord2f( 1, vLast );
TriVertex3fv( last2 );
TriTexCoord2f( 0, vLast );
TriVertex3fv( last1 );
#endif
out[vert_count].u = 1.0f;
out[vert_count].v = vLast;
out[vert_count].x = last2[0];
out[vert_count].y = last2[1];
out[vert_count].z = last2[2];
vert_count++;
out[vert_count].u = 0.0f;
out[vert_count].v = vLast;
out[vert_count].x = last1[0];
out[vert_count].y = last1[1];
out[vert_count].z = last1[2];
vert_count++;
}
VectorCopy( screen, screenLast );
noiseIndex += noiseStep;
}
#if 1
extGuEndPacket( ( void * )( out + vert_size ) );
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_VERTEX_32BITF, vert_size, 0, out );
#endif
extGuEndPacket(( void * )( out + vert_count ));
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_VERTEX_32BITF, vert_count, 0, out );
}
/*
@@ -542,8 +516,9 @@ void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float fr
{
float div, length, fraction;
float w, vLast, vStep;
vec3_t point;
int i;
uint vert_count;
uint vert_color;
if( segments < 2 )
return;
@@ -553,69 +528,52 @@ void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float fr
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
div = 1.0f / (segments - 1);
vStep = length * div; // Texture length texels per space pixel
// scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
vLast = fmod( freq * speed, 1 );
scale = scale * length;
// clamp the beam width
w = fmod( freq, width * 0.1f ) * delta[2];
#if 1
gu_vert_ftcv_t* const out = ( gu_vert_ftcv_t* )extGuBeginPacket( NULL );
unsigned int vert_size = 0;
unsigned int vert_color = getTriBrightness( 1.0f );
#endif
gu_vert_ftcv_t* const out = ( gu_vert_ftcv_t* )extGuBeginPacket( NULL );
vert_count = 0;
vert_color = getTriBrightness( 1.0f );
// NOTE: we must force the degenerate triangles to be on the edge
for( i = 0; i < segments; i++ )
{
float s, c;
fraction = i * div;
VectorCopy( source, point );
#if 1
out[vert_size].u = 1.0f;
out[vert_size].v = vLast;
out[vert_size].c = vert_color;
out[vert_size].x = point[0];
out[vert_size].y = point[1];
out[vert_size].z = point[2];
vert_size++;
out[vert_count].u = 1.0f;
out[vert_count].v = vLast;
out[vert_count].c = vert_color;
out[vert_count].x = source[0];
out[vert_count].y = source[1];
out[vert_count].z = source[2];
vert_count++;
SinCos( fraction * M_PI2_F, &s, &c );
point[0] = s * w + source[0];
point[1] = c * w + source[1];
point[2] = source[2];
out[vert_size].u = 0.0f;
out[vert_size].v = vLast;
out[vert_size].c = vert_color;
out[vert_size].x = point[0];
out[vert_size].y = point[1];
out[vert_size].z = point[2];
vert_size++;
#else
TriBrightness( 1.0f );
TriTexCoord2f( 1.0f, vLast );
TriVertex3fv( point );
out[vert_count].u = 0.0f;
out[vert_count].v = vLast;
out[vert_count].c = vert_color;
out[vert_count].x = s * w + source[0];
out[vert_count].y = c * w + source[1];
out[vert_count].z = source[2];
vert_count++;
SinCos( fraction * M_PI2_F, &s, &c );
point[0] = s * w + source[0];
point[1] = c * w + source[1];
point[2] = source[2];
TriBrightness( 1.0f );
TriTexCoord2f( 0.0f, vLast );
TriVertex3fv( point );
#endif
vLast += vStep; // advance texture scroll (v axis only)
}
#if 1
extGuEndPacket( ( void * )( out + vert_size ) );
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF, vert_size, 0, out );
#endif
extGuEndPacket(( void * )( out + vert_count ));
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF, vert_count, 0, out );
}
/*
@@ -629,8 +587,10 @@ void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, floa
{
float div, length, fraction;
float vLast, vStep;
vec3_t point;
int i;
uint vert_count;
uint vert_color0;
uint vert_color1;
if( segments < 2 )
return;
@@ -640,19 +600,20 @@ void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, floa
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
div = 1.0f / (segments - 1);
vStep = length * div; // texture length texels per space pixel
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
vLast = fmod( freq * speed, 1 );
scale = scale * length;
#if 1
gu_vert_ftcv_t* const out = ( gu_vert_ftcv_t* )extGuBeginPacket( NULL );
unsigned int vert_size = 0;
unsigned int vert_color0 = getTriBrightness( 0.0f );
unsigned int vert_color1 = getTriBrightness( 1.0f );
#endif
vert_count = 0;
vert_color0 = getTriBrightness( 0.0f );
vert_color1 = getTriBrightness( 1.0f );
for ( i = 0; i < segments; i++ )
{
float s, c;
@@ -660,48 +621,26 @@ void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, floa
fraction = i * div;
SinCos( fraction * M_PI2_F, &s, &c );
point[0] = s * freq * delta[2] + source[0];
point[1] = c * freq * delta[2] + source[1];
point[2] = source[2] + width;
#if 1
out[vert_size].u = 1.0f;
out[vert_size].v = vLast;
out[vert_size].c = vert_color0;
out[vert_size].x = point[0];
out[vert_size].y = point[1];
out[vert_size].z = point[2];
vert_size++;
point[0] = s * freq * ( delta[2] + width ) + source[0];
point[1] = c * freq * ( delta[2] + width ) + source[1];
point[2] = source[2] - width;
out[vert_count].u = 1.0f;
out[vert_count].v = vLast;
out[vert_count].c = vert_color0;
out[vert_count].x = s * freq * delta[2] + source[0];
out[vert_count].y = c * freq * delta[2] + source[1];
out[vert_count].z = source[2] + width;
vert_count++;
out[vert_count].u = 0.0f;
out[vert_count].v = vLast;
out[vert_count].c = vert_color1;
out[vert_count].x = s * freq * ( delta[2] + width ) + source[0];
out[vert_count].y = c * freq * ( delta[2] + width ) + source[1];
out[vert_count].z = source[2] - width;
vert_count++;
out[vert_size].u = 0.0f;
out[vert_size].v = vLast;
out[vert_size].c = vert_color1;
out[vert_size].x = point[0];
out[vert_size].y = point[1];
out[vert_size].z = point[2];
vert_size++;
#else
TriBrightness( 0 );
TriTexCoord2f( 1, vLast );
TriVertex3fv( point );
point[0] = s * freq * ( delta[2] + width ) + source[0];
point[1] = c * freq * ( delta[2] + width ) + source[1];
point[2] = source[2] - width;
TriBrightness( 1 );
TriTexCoord2f( 0, vLast );
TriVertex3fv( point );
#endif
vLast += vStep; // Advance texture scroll (v axis only)
}
#if 1
extGuEndPacket( ( void * )( out + vert_size ) );
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF, vert_size, 0, out );
#endif
extGuEndPacket(( void * )( out + vert_count ));
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF, vert_count, 0, out );
}
/*
@@ -717,6 +656,8 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
float fraction, div, vLast, vStep;
vec3_t last1, last2, tmp, screen;
vec3_t delta, screenLast, normal;
uint vert_count;
uint vert_color;
gEngfuncs.R_FreeDeadParticles( &pbeam->particles );
@@ -786,7 +727,7 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
// Build point along noraml line (normal is -y, x)
VectorScale( RI.vup, tmp[0], normal ); // Build point along normal line (normal is -y, x)
VectorMA( normal, tmp[1], RI.vright, normal );
// Make a wide line
VectorMA( delta, pbeam->width, normal, last1 );
VectorMA( delta, -pbeam->width, normal, last2 );
@@ -796,41 +737,30 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
vLast = 0.0f;
vStep = 1.0f;
#if 1
gu_vert_ftcv_t* const out = ( gu_vert_ftcv_t* )extGuBeginPacket( NULL );
unsigned int vert_size = 0;
unsigned int vert_color = 0;
gu_vert_ftcv_t* saved_ptr;
#endif
vert_count = 0;
vert_color = 0;
vert_color = getTriBrightness( fraction );
out[vert_count].u = 1.0f;
out[vert_count].v = vLast;
out[vert_count].c = vert_color;
out[vert_count].x = last2[0];
out[vert_count].y = last2[1];
out[vert_count].z = last2[2];
vert_count++;
out[vert_count].u = 0.0f;
out[vert_count].v = vLast;
out[vert_count].c = vert_color;
out[vert_count].x = last1[0];
out[vert_count].y = last1[1];
out[vert_count].z = last1[2];
vert_count++;
while( particles )
{
#if 1
vert_color = getTriBrightness( fraction );
out[vert_size].u = 1.0f;
out[vert_size].v = 1.0f;
out[vert_size].c = vert_color;
out[vert_size].x = last2[0];
out[vert_size].y = last2[1];
out[vert_size].z = last2[2];
saved_ptr = &out[vert_size];
vert_size++;
out[vert_size].u = 0.0f;
out[vert_size].v = 1.0f;
out[vert_size].c = vert_color;
out[vert_size].x = last1[0];
out[vert_size].y = last1[1];
out[vert_size].z = last1[2];
vert_size++;
#else
TriBrightness( fraction );
TriTexCoord2f( 1, 1 );
TriVertex3fv( last2 );
TriBrightness( fraction );
TriTexCoord2f( 0, 1 );
TriVertex3fv( last1 );
#endif
// Transform point into screen space
TriWorldToScreen( particles->org, screen );
// Build world-space normal to screen-space direction vector
@@ -845,7 +775,7 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
// Make a wide line
VectorMA( particles->org, pbeam->width, normal, last1 );
VectorMA( particles->org, -pbeam->width, normal, last2 );
vLast += vStep; // Advance texture scroll (v axis only)
if( particles->next != NULL )
@@ -856,55 +786,31 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
{
fraction = 0.0;
}
#if 1
vert_color = getTriBrightness( fraction );
out[vert_size].u = 0.0f;
out[vert_size].v = 0.0f;
out[vert_size].c = vert_color;
out[vert_size].x = last1[0];
out[vert_size].y = last1[1];
out[vert_size].z = last1[2];
vert_size++;
out[vert_size].u = saved_ptr->u;
out[vert_size].v = saved_ptr->v;
out[vert_size].c = saved_ptr->c;
out[vert_size].x = saved_ptr->x;
out[vert_size].y = saved_ptr->y;
out[vert_size].z = saved_ptr->z;
vert_size++;
out[vert_size].u = 0.0f;
out[vert_size].v = 0.0f;
out[vert_size].c = vert_color;
out[vert_size].x = last1[0];
out[vert_size].y = last1[1];
out[vert_size].z = last1[2];
vert_size++;
out[vert_size].u = 1.0f;
out[vert_size].v = 0.0f;
out[vert_size].c = vert_color;
out[vert_size].x = last2[0];
out[vert_size].y = last2[1];
out[vert_size].z = last2[2];
vert_size++;
#else
TriBrightness( fraction );
TriTexCoord2f( 0, 0 );
TriVertex3fv( last1 );
TriBrightness( fraction );
TriTexCoord2f( 1, 0 );
TriVertex3fv( last2 );
#endif
vert_color = getTriBrightness( fraction );
out[vert_count].u = 1.0f;
out[vert_count].v = vLast;
out[vert_count].c = vert_color;
out[vert_count].x = last2[0];
out[vert_count].y = last2[1];
out[vert_count].z = last2[2];
vert_count++;
out[vert_count].u = 0.0f;
out[vert_count].v = vLast;
out[vert_count].c = vert_color;
out[vert_count].x = last1[0];
out[vert_count].y = last1[1];
out[vert_count].z = last1[2];
vert_count++;
VectorCopy( screen, screenLast );
particles = particles->next;
}
#if 1
extGuEndPacket( ( void * )( out + vert_size ) );
sceGuDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF, vert_size, 0, out );
#endif
extGuEndPacket(( void * )( out + vert_count ));
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF, vert_count, 0, out );
// drift popcorn trail if there is a velocity
particles = pbeam->particles;
@@ -929,19 +835,20 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
vec3_t last1, last2, point, screen, screenLast;
vec3_t tmp, normal, center, xaxis, yaxis;
float radius, x, y, scale;
uint vert_count;
if( segments < 2 )
return;
VectorClear( screenLast );
segments = segments * M_PI_F;
if( segments > NOISE_DIVISIONS * 8 )
segments = NOISE_DIVISIONS * 8;
length = VectorLength( delta ) * 0.01f * M_PI_F;
if( length < 0.5f ) length = 0.5f; // Don't lose all of the noise/texture on short beams
div = 1.0f / ( segments - 1 );
vStep = length * div / 8.0f; // texture length texels per space pixel
@@ -959,7 +866,7 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
VectorCopy( delta, xaxis );
radius = VectorLength( xaxis );
// cull beamring
// --------------------------------
// Compute box center +/- radius
@@ -976,21 +883,22 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
return;
}
VectorSet( yaxis, xaxis[1], -xaxis[0], 0.0f );
VectorSet( yaxis, xaxis[1], -xaxis[0], 0.0f );
VectorNormalize( yaxis );
VectorScale( yaxis, radius, yaxis );
j = segments / 8;
#if 1
gu_vert_ftv_t* const out = ( gu_vert_ftv_t* )extGuBeginPacket( NULL );
unsigned int vert_size = 0;
#endif
vert_count = 0;
for( i = 0; i < segments + 1; i++ )
{
fraction = i * div;
SinCos( fraction * M_PI2_F, &x, &y );
VectorMAMAM( x, xaxis, y, yaxis, 1.0f, center, point );
VectorMAMAM( x, xaxis, y, yaxis, 1.0f, center, point );
// distort using noise
factor = rgNoise[(noiseIndex >> 16) & (NOISE_DIVISIONS - 1)] * scale;
@@ -1000,7 +908,7 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
factor = rgNoise[(noiseIndex >> 16) & (NOISE_DIVISIONS - 1)] * scale;
factor *= cos( fraction * M_PI_F * 24 + freq );
VectorMA( point, factor, RI.vright, point );
// Transform point into screen space
TriWorldToScreen( point, screen );
@@ -1016,31 +924,25 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
// Build point along normal line (normal is -y, x)
VectorScale( RI.vup, tmp[0], normal );
VectorMA( normal, tmp[1], RI.vright, normal );
// Make a wide line
VectorMA( point, width, normal, last1 );
VectorMA( point, -width, normal, last2 );
vLast += vStep; // Advance texture scroll (v axis only)
#if 1
out[vert_size].u = 1.0f;
out[vert_size].v = vLast;
out[vert_size].x = last2[0];
out[vert_size].y = last2[1];
out[vert_size].z = last2[2];
vert_size++;
out[vert_size].u = 0.0f;
out[vert_size].v = vLast;
out[vert_size].x = last1[0];
out[vert_size].y = last1[1];
out[vert_size].z = last1[2];
vert_size++;
#else
TriTexCoord2f( 1.0f, vLast );
TriVertex3fv( last2 );
TriTexCoord2f( 0.0f, vLast );
TriVertex3fv( last1 );
#endif
out[vert_count].u = 1.0f;
out[vert_count].v = vLast;
out[vert_count].x = last2[0];
out[vert_count].y = last2[1];
out[vert_count].z = last2[2];
vert_count++;
out[vert_count].u = 0.0f;
out[vert_count].v = vLast;
out[vert_count].x = last1[0];
out[vert_count].y = last1[1];
out[vert_count].z = last1[2];
vert_count++;
}
VectorCopy( screen, screenLast );
@@ -1053,10 +955,10 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
FracNoise( rgNoise, NOISE_DIVISIONS );
}
}
#if 1
extGuEndPacket( ( void * )( out + vert_size ) );
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_VERTEX_32BITF, vert_size, 0, out );
#endif
extGuEndPacket(( void * )( out + vert_count ));
sceGuDrawArray( GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_VERTEX_32BITF, vert_count, 0, out );
}
/*
@@ -1301,62 +1203,26 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
{
case TE_BEAMTORUS:
GL_Cull( GL_NONE );
#if 0
TriBegin( TRI_TRIANGLE_STRIP );
#endif
R_DrawTorus( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
#if 0
TriEnd();
#endif
break;
case TE_BEAMDISK:
GL_Cull( GL_NONE );
#if 0
TriBegin( TRI_TRIANGLE_STRIP );
#endif
R_DrawDisk( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
#if 0
TriEnd();
#endif
break;
case TE_BEAMCYLINDER:
GL_Cull( GL_NONE );
#if 0
TriBegin( TRI_TRIANGLE_STRIP );
#endif
R_DrawCylinder( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
#if 0
TriEnd();
#endif
break;
case TE_BEAMPOINTS:
case TE_BEAMHOSE:
#if 0
TriBegin( TRI_TRIANGLE_STRIP );
#endif
R_DrawSegs( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments, pbeam->flags );
#if 0
TriEnd();
#endif
break;
case TE_BEAMFOLLOW:
#if 0
TriBegin( TRI_QUADS );
#endif
R_DrawBeamFollow( pbeam, frametime );
#if 0
TriEnd();
#endif
break;
case TE_BEAMRING:
GL_Cull( GL_NONE );
#if 0
TriBegin( TRI_TRIANGLE_STRIP );
#endif
R_DrawRing( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
#if 0
TriEnd();
#endif
break;
}

View File

@@ -812,6 +812,7 @@ extern cvar_t *tracerblue;
extern cvar_t *traceralpha;
extern cvar_t *cl_lightstyle_lerping;
extern cvar_t *r_showhull;
extern cvar_t *r_fast_particles;
//
// engine callbacks

View File

@@ -49,6 +49,7 @@ cvar_t *r_traceglow;
cvar_t *r_dynamic;
cvar_t *r_lightmap;
cvar_t *r_showhull;
cvar_t *r_fast_particles;
cvar_t *gl_round_down;
cvar_t *gl_showtextures;
cvar_t *cl_lightstyle_lerping;
@@ -360,6 +361,7 @@ void GL_InitCommands( void )
r_drawentities = gEngfuncs.Cvar_Get( "r_drawentities", "1", FCVAR_CHEAT, "render entities" );
r_decals = gEngfuncs.pfnGetCvarPointer( "r_decals", 0 );
r_showhull = gEngfuncs.pfnGetCvarPointer( "r_showhull", 0 );
r_fast_particles = gEngfuncs.Cvar_Get( "r_fast_particles", "1", FCVAR_ARCHIVE, "use GU_POINTS for particles" );
gl_texture_nearest = gEngfuncs.Cvar_Get( "gl_texture_nearest", "0", FCVAR_GLCONFIG, "disable texture filter" );
gl_lightmap_nearest = gEngfuncs.Cvar_Get( "gl_lightmap_nearest", "0", FCVAR_GLCONFIG, "disable lightmap filter" );

View File

@@ -54,134 +54,124 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
color24 *pColor;
int alpha;
float size;
uint vert_count;
uint vert_color;
if( !cl_active_particles )
return; // nothing to draw?
#if 1
vert_count = 0;
vert_color = 0;
sceGuEnable( GU_BLEND );
sceGuDisable( GU_ALPHA_TEST );
sceGuBlendFunc( GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0 );
GL_Bind( XASH_TEXTURE0, tr.particleTexture );
sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGBA );
sceGuDepthMask( GU_TRUE );
gu_vert_ftcv_t* const out = ( gu_vert_ftcv_t* )extGuBeginPacket( NULL );
unsigned int vert_size = 0;
unsigned int vert_color = 0;
for( p = cl_active_particles; p; p = p->next )
if( r_fast_particles->value )
{
if(( p->type != pt_blob ) || ( p->packedColor == 255 ))
gu_vert_fcv_t* const out = ( gu_vert_fcv_t* )extGuBeginPacket( NULL );
sceGuDisable( GU_TEXTURE_2D );
for( p = cl_active_particles; p; p = p->next )
{
size = partsize; // get initial size of particle
if(( p->type != pt_blob ) || ( p->packedColor == 255 ))
{
p->color = bound( 0, p->color, 255 );
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
// scale up to keep particles from disappearing
size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
size += (p->org[1] - RI.vieworg[1]) * RI.cull_vforward[1];
size += (p->org[2] - RI.vieworg[2]) * RI.cull_vforward[2];
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
if( size < 20.0f ) size = partsize;
else size = partsize + size * 0.002f;
out[vert_count].c = GUCOLOR4UB( gEngfuncs.LightToTexGamma( pColor->r ),
gEngfuncs.LightToTexGamma( pColor->g ),
gEngfuncs.LightToTexGamma( pColor->b ), alpha );
out[vert_count].x = p->org[0];
out[vert_count].y = p->org[1];
out[vert_count].z = p->org[2];
vert_count++;
// scale the axes by radius
VectorScale( RI.cull_vright, size, right );
VectorScale( RI.cull_vup, size, up );
r_stats.c_particle_count++;
}
p->color = bound( 0, p->color, 255 );
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
vert_color = GUCOLOR4UB( gEngfuncs.LightToTexGamma( pColor->r ),
gEngfuncs.LightToTexGamma( pColor->g ),
gEngfuncs.LightToTexGamma( pColor->b ), alpha );
out[vert_size].u = 0.0f;
out[vert_size].v = 0.0f;
out[vert_size].c = vert_color;
out[vert_size].x = p->org[0] + right[0] + up[0];
out[vert_size].y = p->org[1] + right[1] + up[1];
out[vert_size].z = p->org[2] + right[2] + up[2];
vert_size++;
out[vert_size].u = 1.0f;
out[vert_size].v = 1.0f;
out[vert_size].c = vert_color;
out[vert_size].x = p->org[0] - right[0] - up[0];
out[vert_size].y = p->org[1] - right[1] - up[1];
out[vert_size].z = p->org[2] - right[2] - up[2];
vert_size++;
r_stats.c_particle_count++;
gEngfuncs.CL_ThinkParticle( frametime, p );
}
gEngfuncs.CL_ThinkParticle( frametime, p );
if( vert_count )
{
extGuEndPacket( ( void * )( out + vert_count ) );
sceGuDrawArray( GU_POINTS, GU_COLOR_8888 | GU_VERTEX_32BITF, vert_count, 0, out );
}
sceGuEnable( GU_TEXTURE_2D );
}
else
{
GL_Bind( XASH_TEXTURE0, tr.particleTexture );
sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGBA );
gu_vert_ftcv_t* const out = ( gu_vert_ftcv_t* )extGuBeginPacket( NULL );
for( p = cl_active_particles; p; p = p->next )
{
if(( p->type != pt_blob ) || ( p->packedColor == 255 ))
{
size = partsize; // get initial size of particle
// scale up to keep particles from disappearing
size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
size += (p->org[1] - RI.vieworg[1]) * RI.cull_vforward[1];
size += (p->org[2] - RI.vieworg[2]) * RI.cull_vforward[2];
if( size < 20.0f ) size = partsize;
else size = partsize + size * 0.002f;
// scale the axes by radius
VectorScale( RI.cull_vright, size, right );
VectorScale( RI.cull_vup, size, up );
p->color = bound( 0, p->color, 255 );
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
vert_color = GUCOLOR4UB( gEngfuncs.LightToTexGamma( pColor->r ),
gEngfuncs.LightToTexGamma( pColor->g ),
gEngfuncs.LightToTexGamma( pColor->b ), alpha );
out[vert_count].u = 0.0f;
out[vert_count].v = 0.0f;
out[vert_count].c = vert_color;
out[vert_count].x = p->org[0] + right[0] + up[0];
out[vert_count].y = p->org[1] + right[1] + up[1];
out[vert_count].z = p->org[2] + right[2] + up[2];
vert_count++;
out[vert_count].u = 1.0f;
out[vert_count].v = 1.0f;
out[vert_count].c = vert_color;
out[vert_count].x = p->org[0] - right[0] - up[0];
out[vert_count].y = p->org[1] - right[1] - up[1];
out[vert_count].z = p->org[2] - right[2] - up[2];
vert_count++;
r_stats.c_particle_count++;
}
gEngfuncs.CL_ThinkParticle( frametime, p );
}
if( vert_count )
{
extGuEndPacket(( void * )( out + vert_count ));
sceGuDrawArray( GU_SPRITES, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF, vert_count, 0, out );
}
}
if( vert_size )
{
extGuEndPacket( ( void * )( out + vert_size ) );
sceGuDrawArray( GU_SPRITES, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF, vert_size, 0, out );
}
sceGuDepthMask( GU_FALSE );
#else
pglEnable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
GL_Bind( XASH_TEXTURE0, tr.particleTexture );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglDepthMask( GL_FALSE );
pglBegin( GL_QUADS );
for( p = cl_active_particles; p; p = p->next )
{
if(( p->type != pt_blob ) || ( p->packedColor == 255 ))
{
size = partsize; // get initial size of particle
// scale up to keep particles from disappearing
size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
size += (p->org[1] - RI.vieworg[1]) * RI.cull_vforward[1];
size += (p->org[2] - RI.vieworg[2]) * RI.cull_vforward[2];
if( size < 20.0f ) size = partsize;
else size = partsize + size * 0.002f;
// scale the axes by radius
VectorScale( RI.cull_vright, size, right );
VectorScale( RI.cull_vup, size, up );
p->color = bound( 0, p->color, 255 );
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
pglColor4ub( gEngfuncs.LightToTexGamma( pColor->r ),
gEngfuncs.LightToTexGamma( pColor->g ),
gEngfuncs.LightToTexGamma( pColor->b ), alpha );
pglTexCoord2f( 0.0f, 1.0f );
pglVertex3f( p->org[0] - right[0] + up[0], p->org[1] - right[1] + up[1], p->org[2] - right[2] + up[2] );
pglTexCoord2f( 0.0f, 0.0f );
pglVertex3f( p->org[0] + right[0] + up[0], p->org[1] + right[1] + up[1], p->org[2] + right[2] + up[2] );
pglTexCoord2f( 1.0f, 0.0f );
pglVertex3f( p->org[0] + right[0] - up[0], p->org[1] + right[1] - up[1], p->org[2] + right[2] - up[2] );
pglTexCoord2f( 1.0f, 1.0f );
pglVertex3f( p->org[0] - right[0] - up[0], p->org[1] - right[1] - up[1], p->org[2] - right[2] - up[2] );
r_stats.c_particle_count++;
}
gEngfuncs.CL_ThinkParticle( frametime, p );
}
pglEnd();
pglDepthMask( GL_TRUE );
#endif
}
/*
@@ -251,19 +241,12 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
if( !cl_active_tracers )
return; // nothing to draw?
if( !TriSpriteTexture( gEngfuncs.GetDefaultSprite( REF_DOT_SPRITE ), 0 ))
return;
#if 1
sceGuEnable( GU_BLEND );
sceGuBlendFunc( GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, GUBLEND1 );
sceGuDisable( GU_ALPHA_TEST );
sceGuDepthMask( GU_TRUE );
#else
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglDisable( GL_ALPHA_TEST );
pglDepthMask( GL_FALSE );
#endif
sceGuDisable( GU_TEXTURE_2D );
gravity = frametime * MOVEVARS->gravity;
scale = 1.0 - (frametime * 0.9);
if( scale < 0.0f ) scale = 0.0f;
@@ -312,47 +295,22 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
}
pColor = &gTracerColors[p->color];
#if 1
sceGuColor( GUCOLOR4UB( pColor->r, pColor->g, pColor->b, p->packedColor ) );
sceGuColor( GUCOLOR4UB( pColor->r, pColor->g, pColor->b, p->packedColor ));
gu_vert_ftv_t* const out = ( gu_vert_ftv_t* )sceGuGetMemory( sizeof( gu_vert_ftv_t ) * 4 );
out[0].u = 0.0f;
out[0].v = 0.8f;
gu_vert_fv_t* const out = ( gu_vert_fv_t* )sceGuGetMemory( sizeof( gu_vert_fv_t ) * 4 );
out[0].x = verts[2][0];
out[0].y = verts[2][1];
out[0].z = verts[2][2];
out[1].u = 1.0f;
out[1].v = 0.8f;
out[1].x = verts[3][0];
out[1].y = verts[3][1];
out[1].z = verts[3][2];
out[2].u = 1.0f;
out[2].v = 0.0f;
out[2].x = verts[1][0];
out[2].y = verts[1][1];
out[2].z = verts[1][2];
out[3].u = 0.0f;
out[3].v = 0.0f;
out[3].x = verts[0][0];
out[3].y = verts[0][1];
out[3].z = verts[0][2];
sceGuDrawArray( GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF, 4, 0, out );
#else
pglColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
pglBegin( GL_QUADS );
pglTexCoord2f( 0.0f, 0.8f );
pglVertex3fv( verts[2] );
pglTexCoord2f( 1.0f, 0.8f );
pglVertex3fv( verts[3] );
pglTexCoord2f( 1.0f, 0.0f );
pglVertex3fv( verts[1] );
pglTexCoord2f( 0.0f, 0.0f );
pglVertex3fv( verts[0] );
pglEnd();
#endif
sceGuDrawArray( GU_TRIANGLE_FAN, GU_VERTEX_32BITF, 4, 0, out );
}
// evaluate position
@@ -372,11 +330,9 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
p->vel[2] = gravity * 0.05f;
}
}
#if 1
sceGuEnable( GU_TEXTURE_2D );
sceGuDepthMask( GU_FALSE );
#else
pglDepthMask( GL_TRUE );
#endif
}
/*

View File

@@ -729,46 +729,26 @@ R_DrawSpriteQuad
*/
static void R_DrawSpriteQuad( mspriteframe_t *frame, vec3_t org, vec3_t v_right, vec3_t v_up, float scale )
{
vec3_t point;
r_stats.c_sprite_polys++;
#if 0
gu_vert_t* const out = ( gu_vert_t* )sceGuGetMemory( sizeof( gu_vert_t ) * 4 );
VectorMA( org, frame->down * scale, v_up, point );
VectorMA( point, frame->left * scale, v_right, point );
out[0].uv[0] = 0.0f;
out[0].uv[1] = 1.0f;
VectorCopy( point, out[0].xyz );
VectorMA( org, frame->up * scale, v_up, point );
VectorMA( point, frame->left * scale, v_right, point );
VectorMA( org, frame->down * scale, v_up, out[0].xyz );
VectorMA( out[0].xyz, frame->left * scale, v_right, out[0].xyz );
out[1].uv[0] = 0.0f;
out[1].uv[1] = 0.0f;
VectorCopy( point, out[1].xyz );
VectorMA( org, frame->up * scale, v_up, point );
VectorMA( point, frame->right * scale, v_right, point );
VectorMA( org, frame->up * scale, v_up, out[1].xyz );
VectorMA( out[1].xyz, frame->left * scale, v_right, out[1].xyz );
out[2].uv[0] = 1.0f;
out[2].uv[1] = 0.0f;
VectorCopy( point, out[2].xyz );
VectorMA( org, frame->down * scale, v_up, point );
VectorMA( point, frame->right * scale, v_right, point );
VectorMA( org, frame->up * scale, v_up, out[2].xyz );
VectorMA( out[2].xyz, frame->right * scale, v_right, out[2].xyz );
out[3].uv[0] = 1.0f;
out[3].uv[1] = 1.0f;
VectorCopy( point, out[3].xyz );
VectorMA( org, frame->down * scale, v_up, out[3].xyz );
VectorMA( out[3].xyz, frame->right * scale, v_right, out[3].xyz );
sceGuDrawArray( GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF, 4, 0, out );
#else
gu_vert_t* const out = ( gu_vert_t* )sceGuGetMemory( sizeof( gu_vert_t ) * 2 );
VectorMA( org, frame->up * scale, v_up, point );
VectorMA( point, frame->left * scale, v_right, point );
out[0].uv[0] = 0.0f;
out[0].uv[1] = 0.0f;
VectorCopy( point, out[0].xyz );
VectorMA( org, frame->down * scale, v_up, point );
VectorMA( point, frame->right * scale, v_right, point );
out[1].uv[0] = 1.0f;
out[1].uv[1] = 1.0f;
VectorCopy( point, out[1].xyz );
sceGuDrawArray( GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF, 2, 0, out );
#endif
}
static qboolean R_SpriteHasLightmap( cl_entity_t *e, int texFormat )
@@ -1014,7 +994,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
sceGuDisable( GU_ALPHA_TEST );
sceGuBlendFunc( GU_ADD, GU_FIX, GU_SRC_COLOR, GUBLEND0, 0 );
sceGuTexFunc( GU_TFX_MODULATE , GU_TCC_RGBA );
sceGuColor( GUCOLOR4F( color2[0], color2[1], color2[2], tr.blend ) );
GL_Bind( XASH_TEXTURE0, tr.whiteTexture );
R_DrawSpriteQuad( frame, origin, v_right, v_up, scale );