mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-14 00:11:01 +00:00
completely removed flare support
This commit is contained in:
parent
837073be62
commit
6f3908ceaa
11 changed files with 8 additions and 660 deletions
|
@ -5,6 +5,8 @@ chg: SSE2 instruction set support is now required
|
||||||
|
|
||||||
chg: removed FreeType 2 and the unused R_REGISTERFONT syscalls that were using it
|
chg: removed FreeType 2 and the unused R_REGISTERFONT syscalls that were using it
|
||||||
|
|
||||||
|
chg: removed light flares and all related cvars (r_flare*)
|
||||||
|
|
||||||
fix: r_monitor on Linux is now 0-based and the value doesn't change incorrectly on its own anymore
|
fix: r_monitor on Linux is now 0-based and the value doesn't change incorrectly on its own anymore
|
||||||
|
|
||||||
fix: when a latched cvar's value is set to its default, the cvar is no longer marked as changed
|
fix: when a latched cvar's value is set to its default, the cvar is no longer marked as changed
|
||||||
|
|
|
@ -533,9 +533,6 @@ static void RB_RenderDrawSurfList( const drawSurf_t* drawSurfs, int numDrawSurfs
|
||||||
if ( depthRange ) {
|
if ( depthRange ) {
|
||||||
qglDepthRange( 0, 1 );
|
qglDepthRange( 0, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// add light flares on lights that aren't obscured
|
|
||||||
RB_RenderFlares();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -491,21 +491,12 @@ static void ParseTriSurf( const dsurface_t* ds, const drawVert_t* verts, msurfac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ParseFlare( const dsurface_t* ds, const drawVert_t* verts, msurface_t* surf, const int* indexes )
|
static void ParseFlare( const dsurface_t* ds, msurface_t* surf )
|
||||||
{
|
{
|
||||||
|
static surfaceType_t flare = SF_FLARE;
|
||||||
surf->fogIndex = LittleLong( ds->fogNum ) + 1;
|
surf->fogIndex = LittleLong( ds->fogNum ) + 1;
|
||||||
surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX );
|
surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX );
|
||||||
|
surf->data = &flare;
|
||||||
srfFlare_t* flare = RI_New<srfFlare_t>();
|
|
||||||
flare->surfaceType = SF_FLARE;
|
|
||||||
|
|
||||||
surf->data = (surfaceType_t*)flare;
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
flare->origin[i] = LittleFloat( ds->lightmapOrigin[i] );
|
|
||||||
flare->color[i] = LittleFloat( ds->lightmapVecs[0][i] );
|
|
||||||
flare->normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1238,7 +1229,7 @@ static void R_LoadSurfaces( const lump_t* surfs, const lump_t* verts, const lump
|
||||||
numFaces++;
|
numFaces++;
|
||||||
break;
|
break;
|
||||||
case MST_FLARE:
|
case MST_FLARE:
|
||||||
ParseFlare( in, dv, out, indexes );
|
ParseFlare( in, out );
|
||||||
numFlares++;
|
numFlares++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,546 +0,0 @@
|
||||||
/*
|
|
||||||
===========================================================================
|
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
|
||||||
or (at your option) any later version.
|
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Quake III Arena source code; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
===========================================================================
|
|
||||||
*/
|
|
||||||
// tr_flares.c
|
|
||||||
|
|
||||||
#include "tr_local.h"
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
void R_ClearFlares( void ) {}
|
|
||||||
void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal ) {}
|
|
||||||
void RB_RenderFlares( void ) {}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/*
|
|
||||||
=============================================================================
|
|
||||||
|
|
||||||
LIGHT FLARES
|
|
||||||
|
|
||||||
A light flare is an effect that takes place inside the eye when bright light
|
|
||||||
sources are visible. The size of the flare reletive to the screen is nearly
|
|
||||||
constant, irrespective of distance, but the intensity should be proportional to the
|
|
||||||
projected area of the light source.
|
|
||||||
|
|
||||||
A surface that has been flagged as having a light flare will calculate the depth
|
|
||||||
buffer value that it's midpoint should have when the surface is added.
|
|
||||||
|
|
||||||
After all opaque surfaces have been rendered, the depth buffer is read back for
|
|
||||||
each flare in view. If the point has not been obscured by a closer surface, the
|
|
||||||
flare should be drawn.
|
|
||||||
|
|
||||||
Surfaces that have a repeated texture should never be flagged as flaring, because
|
|
||||||
there will only be a single flare added at the midpoint of the polygon.
|
|
||||||
|
|
||||||
To prevent abrupt popping, the intensity of the flare is interpolated up and
|
|
||||||
down as it changes visibility. This involves scene to scene state, unlike almost
|
|
||||||
all other aspects of the renderer, and is complicated by the fact that a single
|
|
||||||
frame may have multiple scenes.
|
|
||||||
|
|
||||||
RB_RenderFlares() will be called once per view (twice in a mirrored scene, potentially
|
|
||||||
up to five or more times in a frame with 3D status bar icons).
|
|
||||||
|
|
||||||
=============================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// flare states maintain visibility over multiple frames for fading
|
|
||||||
// layers: view, mirror, menu
|
|
||||||
typedef struct flare_s {
|
|
||||||
struct flare_s *next; // for active chain
|
|
||||||
|
|
||||||
int addedFrame;
|
|
||||||
|
|
||||||
qbool inPortal; // qtrue if in a portal view of the scene
|
|
||||||
int frameSceneNum;
|
|
||||||
void *surface;
|
|
||||||
int fogNum;
|
|
||||||
|
|
||||||
int fadeTime;
|
|
||||||
|
|
||||||
qbool visible; // state of last test
|
|
||||||
float drawIntensity; // may be non 0 even if !visible due to fading
|
|
||||||
|
|
||||||
int windowX, windowY;
|
|
||||||
float eyeZ;
|
|
||||||
|
|
||||||
vec3_t origin;
|
|
||||||
vec3_t color;
|
|
||||||
} flare_t;
|
|
||||||
|
|
||||||
#define MAX_FLARES 128
|
|
||||||
|
|
||||||
flare_t r_flareStructs[MAX_FLARES];
|
|
||||||
flare_t *r_activeFlares, *r_inactiveFlares;
|
|
||||||
|
|
||||||
float flareCoeff;
|
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
R_ClearFlares
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void R_ClearFlares( void ) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
Com_Memset( r_flareStructs, 0, sizeof( r_flareStructs ) );
|
|
||||||
r_activeFlares = NULL;
|
|
||||||
r_inactiveFlares = NULL;
|
|
||||||
|
|
||||||
for ( i = 0 ; i < MAX_FLARES ; i++ ) {
|
|
||||||
r_flareStructs[i].next = r_inactiveFlares;
|
|
||||||
r_inactiveFlares = &r_flareStructs[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
RB_AddFlare
|
|
||||||
|
|
||||||
This is called at surface tesselation time
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal ) {
|
|
||||||
int i;
|
|
||||||
flare_t *f;
|
|
||||||
vec3_t local;
|
|
||||||
float d = 1;
|
|
||||||
vec4_t eye, clip, normalized, window;
|
|
||||||
|
|
||||||
backEnd.pc[RB_FLARE_ADDS]++;
|
|
||||||
|
|
||||||
if(normal && (normal[0] || normal[1] || normal[2]))
|
|
||||||
{
|
|
||||||
VectorSubtract( backEnd.viewParms.orient.origin, point, local );
|
|
||||||
VectorNormalizeFast(local);
|
|
||||||
d = DotProduct(local, normal);
|
|
||||||
|
|
||||||
// If the viewer is behind the flare don't add it.
|
|
||||||
if(d < 0)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the point is off the screen, don't bother adding it
|
|
||||||
// calculate screen coordinates and depth
|
|
||||||
R_TransformModelToClip( point, backEnd.orient.modelMatrix,
|
|
||||||
backEnd.viewParms.projectionMatrix, eye, clip );
|
|
||||||
|
|
||||||
// check to see if the point is completely off screen
|
|
||||||
for ( i = 0 ; i < 3 ; i++ ) {
|
|
||||||
if ( clip[i] >= clip[3] || clip[i] <= -clip[3] ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
R_TransformClipToWindow( clip, &backEnd.viewParms, normalized, window );
|
|
||||||
|
|
||||||
if ( window[0] < 0 || window[0] >= backEnd.viewParms.viewportWidth
|
|
||||||
|| window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) {
|
|
||||||
return; // shouldn't happen, since we check the clip[] above, except for FP rounding
|
|
||||||
}
|
|
||||||
|
|
||||||
// see if a flare with a matching surface, scene, and view exists
|
|
||||||
for ( f = r_activeFlares ; f ; f = f->next ) {
|
|
||||||
if ( f->surface == surface && f->frameSceneNum == backEnd.viewParms.frameSceneNum
|
|
||||||
&& f->inPortal == backEnd.viewParms.isPortal ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// allocate a new one
|
|
||||||
if (!f ) {
|
|
||||||
if ( !r_inactiveFlares ) {
|
|
||||||
// the list is completely full
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
f = r_inactiveFlares;
|
|
||||||
r_inactiveFlares = r_inactiveFlares->next;
|
|
||||||
f->next = r_activeFlares;
|
|
||||||
r_activeFlares = f;
|
|
||||||
|
|
||||||
f->surface = surface;
|
|
||||||
f->frameSceneNum = backEnd.viewParms.frameSceneNum;
|
|
||||||
f->inPortal = backEnd.viewParms.isPortal;
|
|
||||||
f->addedFrame = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( f->addedFrame != backEnd.viewParms.frameCount - 1 ) {
|
|
||||||
f->visible = qfalse;
|
|
||||||
f->fadeTime = backEnd.refdef.time - 2000;
|
|
||||||
}
|
|
||||||
|
|
||||||
f->addedFrame = backEnd.viewParms.frameCount;
|
|
||||||
f->fogNum = fogNum;
|
|
||||||
|
|
||||||
VectorCopy(point, f->origin);
|
|
||||||
VectorCopy( color, f->color );
|
|
||||||
|
|
||||||
// fade the intensity of the flare down as the
|
|
||||||
// light surface turns away from the viewer
|
|
||||||
VectorScale( f->color, d, f->color );
|
|
||||||
|
|
||||||
// save info needed to test
|
|
||||||
f->windowX = backEnd.viewParms.viewportX + window[0];
|
|
||||||
f->windowY = backEnd.viewParms.viewportY + window[1];
|
|
||||||
|
|
||||||
f->eyeZ = eye[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
RB_AddDlightFlares
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void RB_AddDlightFlares( void ) {
|
|
||||||
dlight_t *l;
|
|
||||||
int i, j, k;
|
|
||||||
fog_t *fog = NULL;
|
|
||||||
|
|
||||||
if ( !r_flares->integer ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
l = backEnd.refdef.dlights;
|
|
||||||
|
|
||||||
if(tr.world)
|
|
||||||
fog = tr.world->fogs;
|
|
||||||
|
|
||||||
for (i=0 ; i<backEnd.refdef.num_dlights ; i++, l++) {
|
|
||||||
|
|
||||||
if(fog)
|
|
||||||
{
|
|
||||||
// find which fog volume the light is in
|
|
||||||
for ( j = 1 ; j < tr.world->numfogs ; j++ ) {
|
|
||||||
fog = &tr.world->fogs[j];
|
|
||||||
for ( k = 0 ; k < 3 ; k++ ) {
|
|
||||||
if ( l->origin[k] < fog->bounds[0][k] || l->origin[k] > fog->bounds[1][k] ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( k == 3 ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( j == tr.world->numfogs ) {
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
j = 0;
|
|
||||||
|
|
||||||
RB_AddFlare( (void *)l, j, l->origin, l->color, NULL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
===============================================================================
|
|
||||||
|
|
||||||
FLARE BACK END
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
RB_TestFlare
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void RB_TestFlare( flare_t *f ) {
|
|
||||||
float depth;
|
|
||||||
qbool visible;
|
|
||||||
float fade;
|
|
||||||
float screenZ;
|
|
||||||
|
|
||||||
backEnd.pc[RB_FLARE_TESTS]++;
|
|
||||||
|
|
||||||
// doing a readpixels is as good as doing a glFinish(), so
|
|
||||||
// don't bother with another sync
|
|
||||||
glState.finishCalled = qfalse;
|
|
||||||
|
|
||||||
// read back the z buffer contents
|
|
||||||
qglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth );
|
|
||||||
|
|
||||||
screenZ = backEnd.viewParms.projectionMatrix[14] /
|
|
||||||
( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] );
|
|
||||||
|
|
||||||
visible = ( -f->eyeZ - -screenZ ) < 24;
|
|
||||||
|
|
||||||
if ( visible ) {
|
|
||||||
if ( !f->visible ) {
|
|
||||||
f->visible = qtrue;
|
|
||||||
f->fadeTime = backEnd.refdef.time - 1;
|
|
||||||
}
|
|
||||||
fade = ( ( backEnd.refdef.time - f->fadeTime ) /1000.0f ) * r_flareFade->value;
|
|
||||||
} else {
|
|
||||||
if ( f->visible ) {
|
|
||||||
f->visible = qfalse;
|
|
||||||
f->fadeTime = backEnd.refdef.time - 1;
|
|
||||||
}
|
|
||||||
fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( fade < 0 ) {
|
|
||||||
fade = 0;
|
|
||||||
}
|
|
||||||
if ( fade > 1 ) {
|
|
||||||
fade = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
f->drawIntensity = fade;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
RB_RenderFlare
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void RB_RenderFlare( flare_t *f ) {
|
|
||||||
float size;
|
|
||||||
vec3_t color;
|
|
||||||
int iColor[3];
|
|
||||||
float distance, intensity, factor;
|
|
||||||
byte fogFactors[3] = {255, 255, 255};
|
|
||||||
|
|
||||||
backEnd.pc[RB_FLARE_RENDERS]++;
|
|
||||||
|
|
||||||
// We don't want too big values anyways when dividing by distance.
|
|
||||||
if(f->eyeZ > -1.0f)
|
|
||||||
distance = 1.0f;
|
|
||||||
else
|
|
||||||
distance = -f->eyeZ;
|
|
||||||
|
|
||||||
// calculate the flare size..
|
|
||||||
size = backEnd.viewParms.viewportWidth * ( r_flareSize->value/640.0f + 8 / distance );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is an alternative to intensity scaling. It changes the size of the flare on screen instead
|
|
||||||
* with growing distance. See in the description at the top why this is not the way to go.
|
|
||||||
// size will change ~ 1/r.
|
|
||||||
size = backEnd.viewParms.viewportWidth * (r_flareSize->value / (distance * -2.0f));
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* As flare sizes stay nearly constant with increasing distance we must decrease the intensity
|
|
||||||
* to achieve a reasonable visual result. The intensity is ~ (size^2 / distance^2) which can be
|
|
||||||
* got by considering the ratio of
|
|
||||||
* (flaresurface on screen) : (Surface of sphere defined by flare origin and distance from flare)
|
|
||||||
* An important requirement is:
|
|
||||||
* intensity <= 1 for all distances.
|
|
||||||
*
|
|
||||||
* The formula used here to compute the intensity is as follows:
|
|
||||||
* intensity = flareCoeff * size^2 / (distance + size*sqrt(flareCoeff))^2
|
|
||||||
* As you can see, the intensity will have a max. of 1 when the distance is 0.
|
|
||||||
* The coefficient flareCoeff will determine the falloff speed with increasing distance.
|
|
||||||
*/
|
|
||||||
|
|
||||||
factor = distance + size * sqrt(flareCoeff);
|
|
||||||
|
|
||||||
intensity = flareCoeff * size * size / (factor * factor);
|
|
||||||
|
|
||||||
VectorScale(f->color, f->drawIntensity * intensity, color);
|
|
||||||
|
|
||||||
// Calculations for fogging
|
|
||||||
if(tr.world && f->fogNum < tr.world->numfogs)
|
|
||||||
{
|
|
||||||
tess.numVertexes = 1;
|
|
||||||
VectorCopy(f->origin, tess.xyz[0]);
|
|
||||||
tess.fogNum = f->fogNum;
|
|
||||||
|
|
||||||
RB_CalcModulateColorsByFog(fogFactors);
|
|
||||||
|
|
||||||
// We don't need to render the flare if colors are 0 anyways.
|
|
||||||
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.xyz[tess.numVertexes][2] = 0;
|
|
||||||
tess.xyz[tess.numVertexes][3] = 1;
|
|
||||||
tess.texCoords[tess.numVertexes][0][0] = 0;
|
|
||||||
tess.texCoords[tess.numVertexes][0][1] = 0;
|
|
||||||
tess.vertexColors[tess.numVertexes][0] = iColor[0];
|
|
||||||
tess.vertexColors[tess.numVertexes][1] = iColor[1];
|
|
||||||
tess.vertexColors[tess.numVertexes][2] = iColor[2];
|
|
||||||
tess.vertexColors[tess.numVertexes][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;
|
|
||||||
tess.xyz[tess.numVertexes][3] = 1;
|
|
||||||
tess.texCoords[tess.numVertexes][0][0] = 0;
|
|
||||||
tess.texCoords[tess.numVertexes][0][1] = 1;
|
|
||||||
tess.vertexColors[tess.numVertexes][0] = iColor[0];
|
|
||||||
tess.vertexColors[tess.numVertexes][1] = iColor[1];
|
|
||||||
tess.vertexColors[tess.numVertexes][2] = iColor[2];
|
|
||||||
tess.vertexColors[tess.numVertexes][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;
|
|
||||||
tess.xyz[tess.numVertexes][3] = 1;
|
|
||||||
tess.texCoords[tess.numVertexes][0][0] = 1;
|
|
||||||
tess.texCoords[tess.numVertexes][0][1] = 1;
|
|
||||||
tess.vertexColors[tess.numVertexes][0] = iColor[0];
|
|
||||||
tess.vertexColors[tess.numVertexes][1] = iColor[1];
|
|
||||||
tess.vertexColors[tess.numVertexes][2] = iColor[2];
|
|
||||||
tess.vertexColors[tess.numVertexes][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;
|
|
||||||
tess.xyz[tess.numVertexes][3] = 1;
|
|
||||||
tess.texCoords[tess.numVertexes][0][0] = 1;
|
|
||||||
tess.texCoords[tess.numVertexes][0][1] = 0;
|
|
||||||
tess.vertexColors[tess.numVertexes][0] = iColor[0];
|
|
||||||
tess.vertexColors[tess.numVertexes][1] = iColor[1];
|
|
||||||
tess.vertexColors[tess.numVertexes][2] = iColor[2];
|
|
||||||
tess.vertexColors[tess.numVertexes][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_EndSurface();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
RB_RenderFlares
|
|
||||||
|
|
||||||
Because flares are simulating an occular effect, they should be drawn after
|
|
||||||
everything (all views) in the entire frame has been drawn.
|
|
||||||
|
|
||||||
Because of the way portals use the depth buffer to mark off areas, the
|
|
||||||
needed information would be lost after each view, so we are forced to draw
|
|
||||||
flares after each view.
|
|
||||||
|
|
||||||
The resulting artifact is that flares in mirrors or portals don't dim properly
|
|
||||||
when occluded by something in the main view, and portal flares that should
|
|
||||||
extend past the portal edge will be overwritten.
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
void RB_RenderFlares (void) {
|
|
||||||
flare_t *f;
|
|
||||||
flare_t **prev;
|
|
||||||
qbool draw;
|
|
||||||
|
|
||||||
if ( !r_flares->integer ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(r_flareCoeff->modified)
|
|
||||||
{
|
|
||||||
if(r_flareCoeff->value == 0.0f)
|
|
||||||
flareCoeff = 150;
|
|
||||||
else
|
|
||||||
flareCoeff = r_flareCoeff->value;
|
|
||||||
|
|
||||||
r_flareCoeff->modified = qfalse;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset currentEntity to world so that any previously referenced entities
|
|
||||||
// don't have influence on the rendering of these flares (i.e. RF_ renderer flags).
|
|
||||||
backEnd.currentEntity = &tr.worldEntity;
|
|
||||||
backEnd.orient = backEnd.viewParms.world;
|
|
||||||
|
|
||||||
// if we use it - flare is blink
|
|
||||||
//RB_AddDlightFlares();
|
|
||||||
|
|
||||||
// perform z buffer readback on each flare in this view
|
|
||||||
draw = qfalse;
|
|
||||||
prev = &r_activeFlares;
|
|
||||||
while ( ( f = *prev ) != NULL ) {
|
|
||||||
// throw out any flares that weren't added last frame
|
|
||||||
if ( f->addedFrame < backEnd.viewParms.frameCount - 1 ) {
|
|
||||||
*prev = f->next;
|
|
||||||
f->next = r_inactiveFlares;
|
|
||||||
r_inactiveFlares = f;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't draw any here that aren't from this scene / portal
|
|
||||||
f->drawIntensity = 0;
|
|
||||||
if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum
|
|
||||||
&& f->inPortal == backEnd.viewParms.isPortal ) {
|
|
||||||
RB_TestFlare( f );
|
|
||||||
if ( f->drawIntensity ) {
|
|
||||||
draw = qtrue;
|
|
||||||
} else {
|
|
||||||
// this flare has completely faded out, so remove it from the chain
|
|
||||||
*prev = f->next;
|
|
||||||
f->next = r_inactiveFlares;
|
|
||||||
r_inactiveFlares = f;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prev = &f->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !draw ) {
|
|
||||||
return; // none visible
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( backEnd.viewParms.isPortal ) {
|
|
||||||
qglDisable (GL_CLIP_PLANE0);
|
|
||||||
}
|
|
||||||
|
|
||||||
qglPushMatrix();
|
|
||||||
qglLoadIdentity();
|
|
||||||
qglMatrixMode( GL_PROJECTION );
|
|
||||||
qglPushMatrix();
|
|
||||||
qglLoadIdentity();
|
|
||||||
qglOrtho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth,
|
|
||||||
backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight,
|
|
||||||
-99999, 99999 );
|
|
||||||
|
|
||||||
for ( f = r_activeFlares ; f ; f = f->next ) {
|
|
||||||
if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum
|
|
||||||
&& f->inPortal == backEnd.viewParms.isPortal
|
|
||||||
&& f->drawIntensity ) {
|
|
||||||
RB_RenderFlare( f );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qglPopMatrix();
|
|
||||||
qglMatrixMode( GL_MODELVIEW );
|
|
||||||
qglPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // 0
|
|
|
@ -107,11 +107,6 @@ cvar_t *r_directedScale;
|
||||||
cvar_t *r_debugLight;
|
cvar_t *r_debugLight;
|
||||||
cvar_t *r_debugSort;
|
cvar_t *r_debugSort;
|
||||||
|
|
||||||
cvar_t *r_flares;
|
|
||||||
cvar_t *r_flareSize;
|
|
||||||
cvar_t *r_flareFade;
|
|
||||||
cvar_t *r_flareCoeff;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
cvar_t *r_maplightBrightness;
|
cvar_t *r_maplightBrightness;
|
||||||
cvar_t *r_maplightSaturation;
|
cvar_t *r_maplightSaturation;
|
||||||
|
@ -561,7 +556,6 @@ static const cvarTableItem_t r_cvars[] =
|
||||||
// archived variables that can change at any time
|
// archived variables that can change at any time
|
||||||
//
|
//
|
||||||
{ &r_lodbias, "r_lodbias", "-2", CVAR_ARCHIVE, CVART_INTEGER, "-16", "16", help_r_lodbias },
|
{ &r_lodbias, "r_lodbias", "-2", CVAR_ARCHIVE, CVART_INTEGER, "-16", "16", help_r_lodbias },
|
||||||
{ &r_flares, "r_flares", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "enables light flares" },
|
|
||||||
{ &r_ignoreGLErrors, "r_ignoreGLErrors", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "if " S_COLOR_VAL "0" S_COLOR_HELP ", OpenGL errors are fatal" },
|
{ &r_ignoreGLErrors, "r_ignoreGLErrors", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "if " S_COLOR_VAL "0" S_COLOR_HELP ", OpenGL errors are fatal" },
|
||||||
{ &r_fastsky, "r_fastsky", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_r_fastsky },
|
{ &r_fastsky, "r_fastsky", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_r_fastsky },
|
||||||
{ &r_noportals, "r_noportals", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_r_noportals },
|
{ &r_noportals, "r_noportals", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_r_noportals },
|
||||||
|
@ -587,9 +581,6 @@ static const cvarTableItem_t r_cvars[] =
|
||||||
{ &r_nocurves, "r_nocurves", "0", CVAR_CHEAT },
|
{ &r_nocurves, "r_nocurves", "0", CVAR_CHEAT },
|
||||||
{ &r_drawworld, "r_drawworld", "1", CVAR_CHEAT },
|
{ &r_drawworld, "r_drawworld", "1", CVAR_CHEAT },
|
||||||
{ &r_portalOnly, "r_portalOnly", "0", CVAR_CHEAT },
|
{ &r_portalOnly, "r_portalOnly", "0", CVAR_CHEAT },
|
||||||
{ &r_flareSize, "r_flareSize", "40", CVAR_CHEAT },
|
|
||||||
{ &r_flareFade, "r_flareFade", "7", CVAR_CHEAT },
|
|
||||||
{ &r_flareCoeff, "r_flareCoeff", "150", CVAR_CHEAT },
|
|
||||||
{ &r_measureOverdraw, "r_measureOverdraw", "0", CVAR_CHEAT },
|
{ &r_measureOverdraw, "r_measureOverdraw", "0", CVAR_CHEAT },
|
||||||
{ &r_lodscale, "r_lodscale", "5", CVAR_CHEAT },
|
{ &r_lodscale, "r_lodscale", "5", CVAR_CHEAT },
|
||||||
{ &r_norefresh, "r_norefresh", "0", CVAR_CHEAT },
|
{ &r_norefresh, "r_norefresh", "0", CVAR_CHEAT },
|
||||||
|
@ -713,7 +704,6 @@ static void RE_BeginRegistration( glconfig_t* glconfigOut )
|
||||||
R_SyncRenderThread();
|
R_SyncRenderThread();
|
||||||
|
|
||||||
tr.viewCluster = -1; // force markleafs to regenerate
|
tr.viewCluster = -1; // force markleafs to regenerate
|
||||||
R_ClearFlares();
|
|
||||||
RE_ClearScene();
|
RE_ClearScene();
|
||||||
|
|
||||||
tr.registered = qtrue;
|
tr.registered = qtrue;
|
||||||
|
|
|
@ -505,14 +505,6 @@ struct srfPoly_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct srfFlare_s {
|
|
||||||
surfaceType_t surfaceType;
|
|
||||||
vec3_t origin;
|
|
||||||
vec3_t normal;
|
|
||||||
vec3_t color;
|
|
||||||
} srfFlare_t;
|
|
||||||
|
|
||||||
|
|
||||||
struct srfGridMesh_t {
|
struct srfGridMesh_t {
|
||||||
surfaceType_t surfaceType;
|
surfaceType_t surfaceType;
|
||||||
|
|
||||||
|
@ -844,8 +836,6 @@ typedef struct {
|
||||||
|
|
||||||
shader_t* defaultShader;
|
shader_t* defaultShader;
|
||||||
|
|
||||||
shader_t *flareShader;
|
|
||||||
|
|
||||||
int numLightmaps;
|
int numLightmaps;
|
||||||
image_t *lightmaps[MAX_LIGHTMAPS];
|
image_t *lightmaps[MAX_LIGHTMAPS];
|
||||||
|
|
||||||
|
@ -991,11 +981,6 @@ extern cvar_t *r_debugSurface;
|
||||||
extern cvar_t *r_showImages;
|
extern cvar_t *r_showImages;
|
||||||
extern cvar_t *r_debugSort;
|
extern cvar_t *r_debugSort;
|
||||||
|
|
||||||
extern cvar_t *r_flares;
|
|
||||||
extern cvar_t *r_flareSize;
|
|
||||||
extern cvar_t *r_flareFade;
|
|
||||||
extern cvar_t *r_flareCoeff;
|
|
||||||
|
|
||||||
|
|
||||||
void R_NoiseInit();
|
void R_NoiseInit();
|
||||||
double R_NoiseGet4f( double x, double y, double z, double t );
|
double R_NoiseGet4f( double x, double y, double z, double t );
|
||||||
|
@ -1223,19 +1208,6 @@ void R_AddWorldSurfaces();
|
||||||
qbool R_inPVS( const vec3_t p1, const vec3_t p2 );
|
qbool R_inPVS( const vec3_t p1, const vec3_t p2 );
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
============================================================
|
|
||||||
|
|
||||||
FLARES
|
|
||||||
|
|
||||||
============================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void R_ClearFlares( void );
|
|
||||||
void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal );
|
|
||||||
void RB_AddDlightFlares( void );
|
|
||||||
void RB_RenderFlares (void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============================================================
|
============================================================
|
||||||
|
|
||||||
|
|
|
@ -84,10 +84,6 @@ enum {
|
||||||
RB_LIT_INDICES_LATECULL_IN,
|
RB_LIT_INDICES_LATECULL_IN,
|
||||||
RB_LIT_INDICES_LATECULL_OUT,
|
RB_LIT_INDICES_LATECULL_OUT,
|
||||||
|
|
||||||
RB_FLARE_ADDS,
|
|
||||||
RB_FLARE_TESTS,
|
|
||||||
RB_FLARE_RENDERS,
|
|
||||||
|
|
||||||
RB_STATS_MAX
|
RB_STATS_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2532,23 +2532,6 @@ static void CreateInternalShaders()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void CreateExternalShaders()
|
|
||||||
{
|
|
||||||
tr.flareShader = R_FindShader( "flareShader", LIGHTMAP_NONE, qtrue );
|
|
||||||
|
|
||||||
// Hack to make fogging work correctly on flares. Fog colors are calculated
|
|
||||||
// in tr_flare.c already.
|
|
||||||
if (!tr.flareShader->defaultShader)
|
|
||||||
{
|
|
||||||
for (int index = 0; index < tr.flareShader->numStages; index++)
|
|
||||||
{
|
|
||||||
tr.flareShader->stages[index]->adjustColorsForFog = ACFF_NONE;
|
|
||||||
tr.flareShader->stages[index]->stateBits |= GLS_DEPTHTEST_DISABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void R_InitShaders()
|
void R_InitShaders()
|
||||||
{
|
{
|
||||||
ri.Printf( PRINT_ALL, "Initializing Shaders\n" );
|
ri.Printf( PRINT_ALL, "Initializing Shaders\n" );
|
||||||
|
@ -2558,6 +2541,4 @@ void R_InitShaders()
|
||||||
CreateInternalShaders();
|
CreateInternalShaders();
|
||||||
|
|
||||||
ScanAndLoadShaderFiles();
|
ScanAndLoadShaderFiles();
|
||||||
|
|
||||||
CreateExternalShaders();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -735,29 +735,6 @@ NULL MODEL
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// draws x/y/z lines from the origin for orientation debugging
|
|
||||||
|
|
||||||
static void RB_SurfaceAxis()
|
|
||||||
{
|
|
||||||
GL_Bind( tr.whiteImage );
|
|
||||||
qglLineWidth( 3 );
|
|
||||||
qglBegin( GL_LINES );
|
|
||||||
qglColor3f( 1,0,0 );
|
|
||||||
qglVertex3f( 0,0,0 );
|
|
||||||
qglVertex3f( 16,0,0 );
|
|
||||||
qglColor3f( 0,1,0 );
|
|
||||||
qglVertex3f( 0,0,0 );
|
|
||||||
qglVertex3f( 0,16,0 );
|
|
||||||
qglColor3f( 0,0,1 );
|
|
||||||
qglVertex3f( 0,0,0 );
|
|
||||||
qglVertex3f( 0,0,16 );
|
|
||||||
qglEnd();
|
|
||||||
qglLineWidth( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
static void RB_SurfaceBad( const surfaceType_t* surfType )
|
static void RB_SurfaceBad( const surfaceType_t* surfType )
|
||||||
{
|
{
|
||||||
|
@ -781,16 +758,9 @@ static void RB_SurfaceEntity( surfaceType_t* surfType )
|
||||||
RB_SurfaceLightningBolt();
|
RB_SurfaceLightningBolt();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RB_SurfaceAxis();
|
// invalid or deprecated
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void RB_SurfaceFlare(srfFlare_t *surf) {
|
|
||||||
if (r_flares->integer)
|
|
||||||
RB_AddFlare(surf, tess.fogNum, surf->origin, surf->color, surf->normal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -802,6 +772,6 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( const void* ) = {
|
||||||
(void(*)( const void* ))RB_SurfaceTriangles, // SF_TRIANGLES
|
(void(*)( const void* ))RB_SurfaceTriangles, // SF_TRIANGLES
|
||||||
(void(*)( const void* ))RB_SurfacePolychain, // SF_POLY
|
(void(*)( const void* ))RB_SurfacePolychain, // SF_POLY
|
||||||
(void(*)( const void* ))RB_SurfaceMesh, // SF_MD3
|
(void(*)( const void* ))RB_SurfaceMesh, // SF_MD3
|
||||||
(void(*)( const void* ))RB_SurfaceFlare, // SF_FLARE
|
(void(*)( const void* ))RB_SurfaceSkip, // SF_FLARE
|
||||||
(void(*)( const void* ))RB_SurfaceEntity, // SF_ENTITY
|
(void(*)( const void* ))RB_SurfaceEntity, // SF_ENTITY
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,7 +124,6 @@ OBJECTS := \
|
||||||
$(OBJDIR)/tr_bsp.o \
|
$(OBJDIR)/tr_bsp.o \
|
||||||
$(OBJDIR)/tr_cmds.o \
|
$(OBJDIR)/tr_cmds.o \
|
||||||
$(OBJDIR)/tr_curve.o \
|
$(OBJDIR)/tr_curve.o \
|
||||||
$(OBJDIR)/tr_flares.o \
|
|
||||||
$(OBJDIR)/tr_gl2.o \
|
$(OBJDIR)/tr_gl2.o \
|
||||||
$(OBJDIR)/tr_image.o \
|
$(OBJDIR)/tr_image.o \
|
||||||
$(OBJDIR)/tr_init.o \
|
$(OBJDIR)/tr_init.o \
|
||||||
|
@ -213,9 +212,6 @@ $(OBJDIR)/tr_cmds.o: ../../code/renderer/tr_cmds.cpp
|
||||||
$(OBJDIR)/tr_curve.o: ../../code/renderer/tr_curve.cpp
|
$(OBJDIR)/tr_curve.o: ../../code/renderer/tr_curve.cpp
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
$(OBJDIR)/tr_flares.o: ../../code/renderer/tr_flares.cpp
|
|
||||||
@echo $(notdir $<)
|
|
||||||
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
|
||||||
$(OBJDIR)/tr_gl2.o: ../../code/renderer/tr_gl2.cpp
|
$(OBJDIR)/tr_gl2.o: ../../code/renderer/tr_gl2.cpp
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
|
|
@ -213,7 +213,6 @@
|
||||||
<ClCompile Include="..\..\code\renderer\tr_bsp.cpp" />
|
<ClCompile Include="..\..\code\renderer\tr_bsp.cpp" />
|
||||||
<ClCompile Include="..\..\code\renderer\tr_cmds.cpp" />
|
<ClCompile Include="..\..\code\renderer\tr_cmds.cpp" />
|
||||||
<ClCompile Include="..\..\code\renderer\tr_curve.cpp" />
|
<ClCompile Include="..\..\code\renderer\tr_curve.cpp" />
|
||||||
<ClCompile Include="..\..\code\renderer\tr_flares.cpp" />
|
|
||||||
<ClCompile Include="..\..\code\renderer\tr_gl2.cpp" />
|
<ClCompile Include="..\..\code\renderer\tr_gl2.cpp" />
|
||||||
<ClCompile Include="..\..\code\renderer\tr_image.cpp" />
|
<ClCompile Include="..\..\code\renderer\tr_image.cpp" />
|
||||||
<ClCompile Include="..\..\code\renderer\tr_init.cpp" />
|
<ClCompile Include="..\..\code\renderer\tr_init.cpp" />
|
||||||
|
|
Loading…
Reference in a new issue