]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
moved trace endpos calculation outside of RecursiveHullCheck, to improve code layout...
[xonotic/darkplaces.git] / gl_rmain.c
index 54832756d0977bc42e6f83854e25ce9596702b52..1463a2cb62a2b3256138a691ca4813e6db57ad79 100644 (file)
@@ -54,7 +54,6 @@ unsigned short d_lightstylevalue[256];
 
 cvar_t r_drawentities = {0, "r_drawentities","1"};
 cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1"};
-cvar_t r_shadows = {CVAR_SAVE, "r_shadows", "0"};
 cvar_t r_shadow_staticworldlights = {0, "r_shadow_staticworldlights", "1"};
 cvar_t r_speeds = {0, "r_speeds","0"};
 cvar_t r_fullbright = {0, "r_fullbright","0"};
@@ -77,7 +76,7 @@ cvar_t r_textureunits = {0, "r_textureunits", "32"};
 cvar_t r_lerpsprites = {CVAR_SAVE, "r_lerpsprites", "1"};
 cvar_t r_lerpmodels = {CVAR_SAVE, "r_lerpmodels", "1"};
 cvar_t r_waterscroll = {CVAR_SAVE, "r_waterscroll", "1"};
-
+cvar_t r_watershader = {CVAR_SAVE, "r_watershader", "1"};
 
 
 void R_ModulateColors(float *in, float *out, int verts, float r, float g, float b)
@@ -248,7 +247,6 @@ void GL_Main_Init(void)
        Cmd_AddCommand("timerefresh", R_TimeRefresh_f);
        Cvar_RegisterVariable(&r_drawentities);
        Cvar_RegisterVariable(&r_drawviewmodel);
-       Cvar_RegisterVariable(&r_shadows);
        Cvar_RegisterVariable(&r_shadow_staticworldlights);
        Cvar_RegisterVariable(&r_speeds);
        Cvar_RegisterVariable(&r_fullbrights);
@@ -260,6 +258,7 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable(&r_lerpsprites);
        Cvar_RegisterVariable(&r_lerpmodels);
        Cvar_RegisterVariable(&r_waterscroll);
+       Cvar_RegisterVariable(&r_watershader);
        Cvar_RegisterVariable(&r_drawcollisionbrushes);
        if (gamemode == GAME_NEHAHRA || gamemode == GAME_NEXUIZ)
                Cvar_SetValue("r_fullbrights", 0);
@@ -508,25 +507,6 @@ void R_DrawModels(void)
        }
 }
 
-void R_DrawFakeShadows(void)
-{
-       int i;
-       entity_render_t *ent;
-
-       ent = &cl_entities[0].render;
-       if (ent->model && ent->model->DrawFakeShadow)
-               ent->model->DrawFakeShadow(ent);
-
-       if (!r_drawentities.integer)
-               return;
-       for (i = 0;i < r_refdef.numentities;i++)
-       {
-               ent = r_refdef.entities[i];
-               if ((ent->flags & RENDER_SHADOW) && ent->model && ent->model->DrawFakeShadow)
-                       ent->model->DrawFakeShadow(ent);
-       }
-}
-
 #include "r_shadow.h"
 
 int shadowframecount = 0;
@@ -568,7 +548,7 @@ void R_ShadowVolumeLighting(int visiblevolumes)
                GL_DepthMask(false);
                GL_DepthTest(r_shadow_visiblevolumes.integer < 2);
                qglDisable(GL_CULL_FACE);
-               GL_Color(0.0 * r_colorscale, 0.0125 * r_colorscale, 0.1 * r_colorscale, 1);
+               GL_Color(0.0, 0.0125, 0.1, 1);
        }
        else
                R_Shadow_Stage_Begin();
@@ -685,7 +665,7 @@ void R_ShadowVolumeLighting(int visiblevolumes)
                        cullradius = RadiusFromBoundsAndOrigin(clipmins, clipmaxs, rd->origin);
                        VectorScale(rd->light, (1.0f / 4096.0f), lightcolor);
 
