Skip to content

Clean up remnants of forward lighting code #1709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/engine/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ void MaterialSystem::RenderMaterials( const shaderSort_t fromSort, const shaderS
}

tr.drawingSky = true;
Tess_Begin( Tess_StageIteratorSky, skyShader, nullptr, false, -1, 0, false );
Tess_Begin( Tess_StageIteratorSky, skyShader, false, -1, 0, false );
Tess_End();
}
}
Expand Down
46 changes: 23 additions & 23 deletions src/engine/renderer/tr_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ static void RB_RenderDrawSurfaces( shaderSort_t fromSort, shaderSort_t toSort,
Tess_End();
}

Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, lightmapNum, fogNum, bspSurface );
Tess_Begin( Tess_StageIteratorColor, shader, false, lightmapNum, fogNum, bspSurface );

oldShader = shader;
oldLightmapNum = lightmapNum;
Expand Down Expand Up @@ -1623,7 +1623,7 @@ static void RB_RenderDebugUtils()
GL_LoadModelViewMatrix( backEnd.orientation.modelViewMatrix );
gl_genericShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] );

Tess_Begin( Tess_StageIteratorDebug, nullptr, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );

if ( r_showEntityBounds.Get() == 2)
{
Expand Down Expand Up @@ -1739,7 +1739,7 @@ static void RB_RenderDebugUtils()
static vec3_t worldOrigins[ MAX_BONES ];

GL_State( GLS_POLYMODE_LINE | GLS_DEPTHTEST_DISABLE );
Tess_Begin( Tess_StageIteratorDebug, nullptr, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );

for ( j = 0; j < skel->numBones; j++ )
{
Expand Down Expand Up @@ -1843,7 +1843,7 @@ static void RB_RenderDebugUtils()
}

Tess_End();
Tess_Begin( Tess_StageIteratorDebug, shader, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, shader, true, -1, 0 );
gl_genericShader->SetUniform_ColorMapBindless(
GL_BindToTMU( 0, shader->stages[ 0 ].bundle[ TB_COLORMAP ].image[ 0 ] )
);
Expand Down Expand Up @@ -1906,7 +1906,7 @@ static void RB_RenderDebugUtils()

cubemapProbe_t* cubeProbe = &tr.cubeProbes[tr.cubeProbeGrid( x, y, z )];

Tess_Begin( Tess_StageIteratorDebug, nullptr, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );

gl_reflectionShader->SetUniform_CameraPosition( position );

Expand All @@ -1922,7 +1922,7 @@ static void RB_RenderDebugUtils()
} else {
for ( const cubemapProbe_t& cubeProbe : tr.cubeProbes ) {

Tess_Begin( Tess_StageIteratorDebug, nullptr, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );

gl_reflectionShader->SetUniform_CameraPosition( cubeProbe.origin );

Expand Down Expand Up @@ -1975,7 +1975,7 @@ static void RB_RenderDebugUtils()
vec3_t gridPoints[2];
R_GetNearestCubeMaps( backEnd.viewParms.orientation.origin, probes, trilerp, 2, gridPoints );

Tess_Begin( Tess_StageIteratorDebug, nullptr, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );

vec3_t position;
if ( r_showCubeProbes.Get() == Util::ordinal( showCubeProbesMode::GRID ) ) {
Expand Down Expand Up @@ -2048,7 +2048,7 @@ static void RB_RenderDebugUtils()
);
gl_genericShader->SetUniform_TextureMatrix( matrixIdentity );

Tess_Begin( Tess_StageIteratorDebug, nullptr, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );
GL_CheckErrors();

for ( z = 0; z < tr.world->lightGridBounds[ 2 ]; z++ ) {
Expand Down Expand Up @@ -2235,7 +2235,7 @@ static void RB_RenderDebugUtils()
R_CalcFrustumNearCorners( splitFrustum, nearCorners );
R_CalcFrustumFarCorners( splitFrustum, farCorners );

Tess_Begin( Tess_StageIteratorDebug, nullptr, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );

// draw outer surfaces
for ( j = 0; j < 4; j++ )
Expand Down Expand Up @@ -2332,7 +2332,7 @@ static void RB_RenderDebugUtils()
GL_PolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
}

Tess_Begin( Tess_StageIteratorDebug, nullptr, nullptr, true, -1, 0 );
Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );
Tess_AddCube( vec3_origin, node->mins, node->maxs, Color::White );
Tess_End();

Expand Down Expand Up @@ -2792,11 +2792,11 @@ const RenderCommand *StretchPicCommand::ExecuteSelf( ) const
}

backEnd.currentEntity = &backEnd.entity2D;
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

if( !tess.indexes ) {
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

Tess_CheckOverflow( 4, 6 );
Expand Down Expand Up @@ -2878,7 +2878,7 @@ const RenderCommand *Poly2dCommand::ExecuteSelf( ) const
}

