summaryrefslogtreecommitdiff
path: root/src/renderergl2/tr_bsp.c
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2014-01-15 23:53:00 -0600
committerTim Angus <tim@ngus.net>2014-06-17 17:43:38 +0100
commitdf5c010871b2b98a04bb31d0bcd880c4f6b1e302 (patch)
tree88708ccedc45af5e6cda08c63394a596aba250f9 /src/renderergl2/tr_bsp.c
parent6a1b3a45aad98408c9e93fd98654db754f33ce1c (diff)
Fix OpenGL2 non-HDR map surface over brighting
Vertex lit map surfaces were saturating to white when r_mapOverBrightBits was increased and r_hdr was disabled. Now the color is normalized like lightmaps and lightgrid when r_hdr is disabled. Which is the same as OpenGL1. Noticeable on misc_model trisoup.
Diffstat (limited to 'src/renderergl2/tr_bsp.c')
-rw-r--r--src/renderergl2/tr_bsp.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/renderergl2/tr_bsp.c b/src/renderergl2/tr_bsp.c
index fcced63d..42478035 100644
--- a/src/renderergl2/tr_bsp.c
+++ b/src/renderergl2/tr_bsp.c
@@ -129,17 +129,34 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) {
/*
===============
-R_ColorShiftLightingBytes
+R_ColorShiftLightingFloats
===============
*/
static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale )
{
+ float r, g, b;
+
scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits);
- out[0] = in[0] * scale;
- out[1] = in[1] * scale;
- out[2] = in[2] * scale;
+ r = in[0] * scale;
+ g = in[1] * scale;
+ b = in[2] * scale;
+
+ // normalize by color instead of saturating to white
+ if ( !r_hdr->integer && ( r > 1 || g > 1 || b > 1 ) ) {
+ float max;
+
+ max = r > g ? r : g;
+ max = max > b ? max : b;
+ r = r / max;
+ g = g / max;
+ b = b / max;
+ }
+
+ out[0] = r;
+ out[1] = g;
+ out[2] = b;
out[3] = in[3];
}