Skip to content

Commit 3fb871d

Browse files
committed
Merge remote-tracking branch 'lilium-arena/master'
2 parents 13e8034 + b378fe5 commit 3fb871d

6 files changed

Lines changed: 126 additions & 20 deletions

File tree

code/renderergl2/tr_backend.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,16 @@ const void *RB_PostProcess(const void *data)
18091809
// Use an intermediate FBO because it can't blit to the same FBO directly
18101810
// and can't read from an MSAA dstFbo later.
18111811
RB_ToneMap(srcFbo, srcBox, tr.screenScratchFbo, srcBox, autoExposure);
1812-
FBO_FastBlit(tr.screenScratchFbo, srcBox, srcFbo, srcBox, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1812+
1813+
if (r_anaglyphMode->integer)
1814+
{
1815+
// glBlitFramebuffer() in FBO_FastBlit() doesn't respect glColorMask()
1816+
FBO_Blit(tr.screenScratchFbo, srcBox, NULL, srcFbo, srcBox, NULL, NULL, 0);
1817+
}
1818+
else
1819+
{
1820+
FBO_FastBlit(tr.screenScratchFbo, srcBox, srcFbo, srcBox, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1821+
}
18131822
}
18141823
else if (r_cameraExposure->value != 0.0f)
18151824
{

code/renderergl2/tr_bsp.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ static void R_ColorShiftLightingBytes( int inSize, byte in[4], byte out[4] ) {
143143
b = b * 255 / max;
144144
}
145145

146+
if(r_greyscale->integer)
147+
{
148+
int scale = LUMA(r, g, b);
149+
r = g = b = scale;
150+
}
151+
else if(r_greyscale->value)
152+
{
153+
float scale = LUMA(r, g, b);
154+
r = LERP(r, scale, r_greyscale->value);
155+
g = LERP(g, scale, r_greyscale->value);
156+
b = LERP(b, scale, r_greyscale->value);
157+
}
158+
146159
out[0] = r;
147160
out[1] = g;
148161
out[2] = b;
@@ -180,6 +193,19 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4])
180193
b = b / max;
181194
}
182195

196+
if(r_greyscale->integer)
197+
{
198+
scale = LUMA(r, g, b);
199+
r = g = b = scale;
200+
}
201+
else if(r_greyscale->value)
202+
{
203+
scale = LUMA(r, g, b);
204+
r = LERP(r, scale, r_greyscale->value);
205+
g = LERP(g, scale, r_greyscale->value);
206+
b = LERP(b, scale, r_greyscale->value);
207+
}
208+
183209
out[0] = r;
184210
out[1] = g;
185211
out[2] = b;

code/renderergl2/tr_scene.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,23 @@ void RE_AddDynamicLightToScene( const vec3_t org, float radius, float intensity,
467467
} else {
468468
dl->dlshader = NULL;
469469
}
470+
471+
if(r_greyscale->integer)
472+
{
473+
float scale;
474+
475+
scale = LUMA(dl->color[0], dl->color[1], dl->color[2]);
476+
dl->color[0] = dl->color[1] = dl->color[2] = scale;
477+
}
478+
else if(r_greyscale->value)
479+
{
480+
float scale;
481+
482+
scale = LUMA(dl->color[0], dl->color[1], dl->color[2]);
483+
dl->color[0] = LERP(dl->color[0], scale, r_greyscale->value);
484+
dl->color[1] = LERP(dl->color[1], scale, r_greyscale->value);
485+
dl->color[2] = LERP(dl->color[2], scale, r_greyscale->value);
486+
}
470487
}
471488

