diff options
author | SmileTheory <SmileTheory@gmail.com> | 2013-11-05 00:08:59 -0800 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-06-17 17:43:35 +0100 |
commit | 21b6ec9a3aa8e97d12cf543c5f3c5298e6a87601 (patch) | |
tree | 8edb38c617d78ba86d081fec0bb92172be257e6e /src/renderergl2/tr_shade.c | |
parent | 6fc4c57dfe77e5768c71ac4a4a482562f424336a (diff) |
OpenGL2: Reimplement soft overbright to avoid a framebuffer blit.
Diffstat (limited to 'src/renderergl2/tr_shade.c')
-rw-r--r-- | src/renderergl2/tr_shade.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/renderergl2/tr_shade.c b/src/renderergl2/tr_shade.c index d6837b2a..a23ae119 100644 --- a/src/renderergl2/tr_shade.c +++ b/src/renderergl2/tr_shade.c @@ -444,7 +444,7 @@ static void ProjectDlightTexture( void ) { } -static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor ) +static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend ) { baseColor[0] = baseColor[1] = @@ -602,6 +602,23 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t break; } + // multiply color by overbrightbits if this isn't a blend + if (r_softOverbright->integer && 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)) + { + float scale = 1 << tr.overbrightBits; + + baseColor[0] *= scale; + baseColor[1] *= scale; + baseColor[2] *= scale; + vertColor[0] *= scale; + vertColor[1] *= scale; + vertColor[2] *= scale; + } + // FIXME: find some way to implement this. #if 0 // if in greyscale rendering mode turn all color values into greyscale. @@ -770,7 +787,7 @@ static void ForwardDlight( void ) { vec4_t baseColor; vec4_t vertColor; - ComputeShaderColors(pStage, baseColor, vertColor); + ComputeShaderColors(pStage, baseColor, vertColor, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); @@ -1142,7 +1159,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) vec4_t baseColor; vec4_t vertColor; - ComputeShaderColors(pStage, baseColor, vertColor); + ComputeShaderColors(pStage, baseColor, vertColor, pStage->stateBits); if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) { |