Skip to content

Commit 67040a6

Browse files
committed
Fix sky brushes not being skipped for rendererSurfaces
1 parent 43daba3 commit 67040a6

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

src/engine/renderer/GeometryOptimiser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,10 @@ std::vector<MaterialSurface> OptimiseMapGeometryMaterial(bspSurface_t** renderer
377377
MaterialSurface srf {};
378378

379379
srf.shader = surface->shader;
380+
380381
srf.bspSurface = true;
382+
srf.skyBrush = surface->skyBrush;
383+
381384
srf.lightMapNum = surface->lightmapNum;
382385
srf.fog = surface->fogIndex;
383386
srf.portalNum = surface->portalNum;

src/engine/renderer/Material.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,10 @@ void MaterialSystem::GenerateWorldCommandBuffer( std::vector<MaterialSurface>& s
638638
}
639639

640640
for ( MaterialSurface& surface : surfaces ) {
641+
if ( surface.skyBrush ) {
642+
continue;
643+
}
644+
641645
SurfaceDescriptor surfaceDescriptor;
642646
VectorCopy( surface.origin, surfaceDescriptor.boundingSphere.origin );
643647
surfaceDescriptor.boundingSphere.radius = surface.radius;
@@ -1328,6 +1332,10 @@ void MaterialSystem::GenerateMaterial( MaterialSurface* surface ) {
13281332

13291333
uint32_t stage = 0;
13301334
uint32_t previousMaterialID = 0;
1335+
1336+
if ( surface->skyBrush ) {
1337+
return;
1338+
}
13311339

13321340
if ( surface->shader->depthShader ) {
13331341
uint32_t unused;

src/engine/renderer/Material.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ struct DrawCommand {
7777
struct MaterialSurface {
7878
shader_t* shader;
7979
surfaceType_t* surface;
80+
8081
bool bspSurface;
82+
bool skyBrush;
83+
8184
int16_t lightMapNum;
8285
int fog;
8386
int portalNum = -1;

src/engine/renderer/tr_bsp.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,7 +2538,7 @@ static void R_CreateWorldVBO() {
25382538
// HACK: portals: don't use VBO because when adding a portal we have to read back the verts CPU-side
25392539
// Autosprite: don't use VBO because verts are rewritten each time based on view origin
25402540
if ( surface->shader->isPortal || surface->shader->autoSpriteMode != 0 ) {
2541-
if( glConfig2.usingMaterialSystem && surface->shader->autoSpriteMode ) {
2541+
if( glConfig2.usingMaterialSystem ) {
25422542
materialSystem.autospriteSurfaces.push_back( surface );
25432543
}
25442544

@@ -2548,10 +2548,15 @@ static void R_CreateWorldVBO() {
25482548
continue;
25492549
}
25502550

2551-
if ( glConfig2.usingMaterialSystem && surface->shader->isSky
2552-
&& std::find( materialSystem.skyShaders.begin(), materialSystem.skyShaders.end(), surface->shader )
2553-
== materialSystem.skyShaders.end() ) {
2554-
materialSystem.skyShaders.emplace_back( surface->shader );
2551+
if ( glConfig2.usingMaterialSystem && surface->shader->isSky ) {
2552+
if ( std::find( materialSystem.skyShaders.begin(), materialSystem.skyShaders.end(), surface->shader )
2553+
== materialSystem.skyShaders.end() ) {
2554+
materialSystem.skyShaders.emplace_back( surface->shader );
2555+
}
2556+
2557+
/* Sky brushes are currently not used by the material system,
2558+
but they still have to go into the VBO for the core renderer */
2559+
surface->skyBrush = true;
25552560
}
25562561

25572562
if ( *surface->data == surfaceType_t::SF_FACE || *surface->data == surfaceType_t::SF_GRID

src/engine/renderer/tr_local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,7 @@ enum class ssaoMode {
18301830

18311831
bool renderable = false;
18321832
bool BSPModel = false;
1833+
bool skyBrush = false;
18331834

18341835
surfaceType_t *data; // any of srf*_t
18351836
};

0 commit comments

Comments
 (0)