]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_shadow.c
for some reason, it's faster to always set the lightmaptexture (more than double...
[xonotic/darkplaces.git] / r_shadow.c
index 45fe5c9f3ede0f85553c352cc7112cd5bf7d83b8..8e6958522cdb9fcc4763ea084bcdd7e512f7a973 100644 (file)
@@ -2046,13 +2046,13 @@ static void R_Shadow_MakeShadowMap(int side, int size)
        }
 }
 
-static float testcolor[4] = {0,1,0,1};
 void R_Shadow_RenderMode_ShadowMap(int side, int clear, int size)
 {
        float nearclip, farclip, bias;
        r_viewport_t viewport;
        int flipped;
        GLuint fbo = 0;
+       float clearcolor[4];
        nearclip = r_shadow_shadowmapping_nearclip.value / rsurface.rtlight->radius;
        farclip = 1.0f;
        bias = r_shadow_shadowmapping_bias.value * nearclip * (1024.0f / size);// * rsurface.rtlight->radius;
@@ -2116,6 +2116,7 @@ init_done:
                GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
                break;
        case RENDERPATH_D3D9:
+               Vector4Set(clearcolor, 1,1,1,1);
                // completely different meaning than in OpenGL path
                r_shadow_shadowmap_parameters[1] = 0;
                r_shadow_shadowmap_parameters[3] = -bias;
@@ -2128,13 +2129,13 @@ init_done:
                {
                        GL_ColorMask(0,0,0,0);
                        if (clear)
-                               GL_Clear(GL_DEPTH_BUFFER_BIT, testcolor, 1.0f, 0);
+                               GL_Clear(GL_DEPTH_BUFFER_BIT, clearcolor, 1.0f, 0);
                }
                else
                {
                        GL_ColorMask(1,1,1,1);
                        if (clear)
-                               GL_Clear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT, testcolor, 1.0f, 0);
+                               GL_Clear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT, clearcolor, 1.0f, 0);
                }
                break;
        case RENDERPATH_D3D10:
@@ -4366,6 +4367,30 @@ void R_DrawModelShadowMaps(void)
        Matrix4x4_Concat(&texmatrix, &scalematrix, &shadowmatrix);
        Matrix4x4_Concat(&r_shadow_shadowmapmatrix, &texmatrix, &invmvpmatrix);
 
+       switch (vid.renderpath)
+       {
+       case RENDERPATH_GL11:
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL20:
+       case RENDERPATH_CGGL:
+               break;
+       case RENDERPATH_D3D9:
+       case RENDERPATH_D3D10:
+       case RENDERPATH_D3D11:
+#ifdef OPENGL_ORIENTATION
+               r_shadow_shadowmapmatrix.m[0][0]        *= -1.0f;
+               r_shadow_shadowmapmatrix.m[0][1]        *= -1.0f;
+               r_shadow_shadowmapmatrix.m[0][2]        *= -1.0f;
+               r_shadow_shadowmapmatrix.m[0][3]        *= -1.0f;
+#else
+               r_shadow_shadowmapmatrix.m[0][0]        *= -1.0f;
+               r_shadow_shadowmapmatrix.m[1][0]        *= -1.0f;
+               r_shadow_shadowmapmatrix.m[2][0]        *= -1.0f;
+               r_shadow_shadowmapmatrix.m[3][0]        *= -1.0f;
+#endif
+               break;
+       }
+
        r_shadow_usingshadowmaportho = true;
        switch (r_shadow_shadowmode)
        {