diff options
author | SmileTheory <SmileTheory@gmail.com> | 2016-04-05 02:21:14 -0700 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2016-04-07 11:54:15 +0100 |
commit | 137f8bc53e9895826548d0f398d6faaa36215bb5 (patch) | |
tree | 8fc3cffa22feff74f5ce485d300b6782d40d0393 /src/renderergl2/tr_shade.c | |
parent | 9ebb714235e29db5c0b1b501eaff31a6be85c569 (diff) |
OpenGL2: Render metals as nonmetal on cubemaps, and some ComputeShaderColors cleanup.
Diffstat (limited to 'src/renderergl2/tr_shade.c')
-rw-r--r-- | src/renderergl2/tr_shade.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/renderergl2/tr_shade.c b/src/renderergl2/tr_shade.c index 885e2718..2578420c 100644 --- a/src/renderergl2/tr_shade.c +++ b/src/renderergl2/tr_shade.c @@ -447,11 +447,12 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t || ((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); + float scale = 1.0f; #if defined(USE_OVERBRIGHT) float exactLight = 1.0f; #else - qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL); float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << r_mapOverBrightBits->integer); #endif @@ -611,17 +612,16 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t break; } - // multiply color by overbrightbits if this isn't a blend if (tr.overbrightBits && !isBlend) + scale *= 1 << tr.overbrightBits; + + if ((backEnd.refdef.colorScale != 1.0f) && !isBlend && isWorldDraw) + scale *= backEnd.refdef.colorScale; + + if (scale != 1.0f) { - float scale = 1 << tr.overbrightBits; - - baseColor[0] *= scale; - baseColor[1] *= scale; - baseColor[2] *= scale; - vertColor[0] *= scale; - vertColor[1] *= scale; - vertColor[2] *= scale; + VectorScale(baseColor, scale, baseColor); + VectorScale(vertColor, scale, vertColor); } // FIXME: find some way to implement this. @@ -1072,6 +1072,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) int deformGen; vec5_t deformParams; + qboolean renderToCubemap = tr.renderCubeFbo && glState.currentFBO == tr.renderCubeFbo; + ComputeDeformValues(&deformGen, deformParams); ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); @@ -1187,13 +1189,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) ComputeShaderColors(pStage, baseColor, vertColor, pStage->stateBits); - if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) - { - // use VectorScale to only scale first three values, not alpha - VectorScale(baseColor, backEnd.refdef.colorScale, baseColor); - VectorScale(vertColor, backEnd.refdef.colorScale, vertColor); - } - GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); } @@ -1264,7 +1259,20 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); - GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); + + { + vec4_t specularScale; + Vector4Copy(pStage->specularScale, specularScale); + + if (renderToCubemap) + { + // force specular to nonmetal if rendering cubemaps + if (r_pbr->integer) + specularScale[1] = 0.0f; + } + + GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); + } //GLSL_SetUniformFloat(sp, UNIFORM_MAPLIGHTSCALE, backEnd.refdef.mapLightScale); |