-                       if (gl_stencil || visiblevolumes)
+                       if (r_shadow_shadows.integer && (gl_stencil || visiblevolumes))
                        {
                                if (!visiblevolumes)
                                        R_Shadow_Stage_ShadowVolumes();
@@ -704,7 +684,7 @@ void R_ShadowVolumeLighting(int visiblevolumes)
 
                        if (!visiblevolumes)
                        {
-                               if (gl_stencil)
+                               if (r_shadow_shadows.integer && gl_stencil)
                                        R_Shadow_Stage_LightWithShadows();
                                else
                                        R_Shadow_Stage_LightWithoutShadows();
@@ -865,7 +845,7 @@ void R_RenderView (void)
        {
                if (!gl_stencil)
                {
-                       Con_Printf("Stencil not enabled, turning off r_shadow_realtime_world, please type vid_stencil 1;vid_bitsperpixel 32;vid_restart and try again\n");
+                       Con_Printf("Realtime world lighting requires 32bit color turning off r_shadow_realtime_world, please type vid_bitsperpixel 32;vid_restart and try again\n");
                        Cvar_SetValueQuick(&r_shadow_realtime_world, 0);
                }
        }
@@ -896,7 +876,7 @@ void R_RenderView (void)
        R_TimeReport("markentity");
 
        GL_SetupView_ViewPort(r_refdef.x, r_refdef.y, r_refdef.width, r_refdef.height);
-       if (r_shadow_realtime_world.integer || gl_stencil)
+       if ((r_shadow_realtime_world.integer || r_shadow_shadows.integer) && gl_stencil)
                GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.fov_x, r_refdef.fov_y, 1.0f);
        else
                GL_SetupView_Mode_Perspective(r_refdef.fov_x, r_refdef.fov_y, 1.0f, r_farclip);
@@ -922,12 +902,6 @@ void R_RenderView (void)
        R_DrawModels();
        R_TimeReport("models");
 
-       if (r_shadows.integer == 1 && !r_shadow_realtime_world.integer)
-       {
-               R_DrawFakeShadows();
-               R_TimeReport("fakeshadow");
-       }
-
        if (r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer)
        {
                R_ShadowVolumeLighting(false);
@@ -992,7 +966,7 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
        vertex3f[18] = mins[0];vertex3f[19] = maxs[1];vertex3f[20] = maxs[2];
        vertex3f[21] = maxs[0];vertex3f[22] = maxs[1];vertex3f[23] = maxs[2];
        GL_ColorPointer(color);
-       R_FillColors(color, 8, cr * r_colorscale, cg * r_colorscale, cb * r_colorscale, ca);
+       R_FillColors(color, 8, cr, cg, cb, ca);
        if (fogenabled)
        {
                for (i = 0, v = vertex, c = color;i < 8;i++, v += 4, c += 4)
@@ -1000,7 +974,6 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
                        VectorSubtract(v, r_origin, diff);
                        f2 = exp(fogdensity/DotProduct(diff, diff));
                        f1 = 1 - f2;
-                       f2 *= r_colorscale;
                        c[0] = c[0] * f1 + fogcolor[0] * f2;
                        c[1] = c[1] * f1 + fogcolor[1] * f2;
                        c[2] = c[2] * f1 + fogcolor[2] * f2;
@@ -1080,23 +1053,18 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2)
                f1 = 1 - f2;
                for (i = 0, c = color4f;i < 6;i++, c += 4)
                {
-                       c[0] = (c[0] * f1 + fogcolor[0] * f2) * r_colorscale;
-                       c[1] = (c[1] * f1 + fogcolor[1] * f2) * r_colorscale;
-                       c[2] = (c[2] * f1 + fogcolor[2] * f2) * r_colorscale;
+                       c[0] = (c[0] * f1 + fogcolor[0] * f2);
+                       c[1] = (c[1] * f1 + fogcolor[1] * f2);
+                       c[2] = (c[2] * f1 + fogcolor[2] * f2);
                        c[3] *= ent->alpha;
                }
        }
-       else if (r_colorscale != 1 || ent->alpha != 1)
+       else if (ent->alpha != 1)
        {
                memcpy(color4f, nomodelcolor4f, sizeof(float[6*4]));
                GL_ColorPointer(color4f);
                for (i = 0, c = color4f;i < 6;i++, c += 4)
-               {
-                       c[0] *= r_colorscale;
-                       c[1] *= r_colorscale;
-                       c[2] *= r_colorscale;
                        c[3] *= ent->alpha;
-               }
        }
        else
                GL_ColorPointer(nomodelcolor4f);
@@ -1156,7 +1124,7 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, int depth
        }
 
        R_Mesh_Matrix(&r_identitymatrix);
-       GL_Color(cr * r_colorscale, cg * r_colorscale, cb * r_colorscale, ca);
+       GL_Color(cr, cg, cb, ca);
        GL_VertexPointer(varray_vertex3f);
        GL_BlendFunc(blendfunc1, blendfunc2);
        GL_DepthMask(false);