+ // fog color
+ if (r_refdef.fog_density)
+ {
+ r_refdef.fogcolor[0] = r_refdef.fog_red;
+ r_refdef.fogcolor[1] = r_refdef.fog_green;
+ r_refdef.fogcolor[2] = r_refdef.fog_blue;
+
+ Vector4Set(r_refdef.fogplane, 0, 0, 1, -r_refdef.fog_height);
+ r_refdef.fogplaneviewdist = DotProduct(r_refdef.fogplane, r_refdef.view.origin) + r_refdef.fogplane[3];
+ r_refdef.fogplaneviewabove = r_refdef.fogplaneviewdist >= 0;
+ r_refdef.fogheightfade = -0.5f/max(0.125f, r_refdef.fog_fadedepth);
+
+ {
+ vec3_t fogvec;
+ VectorCopy(r_refdef.fogcolor, fogvec);
+ // color.rgb *= ContrastBoost * SceneBrightness;
+ VectorScale(fogvec, r_refdef.view.colorscale, fogvec);
+ r_refdef.fogcolor[0] = bound(0.0f, fogvec[0], 1.0f);
+ r_refdef.fogcolor[1] = bound(0.0f, fogvec[1], 1.0f);
+ r_refdef.fogcolor[2] = bound(0.0f, fogvec[2], 1.0f);
+ }
+ }
+}
+
+void R_UpdateVariables(void)
+{
+ R_Textures_Frame();
+
+ r_refdef.scene.ambient = r_ambient.value * (1.0f / 64.0f);
+
+ r_refdef.farclip = r_farclip_base.value;
+ if (r_refdef.scene.worldmodel)
+ r_refdef.farclip += r_refdef.scene.worldmodel->radius * r_farclip_world.value * 2;
+ r_refdef.nearclip = bound (0.001f, r_nearclip.value, r_refdef.farclip - 1.0f);
+
+ if (r_shadow_frontsidecasting.integer < 0 || r_shadow_frontsidecasting.integer > 1)
+ Cvar_SetValueQuick(&r_shadow_frontsidecasting, 1);
+ r_refdef.polygonfactor = 0;
+ r_refdef.polygonoffset = 0;
+ r_refdef.shadowpolygonfactor = r_refdef.polygonfactor + r_shadow_polygonfactor.value * (r_shadow_frontsidecasting.integer ? 1 : -1);
+ r_refdef.shadowpolygonoffset = r_refdef.polygonoffset + r_shadow_polygonoffset.value * (r_shadow_frontsidecasting.integer ? 1 : -1);
+
+ r_refdef.scene.rtworld = r_shadow_realtime_world.integer != 0;
+ r_refdef.scene.rtworldshadows = r_shadow_realtime_world_shadows.integer && vid.stencil;
+ r_refdef.scene.rtdlight = r_shadow_realtime_dlight.integer != 0 && !gl_flashblend.integer && r_dynamic.integer;
+ r_refdef.scene.rtdlightshadows = r_refdef.scene.rtdlight && r_shadow_realtime_dlight_shadows.integer && vid.stencil;
+ r_refdef.lightmapintensity = r_refdef.scene.rtworld ? r_shadow_realtime_world_lightmaps.value : 1;
+ if (FAKELIGHT_ENABLED)
+ {
+ r_refdef.lightmapintensity *= r_fakelight_intensity.value;
+ }
+ else if (r_refdef.scene.worldmodel)
+ {
+ r_refdef.lightmapintensity *= r_refdef.scene.worldmodel->lightmapscale;
+ }
+ if (r_showsurfaces.integer)
+ {
+ r_refdef.scene.rtworld = false;
+ r_refdef.scene.rtworldshadows = false;
+ r_refdef.scene.rtdlight = false;
+ r_refdef.scene.rtdlightshadows = false;
+ r_refdef.lightmapintensity = 0;
+ }
+