Skip to content

Commit

Permalink
renderergl2: Implement Xembie's minimum lightmap patch for making ver…
Browse files Browse the repository at this point in the history
…y dark maps more visible.
  • Loading branch information
dGr8LookinSparky authored and wtfbbqhax committed Mar 7, 2018
1 parent b604102 commit 2addd40
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/renderergl2/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,18 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) {
r = in[0] << shift;
g = in[1] << shift;
b = in[2] << shift;


// Minimum values
if(r < r_mapLightmapMin->integer){
r = r_mapLightmapMin->integer;
}
if(g < r_mapLightmapMin->integer){
g = r_mapLightmapMin->integer;
}
if(b < r_mapLightmapMin->integer){
b = r_mapLightmapMin->integer;
}

// normalize by color instead of saturating to white
if ( ( r | g | b ) > 255 ) {
int max;
Expand Down Expand Up @@ -147,6 +158,17 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4])
g = in[1] * scale;
b = in[2] * scale;

// Minimum values
if(r < r_mapLightmapMin->value / 255.0f){
r = r_mapLightmapMin->value / 255.0f;
}
if(g < r_mapLightmapMin->value / 255.0f){
g = r_mapLightmapMin->value / 255.0f;
}
if(b < r_mapLightmapMin->value / 255.0f){
b = r_mapLightmapMin->value / 255.0f;
}

// normalize by color instead of saturating to white
if ( r > 1 || g > 1 || b > 1 ) {
float max;
Expand Down
5 changes: 4 additions & 1 deletion src/renderergl2/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ cvar_t *r_pixelAspect;
cvar_t *r_overBrightBits;
cvar_t *r_mapOverBrightBits;

cvar_t *r_mapLightmapMin;

cvar_t *r_debugSurface;
cvar_t *r_simpleMipMaps;

Expand Down Expand Up @@ -1181,7 +1183,8 @@ void R_Register( void )
//
r_fullbright = ri.Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT );
r_mapOverBrightBits = ri.Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH );
r_intensity = ri.Cvar_Get ("r_intensity", "1", CVAR_LATCH );
r_mapLightmapMin = ri.Cvar_Get ("r_mapLightmapMin", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_intensity = ri.Cvar_Get ("r_intensity", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_singleShader = ri.Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH );

//
Expand Down
2 changes: 2 additions & 0 deletions src/renderergl2/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,8 @@ extern cvar_t *r_ignoreGLErrors;
extern cvar_t *r_overBrightBits;
extern cvar_t *r_mapOverBrightBits;

extern cvar_t *r_mapLightmapMin;

extern cvar_t *r_debugSurface;
extern cvar_t *r_simpleMipMaps;

Expand Down

0 comments on commit 2addd40

Please sign in to comment.