1
0
Fork 0

Renderers: use generic quads instead of color clear function to draw hyperspace effect

This commit is contained in:
Eugene 2022-01-29 22:32:03 +02:00
parent 86f27c3e9c
commit b576a48699
12 changed files with 204 additions and 153 deletions

View File

@ -427,6 +427,8 @@ void GL_ClientState( int unit, unsigned stateBits )
}
void RB_SetGL2D( void );
/*
================
RB_Hyperspace
@ -435,24 +437,39 @@ A player has predicted a teleport, but hasn't arrived yet
================
*/
static void RB_Hyperspace( void ) {
float c;
color4ub_t c;
if ( !backEnd.isHyperspace ) {
// do initialization shit
}
c = ( backEnd.refdef.time & 255 ) / 255.0f;
qglClearColor( c, c, c, 1 );
qglClear( GL_COLOR_BUFFER_BIT );
if ( tess.shader != tr.whiteShader ) {
if ( tess.numIndexes ) {
RB_EndSurface();
}
RB_BeginSurface( tr.whiteShader, 0 );
}
VBO_UnBind();
RB_SetGL2D();
c.rgba[0] = c.rgba[1] = c.rgba[2] = (backEnd.refdef.time & 255);
c.rgba[3] = 255;
RB_AddQuadStamp2( backEnd.refdef.x, backEnd.refdef.y, backEnd.refdef.width, backEnd.refdef.height,
0.0, 0.0, 0.0, 0.0, c );
RB_EndSurface();
backEnd.isHyperspace = qtrue;
}
static void SetViewportAndScissor( void ) {
qglMatrixMode(GL_PROJECTION);
qglMatrixMode( GL_PROJECTION );
qglLoadMatrixf( backEnd.viewParms.projectionMatrix );
qglMatrixMode(GL_MODELVIEW);
qglMatrixMode( GL_MODELVIEW );
// set the window clipping
qglViewport( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY,
@ -511,13 +528,11 @@ static void RB_BeginDrawingView( void ) {
}
qglClear( clearBits );
if ( backEnd.refdef.rdflags & RDF_HYPERSPACE )
{
if ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) {
RB_Hyperspace();
return;
}
else
{
backEnd.projection2D = qfalse;
SetViewportAndScissor();
} else {
backEnd.isHyperspace = qfalse;
}
@ -926,6 +941,7 @@ RENDER BACK END FUNCTIONS
============================================================================
*/
/*
================
RB_SetGL2D

View File

@ -197,9 +197,9 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t
f->eyeZ = eye[2];
if ( backEnd.viewParms.portalView )
f->drawZ = (clip[2] + clip[3] - 2 ) / ( 2 * clip[3] );
f->drawZ = (clip[2] + clip[3] - 1.5 ) / ( 2 * clip[3] );
else
f->drawZ = (clip[2] + clip[3] - 1 ) / ( 2 * clip[3] );
f->drawZ = (clip[2] + clip[3] - 0.5 ) / ( 2 * clip[3] );
}
@ -309,9 +309,9 @@ RB_RenderFlare
static void RB_RenderFlare( flare_t *f ) {
float size;
vec3_t color;
int iColor[3];
float distance, intensity, factor;
byte fogFactors[3] = {255, 255, 255};
color4ub_t c;
backEnd.pc.c_flareRenders++;
@ -352,7 +352,7 @@ static void RB_RenderFlare( flare_t *f ) {
VectorScale(f->color, f->drawIntensity * intensity, color);
// Calculations for fogging
if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs)
if ( tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs )
{
tess.numVertexes = 1;
VectorCopy(f->origin, tess.xyz[0]);
@ -361,63 +361,18 @@ static void RB_RenderFlare( flare_t *f ) {
RB_CalcModulateColorsByFog(fogFactors);
// We don't need to render the flare if colors are 0 anyways.
if(!(fogFactors[0] || fogFactors[1] || fogFactors[2]))
if (!(fogFactors[0] || fogFactors[1] || fogFactors[2]))
return;
}
iColor[0] = color[0] * fogFactors[0];
iColor[1] = color[1] * fogFactors[1];
iColor[2] = color[2] * fogFactors[2];
RB_BeginSurface( tr.flareShader, f->fogNum );
// FIXME: use quadstamp?
tess.xyz[tess.numVertexes][0] = f->windowX - size;
tess.xyz[tess.numVertexes][1] = f->windowY - size;
tess.texCoords[0][tess.numVertexes][0] = 0;
tess.texCoords[0][tess.numVertexes][1] = 0;
tess.vertexColors[tess.numVertexes].rgba[0] = iColor[0];
tess.vertexColors[tess.numVertexes].rgba[1] = iColor[1];
tess.vertexColors[tess.numVertexes].rgba[2] = iColor[2];
tess.vertexColors[tess.numVertexes].rgba[3] = 255;
tess.numVertexes++;
c.rgba[0] = color[0] * fogFactors[0];
c.rgba[1] = color[1] * fogFactors[1];
c.rgba[2] = color[2] * fogFactors[2];
c.rgba[3] = 255;
tess.xyz[tess.numVertexes][0] = f->windowX - size;
tess.xyz[tess.numVertexes][1] = f->windowY + size;
tess.texCoords[0][tess.numVertexes][0] = 0;
tess.texCoords[0][tess.numVertexes][1] = 1;
tess.vertexColors[tess.numVertexes].rgba[0] = iColor[0];
tess.vertexColors[tess.numVertexes].rgba[1] = iColor[1];
tess.vertexColors[tess.numVertexes].rgba[2] = iColor[2];
tess.vertexColors[tess.numVertexes].rgba[3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX + size;
tess.xyz[tess.numVertexes][1] = f->windowY + size;
tess.texCoords[0][tess.numVertexes][0] = 1;
tess.texCoords[0][tess.numVertexes][1] = 1;
tess.vertexColors[tess.numVertexes].rgba[0] = iColor[0];
tess.vertexColors[tess.numVertexes].rgba[1] = iColor[1];
tess.vertexColors[tess.numVertexes].rgba[2] = iColor[2];
tess.vertexColors[tess.numVertexes].rgba[3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX + size;
tess.xyz[tess.numVertexes][1] = f->windowY - size;
tess.texCoords[0][tess.numVertexes][0] = 1;
tess.texCoords[0][tess.numVertexes][1] = 0;
tess.vertexColors[tess.numVertexes].rgba[0] = iColor[0];
tess.vertexColors[tess.numVertexes].rgba[1] = iColor[1];
tess.vertexColors[tess.numVertexes].rgba[2] = iColor[2];
tess.vertexColors[tess.numVertexes].rgba[3] = 255;
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 1;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 3;
RB_AddQuadStamp2( f->windowX - size, f->windowY - size, size * 2, size * 2, 0, 0, 1, 1, c );
RB_EndSurface();
}

View File

@ -1094,6 +1094,7 @@ typedef struct {
image_t *identityLightImage; // full of tr.identityLightByte
shader_t *defaultShader;
shader_t *whiteShader;
shader_t *cinematicShader;
shader_t *shadowShader;
shader_t *projectionShadowShader;
@ -1518,6 +1519,7 @@ void RB_StageIteratorSky( void );
void RB_AddQuadStamp( const vec3_t origin, const vec3_t left, const vec3_t up, const byte *color );
void RB_AddQuadStampExt( const vec3_t origin, const vec3_t left, const vec3_t up, const byte *color, float s1, float t1, float s2, float t2 );
void RB_AddQuadStamp2( float x, float y, float w, float h, float s1, float t1, float s2, float t2, color4ub_t color );
void RB_ShowImages( void );

View File

@ -208,7 +208,7 @@ void RB_CalcBulgeVertexes( deformStage_t *ds ) {
float *normal = ( float * ) tess.normal;
double now;
now = backEnd.refdef.time * 0.001 * ds->bulgeSpeed;
now = backEnd.refdef.floatTime * ds->bulgeSpeed;
for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 2, normal += 4 ) {
int64_t off;

View File

@ -3583,6 +3583,13 @@ static void CreateInternalShaders( void ) {
stages[0].stateBits = GLS_DEFAULT;
tr.defaultShader = FinishShader();
InitShader( "<whiteShader>", LIGHTMAP_NONE );
stages[0].bundle[0].image[0] = tr.whiteImage;
stages[0].active = qtrue;
stages[0].rgbGen = CGEN_EXACT_VERTEX;
stages[0].stateBits = GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;
tr.whiteShader = FinishShader();
// shadow shader is just a marker
InitShader( "<stencil shadow>", LIGHTMAP_NONE );
stages[0].bundle[0].image[0] = tr.defaultImage;

View File

@ -130,17 +130,70 @@ void RB_AddQuadStampExt( const vec3_t origin, const vec3_t left, const vec3_t up
// constant color all the way around
// should this be identity and let the shader specify from entity?
* ( unsigned int * ) &tess.vertexColors[ndx] =
* ( unsigned int * ) &tess.vertexColors[ndx+1] =
* ( unsigned int * ) &tess.vertexColors[ndx+2] =
* ( unsigned int * ) &tess.vertexColors[ndx+3] =
* ( unsigned int * )color;
tess.vertexColors[ndx+0].u32 =
tess.vertexColors[ndx+1].u32 =
tess.vertexColors[ndx+2].u32 =
tess.vertexColors[ndx+3].u32 =
* ( uint32_t * )color;
tess.numVertexes += 4;
tess.numIndexes += 6;
}
void RB_AddQuadStamp2( float x, float y, float w, float h, float s1, float t1, float s2, float t2, color4ub_t color ) {
int numIndexes;
int numVerts;
RB_CHECKOVERFLOW( 4, 6 );
tess.surfType = SF_TRIANGLES;
numIndexes = tess.numIndexes;
numVerts = tess.numVertexes;
tess.numVertexes += 4;
tess.numIndexes += 6;
tess.indexes[numIndexes + 0] = numVerts + 3;
tess.indexes[numIndexes + 1] = numVerts + 0;
tess.indexes[numIndexes + 2] = numVerts + 2;
tess.indexes[numIndexes + 3] = numVerts + 2;
tess.indexes[numIndexes + 4] = numVerts + 0;
tess.indexes[numIndexes + 5] = numVerts + 1;
tess.vertexColors[numVerts + 0].u32 =
tess.vertexColors[numVerts + 1].u32 =
tess.vertexColors[numVerts + 2].u32 =
tess.vertexColors[numVerts + 3].u32 = color.u32;
tess.xyz[numVerts + 0][0] = x;
tess.xyz[numVerts + 0][1] = y;
tess.xyz[numVerts + 0][2] = 0;
tess.xyz[numVerts + 1][0] = x + w;
tess.xyz[numVerts + 1][1] = y;
tess.xyz[numVerts + 1][2] = 0;
tess.xyz[numVerts + 2][0] = x + w;
tess.xyz[numVerts + 2][1] = y + h;
tess.xyz[numVerts + 2][2] = 0;
tess.xyz[numVerts + 3][0] = x;
tess.xyz[numVerts + 3][1] = y + h;
tess.xyz[numVerts + 3][2] = 0;
tess.texCoords[0][numVerts + 0][0] = s1;
tess.texCoords[0][numVerts + 0][1] = t1;
tess.texCoords[0][numVerts + 1][0] = s2;
tess.texCoords[0][numVerts + 1][1] = s1;
tess.texCoords[0][numVerts + 2][0] = s2;
tess.texCoords[0][numVerts + 2][1] = t2;
tess.texCoords[0][numVerts + 3][0] = s1;
tess.texCoords[0][numVerts + 3][1] = t2;
}
/*
==============
RB_AddQuadStamp

View File

@ -437,6 +437,8 @@ void GL_ClientState( int unit, unsigned stateBits )
#endif
void RB_SetGL2D( void );
/*
================
RB_Hyperspace
@ -445,25 +447,30 @@ A player has predicted a teleport, but hasn't arrived yet
================
*/
static void RB_Hyperspace( void ) {
float c;
color4ub_t c;
if ( !backEnd.isHyperspace ) {
// do initialization shit
}
#ifdef USE_VULKAN
{
vec4_t color;
c = ( backEnd.refdef.time & 255 ) / 255.0f;
color[0] = color[1] = color[2] = c;
color[3] = 1.0;
vk_clear_color( color );
if ( tess.shader != tr.whiteShader ) {
if ( tess.numIndexes ) {
RB_EndSurface();
}
RB_BeginSurface( tr.whiteShader, 0 );
}
#else
c = ( backEnd.refdef.time & 255 ) / 255.0f;
qglClearColor( c, c, c, 1 );
qglClear( GL_COLOR_BUFFER_BIT );
#endif
VBO_UnBind();
RB_SetGL2D();
c.rgba[0] = c.rgba[1] = c.rgba[2] = (backEnd.refdef.time & 255);
c.rgba[3] = 255;
RB_AddQuadStamp2( backEnd.refdef.x, backEnd.refdef.y, backEnd.refdef.width, backEnd.refdef.height,
0.0, 0.0, 0.0, 0.0, c );
RB_EndSurface();
backEnd.isHyperspace = qtrue;
}
@ -544,13 +551,11 @@ static void RB_BeginDrawingView( void ) {
qglClear( clearBits );
#endif
if ( backEnd.refdef.rdflags & RDF_HYPERSPACE )
{
if ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) {
RB_Hyperspace();
return;
}
else
{
backEnd.projection2D = qfalse;
SetViewportAndScissor();
} else {
backEnd.isHyperspace = qfalse;
}

View File

@ -1172,6 +1172,7 @@ typedef struct {
image_t *identityLightImage; // full of tr.identityLightByte
shader_t *defaultShader;
shader_t *whiteShader;
shader_t *cinematicShader;
shader_t *shadowShader;
shader_t *projectionShadowShader;
@ -1613,6 +1614,7 @@ void RB_StageIteratorSky( void );
void RB_AddQuadStamp( const vec3_t origin, const vec3_t left, const vec3_t up, const byte *color );
void RB_AddQuadStampExt( const vec3_t origin, const vec3_t left, const vec3_t up, const byte *color, float s1, float t1, float s2, float t2 );
void RB_AddQuadStamp2( float x, float y, float w, float h, float s1, float t1, float s2, float t2, color4ub_t color );
void RB_ShowImages( void );

View File

@ -208,7 +208,7 @@ void RB_CalcBulgeVertexes( deformStage_t *ds ) {
float *normal = ( float * ) tess.normal;
double now;
now = backEnd.refdef.time * 0.001 * ds->bulgeSpeed;
now = backEnd.refdef.floatTime * ds->bulgeSpeed;
for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 2, normal += 4 ) {
int64_t off;

View File

@ -4027,6 +4027,13 @@ static void CreateInternalShaders( void ) {
stages[0].stateBits = GLS_DEFAULT;
tr.defaultShader = FinishShader();
InitShader( "<white>", LIGHTMAP_NONE );
stages[0].bundle[0].image[0] = tr.whiteImage;
stages[0].active = qtrue;
stages[0].bundle[0].rgbGen = CGEN_EXACT_VERTEX;
stages[0].stateBits = GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;
tr.whiteShader = FinishShader();
// shadow shader is just a marker
InitShader( "<stencil shadow>", LIGHTMAP_NONE );
stages[0].bundle[0].image[0] = tr.defaultImage;

View File

@ -134,17 +134,70 @@ void RB_AddQuadStampExt( const vec3_t origin, const vec3_t left, const vec3_t up
// constant color all the way around
// should this be identity and let the shader specify from entity?
* ( unsigned int * ) &tess.vertexColors[ndx] =
* ( unsigned int * ) &tess.vertexColors[ndx+1] =
* ( unsigned int * ) &tess.vertexColors[ndx+2] =
* ( unsigned int * ) &tess.vertexColors[ndx+3] =
* ( unsigned int * )color;
tess.vertexColors[ndx+0].u32 =
tess.vertexColors[ndx+1].u32 =
tess.vertexColors[ndx+2].u32 =
tess.vertexColors[ndx+3].u32 =
* ( uint32_t * )color;
tess.numVertexes += 4;
tess.numIndexes += 6;
}
void RB_AddQuadStamp2( float x, float y, float w, float h, float s1, float t1, float s2, float t2, color4ub_t color ) {
int numIndexes;
int numVerts;
RB_CHECKOVERFLOW( 4, 6 );
tess.surfType = SF_TRIANGLES;
numIndexes = tess.numIndexes;
numVerts = tess.numVertexes;
tess.numVertexes += 4;
tess.numIndexes += 6;
tess.indexes[numIndexes + 0] = numVerts + 3;
tess.indexes[numIndexes + 1] = numVerts + 0;
tess.indexes[numIndexes + 2] = numVerts + 2;
tess.indexes[numIndexes + 3] = numVerts + 2;
tess.indexes[numIndexes + 4] = numVerts + 0;
tess.indexes[numIndexes + 5] = numVerts + 1;
tess.vertexColors[numVerts + 0].u32 =
tess.vertexColors[numVerts + 1].u32 =
tess.vertexColors[numVerts + 2].u32 =
tess.vertexColors[numVerts + 3].u32 = color.u32;
tess.xyz[numVerts + 0][0] = x;
tess.xyz[numVerts + 0][1] = y;
tess.xyz[numVerts + 0][2] = 0;
tess.xyz[numVerts + 1][0] = x + w;
tess.xyz[numVerts + 1][1] = y;
tess.xyz[numVerts + 1][2] = 0;
tess.xyz[numVerts + 2][0] = x + w;
tess.xyz[numVerts + 2][1] = y + h;
tess.xyz[numVerts + 2][2] = 0;
tess.xyz[numVerts + 3][0] = x;
tess.xyz[numVerts + 3][1] = y + h;
tess.xyz[numVerts + 3][2] = 0;
tess.texCoords[0][numVerts + 0][0] = s1;
tess.texCoords[0][numVerts + 0][1] = t1;
tess.texCoords[0][numVerts + 1][0] = s2;
tess.texCoords[0][numVerts + 1][1] = s1;
tess.texCoords[0][numVerts + 2][0] = s2;
tess.texCoords[0][numVerts + 2][1] = t2;
tess.texCoords[0][numVerts + 3][0] = s1;
tess.texCoords[0][numVerts + 3][1] = t2;
}
/*
==============
RB_AddQuadStamp

View File

@ -387,9 +387,9 @@ RB_RenderFlare
static void RB_RenderFlare( flare_t *f ) {
float size;
vec3_t color;
int iColor[3];
float distance, intensity, factor;
byte fogFactors[3] = {255, 255, 255};
color4ub_t c;
//if ( f->drawIntensity == 0.0 )
// return;
@ -446,63 +446,14 @@ static void RB_RenderFlare( flare_t *f ) {
return;
}
iColor[0] = color[0] * fogFactors[0];
iColor[1] = color[1] * fogFactors[1];
iColor[2] = color[2] * fogFactors[2];
RB_BeginSurface( tr.flareShader, f->fogNum );
// FIXME: use quadstamp?
tess.xyz[tess.numVertexes][0] = f->windowX - size;
tess.xyz[tess.numVertexes][1] = f->windowY - size;
tess.xyz[tess.numVertexes][2] = 0.0;
tess.texCoords[0][tess.numVertexes][0] = 0;
tess.texCoords[0][tess.numVertexes][1] = 0;
tess.vertexColors[tess.numVertexes].rgba[0] = iColor[0];
tess.vertexColors[tess.numVertexes].rgba[1] = iColor[1];
tess.vertexColors[tess.numVertexes].rgba[2] = iColor[2];
tess.vertexColors[tess.numVertexes].rgba[3] = 255;
tess.numVertexes++;
c.rgba[0] = color[0] * fogFactors[0];
c.rgba[1] = color[1] * fogFactors[1];
c.rgba[2] = color[2] * fogFactors[2];
c.rgba[3] = 255;
tess.xyz[tess.numVertexes][0] = f->windowX - size;
tess.xyz[tess.numVertexes][1] = f->windowY + size;
tess.xyz[tess.numVertexes][2] = 0.0;
tess.texCoords[0][tess.numVertexes][0] = 0;
tess.texCoords[0][tess.numVertexes][1] = 1;
tess.vertexColors[tess.numVertexes].rgba[0] = iColor[0];
tess.vertexColors[tess.numVertexes].rgba[1] = iColor[1];
tess.vertexColors[tess.numVertexes].rgba[2] = iColor[2];
tess.vertexColors[tess.numVertexes].rgba[3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX + size;
tess.xyz[tess.numVertexes][1] = f->windowY + size;
tess.xyz[tess.numVertexes][2] = 0.0;
tess.texCoords[0][tess.numVertexes][0] = 1;
tess.texCoords[0][tess.numVertexes][1] = 1;
tess.vertexColors[tess.numVertexes].rgba[0] = iColor[0];
tess.vertexColors[tess.numVertexes].rgba[1] = iColor[1];
tess.vertexColors[tess.numVertexes].rgba[2] = iColor[2];
tess.vertexColors[tess.numVertexes].rgba[3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX + size;
tess.xyz[tess.numVertexes][1] = f->windowY - size;
tess.xyz[tess.numVertexes][2] = 0.0;
tess.texCoords[0][tess.numVertexes][0] = 1;
tess.texCoords[0][tess.numVertexes][1] = 0;
tess.vertexColors[tess.numVertexes].rgba[0] = iColor[0];
tess.vertexColors[tess.numVertexes].rgba[1] = iColor[1];
tess.vertexColors[tess.numVertexes].rgba[2] = iColor[2];
tess.vertexColors[tess.numVertexes].rgba[3] = 255;
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 1;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 3;
RB_AddQuadStamp2( f->windowX - size, f->windowY - size, size * 2, size * 2, 0, 0, 1, 1, c );
RB_EndSurface();
}