backEnd.currentEntity = &backEnd.entity2D;
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

Tess_CheckOverflow( numverts, ( numverts - 2 ) * 3 );
Expand Down Expand Up @@ -2929,11 +2929,11 @@ const RenderCommand *Poly2dIndexedCommand::ExecuteSelf( ) const
}

backEnd.currentEntity = &backEnd.entity2D;
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

if( !tess.verts ) {
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

Tess_CheckOverflow( numverts, numIndexes );
Expand Down Expand Up @@ -3022,11 +3022,11 @@ const RenderCommand *RotatedPicCommand::ExecuteSelf( ) const
}

backEnd.currentEntity = &backEnd.entity2D;
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

if( !tess.indexes ) {
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

Tess_CheckOverflow( 4, 6 );
Expand Down Expand Up @@ -3111,11 +3111,11 @@ const RenderCommand *GradientPicCommand::ExecuteSelf( ) const
}

backEnd.currentEntity = &backEnd.entity2D;
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

if( !tess.indexes ) {
Tess_Begin( Tess_StageIteratorColor, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorColor, shader, false, -1, 0 );
}

Tess_CheckOverflow( 4, 6 );
Expand Down Expand Up @@ -3314,7 +3314,7 @@ const RenderCommand *PreparePortalCommand::ExecuteSelf( ) const
GL_State( GLS_COLORMASK_BITS );
glState.glStateBitsMask = GLS_COLORMASK_BITS;

Tess_Begin( Tess_StageIteratorPortal, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorPortal, shader, false, -1, 0 );
rb_surfaceTable[Util::ordinal(*(surface->surface))](surface->surface );
Tess_End();

Expand All @@ -3329,7 +3329,7 @@ const RenderCommand *PreparePortalCommand::ExecuteSelf( ) const
GL_State( GLS_DEPTHMASK_TRUE | GLS_COLORMASK_BITS | GLS_DEPTHFUNC_ALWAYS);
glState.glStateBitsMask = GLS_DEPTHMASK_TRUE | GLS_COLORMASK_BITS | GLS_DEPTHFUNC_ALWAYS;

Tess_Begin( Tess_StageIteratorPortal, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorPortal, shader, false, -1, 0 );
rb_surfaceTable[Util::ordinal(*(surface->surface))](surface->surface );
Tess_End();

Expand Down Expand Up @@ -3380,7 +3380,7 @@ const RenderCommand *FinalisePortalCommand::ExecuteSelf( ) const
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );

Tess_Begin( Tess_StageIteratorColor, shader,
nullptr, false, surface->lightmapNum(), surface->fog, surface->bspSurface );
false, surface->lightmapNum(), surface->fog, surface->bspSurface );
rb_surfaceTable[Util::ordinal( *( surface->surface ) )]( surface->surface );
Tess_End();

Expand All @@ -3389,7 +3389,7 @@ const RenderCommand *FinalisePortalCommand::ExecuteSelf( ) const
GL_State( GLS_COLORMASK_BITS | GLS_DEPTHFUNC_ALWAYS);
glState.glStateBitsMask = GLS_COLORMASK_BITS | GLS_DEPTHFUNC_ALWAYS;

Tess_Begin( Tess_StageIteratorPortal, shader, nullptr, false, -1, 0 );
Tess_Begin( Tess_StageIteratorPortal, shader, false, -1, 0 );
rb_surfaceTable[Util::ordinal(*(surface->surface))](surface->surface );
Tess_End();

Expand Down
94 changes: 15 additions & 79 deletions src/engine/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2444,9 +2444,9 @@ static void R_CreateFogImage()
R_CreateDefaultImage
==================
*/
static const int DEFAULT_SIZE = 128;
static void R_CreateDefaultImage()
{
constexpr int DEFAULT_SIZE = 128;
int x;
byte data[ DEFAULT_SIZE ][ DEFAULT_SIZE ][ 4 ];
byte *dataPtr = &data[0][0][0];
Expand Down Expand Up @@ -2474,45 +2474,6 @@ static void R_CreateDefaultImage()
tr.defaultImage = R_CreateImage( "_default", ( const byte ** ) &dataPtr, DEFAULT_SIZE, DEFAULT_SIZE, 1, imageParams );
}

