Skip to content

Commit 0443aa6

Browse files
committed
Material system: don't draw global fog twice
3cd5d86 did this for the core renderer.
1 parent ed4ffa8 commit 0443aa6

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/engine/renderer/GeometryOptimiser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ std::vector<MaterialSurface> OptimiseMapGeometryMaterial( world_t* world, bspSur
570570
VectorCopy( ( ( srfGeneric_t* ) surface->data )->origin, srf.origin );
571571
srf.radius = ( ( srfGeneric_t* ) surface->data )->radius;
572572

573-
materialSystem.GenerateMaterial( &srf );
573+
materialSystem.GenerateMaterial( &srf, world->globalFog );
574574

575575
static const float MAX_NORMAL_SURFACE_DISTANCE = 65536.0f * sqrtf( 2.0f );
576576
if ( VectorLength( ( ( srfGeneric_t* ) surface->data )->bounds[0] ) > MAX_NORMAL_SURFACE_DISTANCE

src/engine/renderer/Material.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ void MaterialSystem::ProcessStage( MaterialSurface* surface, shaderStage_t* pSta
14871487
/* This will only generate a material itself
14881488
A material represents a distinct global OpenGL state (e. g. blend function, depth test, depth write etc.)
14891489
Materials can have a dependency on other materials to make sure that consecutive stages are rendered in the proper order */
1490-
void MaterialSystem::GenerateMaterial( MaterialSurface* surface ) {
1490+
void MaterialSystem::GenerateMaterial( MaterialSurface* surface, int globalFog ) {
14911491
uint32_t stage = 0;
14921492
uint32_t previousMaterialID = 0;
14931493

@@ -1508,7 +1508,7 @@ void MaterialSystem::GenerateMaterial( MaterialSurface* surface ) {
15081508
surface->stages++;
15091509
}
15101510

1511-
if ( !surface->shader->noFog && surface->fog >= 1 ) {
1511+
if ( !surface->shader->noFog && surface->fog >= 1 && surface->fog != globalFog ) {
15121512
uint32_t unused;
15131513
ProcessStage( surface, surface->shader->fogShader->stages, surface->shader->fogShader, packIDs, stage, unused, true );
15141514

src/engine/renderer/Material.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class MaterialSystem {
379379
const bool mayUseVertexOverbright, const bool vertexLit, const bool fullbright );
380380
void ProcessStage( MaterialSurface* surface, shaderStage_t* pStage, shader_t* shader, uint32_t* packIDs, uint32_t& stage,
381381
uint32_t& previousMaterialID, bool skipStageSync = false );
382-
void GenerateMaterial( MaterialSurface* surface );
382+
void GenerateMaterial( MaterialSurface* surface, int globalFog );
383383
void GenerateWorldMaterialsBuffer();
384384
void GenerateWorldCommandBuffer( std::vector<MaterialSurface>& surfaces );
385385
void GeneratePortalBoundingSpheres();

0 commit comments

Comments
 (0)