summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSmileTheory <SmileTheory@gmail.com>2015-12-08 05:17:05 -0800
committerTim Angus <tim@ngus.net>2016-04-07 11:13:30 +0100
commit3372e9eaf5c21e1e44f000e09a94584231ba9550 (patch)
tree77eac07a6bfdd387a11aa1a72c69d41f7b80bd17 /src
parente8a31f6a628ca309d1c5119d6d52c391e225445d (diff)
OpenGL2: Add option in code for alternate overbright method.
Diffstat (limited to 'src')
-rw-r--r--src/renderergl2/tr_bsp.c10
-rw-r--r--src/renderergl2/tr_image.c4
-rw-r--r--src/renderergl2/tr_local.h1
-rw-r--r--src/renderergl2/tr_scene.c4
-rw-r--r--src/renderergl2/tr_shade.c23
5 files changed, 35 insertions, 7 deletions
diff --git a/src/renderergl2/tr_bsp.c b/src/renderergl2/tr_bsp.c
index beb07fe3..d1508051 100644
--- a/src/renderergl2/tr_bsp.c
+++ b/src/renderergl2/tr_bsp.c
@@ -102,7 +102,11 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) {
int shift, r, g, b;
// shift the color data based on overbright range
+#if defined(USE_OVERBRIGHT)
shift = r_mapOverBrightBits->integer - tr.overbrightBits;
+#else
+ shift = 0;
+#endif
// shift the data based on overbright range
r = in[0] << shift;
@@ -137,7 +141,9 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale )
{
float r, g, b;
+#if defined(USE_OVERBRIGHT)
scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits);
+#endif
r = in[0] * scale;
g = in[1] * scale;
@@ -2756,7 +2762,11 @@ void R_LoadLightGrid( lump_t *l ) {
if (hdrLightGrid)
{
+#if defined(USE_OVERBRIGHT)
float lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits);
+#else
+ float lightScale = 1.0f;
+#endif
//ri.Printf(PRINT_ALL, "found!\n");
diff --git a/src/renderergl2/tr_image.c b/src/renderergl2/tr_image.c
index ef244d56..541b1a38 100644
--- a/src/renderergl2/tr_image.c
+++ b/src/renderergl2/tr_image.c
@@ -2856,7 +2856,11 @@ void R_SetColorMappings( void ) {
int inf;
// setup the overbright lighting
+#if defined(USE_OVERBRIGHT)
tr.overbrightBits = r_overBrightBits->integer;
+#else
+ tr.overbrightBits = 0;
+#endif
// allow 2 overbright bits
if ( tr.overbrightBits > 2 ) {
diff --git a/src/renderergl2/tr_local.h b/src/renderergl2/tr_local.h
index 02d0887e..a38cf7fc 100644
--- a/src/renderergl2/tr_local.h
+++ b/src/renderergl2/tr_local.h
@@ -59,6 +59,7 @@ typedef unsigned int glIndex_t;
#define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS)
#define USE_VERT_TANGENT_SPACE
+#define USE_OVERBRIGHT
typedef struct dlight_s {
vec3_t origin;
diff --git a/src/renderergl2/tr_scene.c b/src/renderergl2/tr_scene.c
index 51bb412e..94997a8c 100644
--- a/src/renderergl2/tr_scene.c
+++ b/src/renderergl2/tr_scene.c
@@ -350,7 +350,11 @@ void RE_BeginScene(const refdef_t *fd)
}
else
{
+#if defined(USE_OVERBRIGHT)
float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8);
+#else
+ float scale = (1 << r_mapOverBrightBits->integer) / 255.0f;
+#endif
if (r_forceSun->integer)
{
VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol);
diff --git a/src/renderergl2/tr_shade.c b/src/renderergl2/tr_shade.c
index 9853313c..e7a73842 100644
--- a/src/renderergl2/tr_shade.c
+++ b/src/renderergl2/tr_shade.c
@@ -445,9 +445,22 @@ static void ProjectDlightTexture( void ) {
static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend )
{
+ qboolean isBlend = ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR)
+ || ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR)
+ || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
+ || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
+
+ qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL);
+
+#if defined(USE_OVERBRIGHT)
+ float exactLight = 1.0f;
+#else
+ float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << r_mapOverBrightBits->integer);
+#endif
+
baseColor[0] =
baseColor[1] =
- baseColor[2] =
+ baseColor[2] = exactLight;
baseColor[3] = 1.0f;
vertColor[0] =
@@ -474,7 +487,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t
vertColor[0] =
vertColor[1] =
- vertColor[2] =
+ vertColor[2] = exactLight;
vertColor[3] = 1.0f;
break;
case CGEN_CONST:
@@ -602,11 +615,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t
}
// multiply color by overbrightbits if this isn't a blend
- if (tr.overbrightBits
- && !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR)
- && !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR)
- && !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
- && !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR))
+ if (tr.overbrightBits && !isBlend)
{
float scale = 1 << tr.overbrightBits;