static void R_CreateRandomNormalsImage()
{
int x, y;
byte data[ DEFAULT_SIZE ][ DEFAULT_SIZE ][ 4 ];
// the default image will be a box, to allow you to see the mapping coordinates
memset(data, 32, sizeof(data));

byte *ptr = &data[0][0][0];
byte *dataPtr = &data[0][0][0];

for ( y = 0; y < DEFAULT_SIZE; y++ )
{
for ( x = 0; x < DEFAULT_SIZE; x++ )
{
vec3_t n;
float r, angle;

r = random();
angle = 2.0f * M_PI * r; // / 360.0f;

VectorSet( n, cosf( angle ), sinf( angle ), r );
VectorNormalize( n );

ptr[ 0 ] = ( byte )( 128 + 127 * n[ 0 ] );
ptr[ 1 ] = ( byte )( 128 + 127 * n[ 1 ] );
ptr[ 2 ] = ( byte )( 128 + 127 * n[ 2 ] );
ptr[ 3 ] = 255;
ptr += 4;
}
}

imageParams_t imageParams = {};
imageParams.bits = IF_NOPICMIP;
imageParams.filterType = filterType_t::FT_DEFAULT;
imageParams.wrapType = wrapTypeEnum_t::WT_REPEAT;

tr.randomNormalsImage = R_CreateImage( "_randomNormals", ( const byte ** ) &dataPtr, DEFAULT_SIZE, DEFAULT_SIZE, 1, imageParams );
}

static void R_CreateContrastRenderFBOImage()
{
if ( !glConfig2.bloom)
Expand Down Expand Up @@ -2749,12 +2710,11 @@ R_CreateBuiltinImages
*/
void R_CreateBuiltinImages()
{
int x, y;
byte data[ DEFAULT_SIZE ][ DEFAULT_SIZE ][ 4 ];
byte *dataPtr = &data[0][0][0];
constexpr int DIMENSION = 8;
int x;
byte data[ DIMENSION * DIMENSION * 4 ];
byte *dataPtr = data;
byte *out;
float s, value;
byte intensity;

R_CreateDefaultImage();

Expand All @@ -2766,41 +2726,41 @@ void R_CreateBuiltinImages()
imageParams.filterType = filterType_t::FT_LINEAR;
imageParams.wrapType = wrapTypeEnum_t::WT_REPEAT;

tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, 8, 8, 1, imageParams );
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );

// we use a solid black image instead of disabling texturing
memset( data, 0, sizeof( data ) );
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, 8, 8, 1, imageParams );
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );

// red
for ( x = DEFAULT_SIZE * DEFAULT_SIZE, out = &data[0][0][0]; x; --x, out += 4 )
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
{
out[ 1 ] = out[ 2 ] = 0;
out[ 0 ] = out[ 3 ] = 255;
}

tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, 8, 8, 1, imageParams );
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );

// green
for ( x = DEFAULT_SIZE * DEFAULT_SIZE, out = &data[0][0][0]; x; --x, out += 4 )
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
{
out[ 0 ] = out[ 2 ] = 0;
out[ 1 ] = out[ 3 ] = 255;
}

tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, 8, 8, 1, imageParams );
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );

// blue
for ( x = DEFAULT_SIZE * DEFAULT_SIZE, out = &data[0][0][0]; x; --x, out += 4 )
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
{
out[ 0 ] = out[ 1 ] = 0;
out[ 2 ] = out[ 3 ] = 255;
}

tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, 8, 8, 1, imageParams );
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );

// generate a default normalmap with a fully opaque heightmap (no displacement)
for ( x = DEFAULT_SIZE * DEFAULT_SIZE, out = &data[0][0][0]; x; --x, out += 4 )
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
{
out[ 0 ] = out[ 1 ] = 128;
out[ 2 ] = 255;
Expand All @@ -2809,7 +2769,7 @@ void R_CreateBuiltinImages()

imageParams.bits = IF_NOPICMIP | IF_NORMALMAP;

tr.flatImage = R_CreateImage( "_flat", ( const byte ** ) &dataPtr, 8, 8, 1, imageParams );
tr.flatImage = R_CreateImage( "_flat", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );

imageParams.bits = IF_NOPICMIP;
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;
Expand All @@ -2819,30 +2779,6 @@ void R_CreateBuiltinImages()
image = R_CreateImage( "_cinematic", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
}

out = &data[ 0 ][ 0 ][ 0 ];

for ( y = 0; y < DEFAULT_SIZE; y++ )
{
for ( x = 0; x < DEFAULT_SIZE; x++, out += 4 )
{
s = ( ( ( float ) x + 0.5f ) * ( 2.0f / DEFAULT_SIZE ) - 1.0f );

s = Q_fabs( s ) - ( 1.0f / DEFAULT_SIZE );

value = 1.0f - ( s * 2.0f ) + ( s * s );

intensity = ClampByte( Q_ftol( value * 255.0f ) );

out[ 0 ] = intensity;
out[ 1 ] = intensity;
out[ 2 ] = intensity;
out[ 3 ] = intensity;
}
}

tr.quadraticImage = R_CreateImage( "_quadratic", ( const byte ** ) &dataPtr, DEFAULT_SIZE, DEFAULT_SIZE, 1, imageParams );

R_CreateRandomNormalsImage();
R_CreateFogImage();
R_CreateContrastRenderFBOImage();
R_CreateBloomRenderFBOImages();
Expand Down
Loading