[iortcw] 08/497: All: Rend2: Fix non-HDR map surface over brighting
Simon McVittie
smcv at debian.org
Fri Sep 8 10:35:59 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to annotated tag 1.42d
in repository iortcw.
commit 5eeab8da3ad8a31c58566268bf7db4d48d0b155a
Author: M4N4T4RMS at gmail.com <M4N4T4RMS at gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date: Thu Jan 16 11:30:15 2014 +0000
All: Rend2: Fix non-HDR map surface over brighting
---
MP/code/rend2/tr_bsp.c | 25 +++++++++++++++++++++----
SP/code/rend2/tr_bsp.c | 25 +++++++++++++++++++++----
2 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/MP/code/rend2/tr_bsp.c b/MP/code/rend2/tr_bsp.c
index af03baa..01b0584 100644
--- a/MP/code/rend2/tr_bsp.c
+++ b/MP/code/rend2/tr_bsp.c
@@ -133,17 +133,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];
}
diff --git a/SP/code/rend2/tr_bsp.c b/SP/code/rend2/tr_bsp.c
index 6ee51f0..15edfa6 100644
--- a/SP/code/rend2/tr_bsp.c
+++ b/SP/code/rend2/tr_bsp.c
@@ -133,17 +133,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];
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git
More information about the Pkg-games-commits
mailing list