From bd25d4423bb0e4989a31405a0cb20683d16615ba Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 17 Oct 2007 21:16:23 +0000 Subject: [PATCH] do contrastboost before reflection; move fog behind contrastboost (consistent with skybox) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7645 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index cfeea649..f7869707 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -824,6 +824,12 @@ static const char *builtinshaderstring = " color.rgb += myhvec3(texture2D(Texture_Glow, TexCoord)) * GlowScale;\n" "#endif\n" "\n" +"#ifdef USECONTRASTBOOST\n" +" color.rgb = color.rgb / (ContrastBoostCoeff * color.rgb + myhvec3(1, 1, 1));\n" +"#endif\n" +"\n" +" color.rgb *= SceneBrightness;\n" +"\n" "#ifndef MODE_LIGHTSOURCE\n" "# ifdef USEREFLECTION\n" " vec4 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect * (1.0 / ModelViewProjectionPosition.w);\n" @@ -838,12 +844,6 @@ static const char *builtinshaderstring = " color.rgb = mix(FogColor, color.rgb, myhalf(texture2D(Texture_FogMask, myhvec2(length(EyeVectorModelSpace)*FogRangeRecip, 0.0))));\n" "#endif\n" "\n" -"#ifdef USECONTRASTBOOST\n" -" color.rgb = color.rgb / (ContrastBoostCoeff * color.rgb + myhvec3(1, 1, 1));\n" -"#endif\n" -"\n" -" color.rgb *= SceneBrightness;\n" -"\n" " gl_FragColor = vec4(color);\n" "}\n" "#endif // MODE_REFRACTION\n" @@ -1350,7 +1350,7 @@ int R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting, fl // color.rgb *= [[SceneBrightness * ContrastBoost]]; // color.rgb /= [[(ContrastBoost - 1) / ContrastBoost]] * color.rgb + 1; // and Black: - // color.rgb = [[SceneBrightness * ContrastBoost]] / ([[(ContrastBoost - 1) * SceneBrightness]] + 1 / color.rgb); + // color.rgb = [[SceneBrightness * ContrastBoost]] * color.rgb / ([[(ContrastBoost - 1) * SceneBrightness]] * color.rgb + 1); // and do [[calculations]] here in the engine qglUniform1fARB(r_glsl_permutation->loc_ContrastBoostCoeff, (r_glsl_contrastboost.value - 1) * r_view.colorscale); if (r_glsl_permutation->loc_SceneBrightness >= 0) qglUniform1fARB(r_glsl_permutation->loc_SceneBrightness, r_view.colorscale * r_glsl_contrastboost.value); @@ -1363,6 +1363,21 @@ int R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting, fl if (rsurface.rtlight || (rsurface.texture->currentmaterialflags & MATERIALFLAG_ADD)) qglUniform3fARB(r_glsl_permutation->loc_FogColor, 0, 0, 0); else + /* + { + vec3_t fogvec; + // color.rgb *= SceneBrightness; + VectorScale(r_refdef.fogcolor, r_view.colorscale, fogvec); + if(r_glsl_permutation->loc_ContrastBoostCoeff >= 0) // need to support contrast boost + { + // color.rgb *= ContrastBoost / ((ContrastBoost - 1) * color.rgb + 1); + fogvec[0] *= r_glsl_contrastboost.value / ((r_glsl_contrastboost.value - 1) * fogvec[0] + 1); + fogvec[1] *= r_glsl_contrastboost.value / ((r_glsl_contrastboost.value - 1) * fogvec[1] + 1); + fogvec[2] *= r_glsl_contrastboost.value / ((r_glsl_contrastboost.value - 1) * fogvec[2] + 1); + } + qglUniform3fARB(r_glsl_permutation->loc_FogColor, fogvec[0], fogvec[1], fogvec[2]); + } + */ qglUniform3fARB(r_glsl_permutation->loc_FogColor, r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2]); } if (r_glsl_permutation->loc_EyePosition >= 0) qglUniform3fARB(r_glsl_permutation->loc_EyePosition, rsurface.modelorg[0], rsurface.modelorg[1], rsurface.modelorg[2]); -- 2.39.2