472489
/*

code/renderergl2/tr_shade.c

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -758,20 +758,27 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t
758758
break;
759759
}
760760

761-
// FIXME: find some way to implement this.
762-
#if 0
763-
// if in greyscale rendering mode turn all color values into greyscale.
764-
if(r_greyscale->integer)
761+
if (pStage->rgbGen == CGEN_CONST || pStage->rgbGen == CGEN_FOG
762+
|| pStage->rgbGen == CGEN_ENTITY || pStage->rgbGen == CGEN_ONE_MINUS_ENTITY)
765763
{
766-
int scale;
767-
768-
for(i = 0; i < tess.numVertexes; i++)
764+
// if in greyscale rendering mode turn all color values into greyscale.
765+
if(r_greyscale->integer)
769766
{
770-
scale = (tess.svars.colors[i][0] + tess.svars.colors[i][1] + tess.svars.colors[i][2]) / 3;
771-
tess.svars.colors[i][0] = tess.svars.colors[i][1] = tess.svars.colors[i][2] = scale;
767+
float scale;
768+
769+
scale = LUMA(baseColor[0], baseColor[1], baseColor[2]);
770+
baseColor[0] = baseColor[1] = baseColor[2] = scale;
771+
}
772+
else if(r_greyscale->value)
773+
{
774+
float scale;
775+
776+
scale = LUMA(baseColor[0], baseColor[1], baseColor[2]);
777+
baseColor[0] = LERP(baseColor[0], scale, r_greyscale->value);
778+
baseColor[1] = LERP(baseColor[1], scale, r_greyscale->value);
779+
baseColor[2] = LERP(baseColor[2], scale, r_greyscale->value);
772780
}
773781
}
774-
#endif
775782
}
776783

777784

@@ -2008,6 +2015,36 @@ void RB_StageIteratorGeneric( void )
20082015

20092016
if (tess.useInternalVao)
20102017
{
2018+
if (vertexAttribs & ATTR_COLOR)
2019+
{
2020+
// if in greyscale rendering mode turn all color values into greyscale.
2021+
if(r_greyscale->integer)
2022+
{
2023+
uint16_t *color = tess.color[0];
2024+
int i;
2025+
int scale;
2026+
for(i = 0; i < tess.numVertexes; i++, color += 4)
2027+
{
2028+
scale = LUMA(color[0], color[1], color[2]);
2029+
color[0] = color[1] = color[2] = scale;
2030+
}
2031+
}
2032+
else if(r_greyscale->value)
2033+
{
2034+
uint16_t *color = tess.color[0];
2035+
int i;
2036+
float scale;
2037+
2038+
for(i = 0; i < tess.numVertexes; i++, color += 4)
2039+
{
2040+
scale = LUMA(color[0], color[1], color[2]);
2041+
color[0] = LERP(color[0], scale, r_greyscale->value);
2042+
color[1] = LERP(color[1], scale, r_greyscale->value);
2043+
color[2] = LERP(color[2], scale, r_greyscale->value);
2044+
}
2045+
}
2046+
}
2047+
20112048
RB_UpdateTessVao(vertexAttribs);
20122049
}
20132050
else

code/server/sv_main.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,12 +1190,6 @@ void SV_Frame( int msec ) {
11901190
Cbuf_AddText( va( "map %s\n", Cvar_VariableString( "mapname" ) ) );
11911191
return;
11921192
}
1193-
// this can happen considerably earlier when lots of clients play and the map doesn't change
1194-
if ( svs.nextSnapshotEntities >= 0x7FFFFFFE - svs.numSnapshotEntities ) {
1195-
SV_Shutdown( "Restarting server due to numSnapshotEntities wrapping" );
1196-
Cbuf_AddText( va( "map %s\n", Cvar_VariableString( "mapname" ) ) );
1197-
return;
1198-
}
11991193

12001194
if( sv.restartTime && sv.time >= sv.restartTime ) {
12011195
Cbuf_AddText( "map_restart\n" );

code/server/sv_snapshot.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,14 +594,15 @@ currently doesn't.
594594
*/
595595
static void SV_BuildClientSnapshot( client_t *client ) {
596596
vec3_t org;
597-
clientSnapshot_t *frame;
597+
clientSnapshot_t *frame, *oldframe;
598598
snapshotEntityNumbers_t entityNumbers;
599-
int i;
599+
int i, j;
600600
int psIndex;
601601
sharedEntityState_t *state;
602602
svEntity_t *svEnt;
603603
int playerNum;
604604
sharedPlayerState_t *ps;
605+
int offset;
605606

606607
// bump the counter used to prevent double adding
607608
sv.snapshotCounter++;
@@ -686,14 +687,36 @@ static void SV_BuildClientSnapshot( client_t *client ) {
686687
}
687688
}
688689

690+
// avoid wrapping snapshot entities index to negative while keeping the same modulo value
691+
// and lower existing first_entity for detecting rolling off the buffer
692+
if ( svs.nextSnapshotEntities >= 0x7FFFFFFE - entityNumbers.numSnapshotEntities ) {
693+
Com_DPrintf( "Updating snapshot entities to avoid numSnapshotEntities wrapping.\n" );
694+
695+
offset = ( ( svs.nextSnapshotEntities / svs.numSnapshotEntities ) - 2 ) * svs.numSnapshotEntities;
696+
697+
for ( i = 0; i < sv_maxclients->integer; i++ ) {
698+
oldframe = svs.clients[i].frames;
699+
700+
for ( j = 0; j < PACKET_BACKUP; j++, oldframe++ ) {
701+
if ( oldframe->first_entity <= svs.nextSnapshotEntities - svs.numSnapshotEntities ) {
702+
oldframe->first_entity %= svs.numSnapshotEntities;
703+
} else {
704+
oldframe->first_entity -= offset;
705+
}
706+
}
707+
}
708+
709+
svs.nextSnapshotEntities -= offset;
710+
}
711+
689712
// copy the entity states out
690713
frame->num_entities = 0;
691714
frame->first_entity = svs.nextSnapshotEntities;
692715
for ( i = 0 ; i < entityNumbers.numSnapshotEntities ; i++ ) {
693716
state = SV_GameEntityStateNum( entityNumbers.snapshotEntities[i] );
694717
DA_SetElement( &svs.snapshotEntities, svs.nextSnapshotEntities % svs.numSnapshotEntities, state );
695718
svs.nextSnapshotEntities++;
696-
// this should never hit, map should always be restarted first in SV_Frame
719+
// this should never hit
697720
if ( svs.nextSnapshotEntities >= 0x7FFFFFFE ) {
698721
Com_Error(ERR_FATAL, "svs.nextSnapshotEntities wrapped");
699722
}

0 commit comments

Comments
 (0)