]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
more statics...
[xonotic/darkplaces.git] / gl_rmain.c
index fc314d1e88829a19d0b187c03ee4d8ad7dc46fc2..604df149b7f7b416381f7d6f904b6d011002ef58 100644 (file)
@@ -1063,56 +1063,21 @@ static const char *builtinshaderstring =
 "#  ifdef USESHADOWMAPVSDCT\n"
 "vec3 GetShadowMapTC2D(vec3 dir)\n"
 "{\n"
-"   vec3 adir = abs(dir);\n"
-"   vec4 proj = textureCube(Texture_CubeProjection, dir);\n"
-"   float ma = max(max(adir.x, adir.y), adir.z);\n"
-"   vec3 stc = vec3(mix(dir.xy, dir.zz, proj.xy) * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma;\n"
-"   stc.xy += proj.zw * ShadowMap_Parameters.y;\n"
-"   stc.z += ShadowMap_Parameters.z;\n"
-"   return stc;\n"
+"      vec3 adir = abs(dir);\n"
+"      vec2 aparams = ShadowMap_Parameters.xy / max(max(adir.x, adir.y), adir.z);\n"
+"      vec4 proj = textureCube(Texture_CubeProjection, dir);\n"
+"      return vec3(mix(dir.xy, dir.zz, proj.xy) * aparams.x + proj.zw * ShadowMap_Parameters.z, aparams.y + ShadowMap_Parameters.w);\n"
 "}\n"
 "#  else\n"
 "vec3 GetShadowMapTC2D(vec3 dir)\n"
 "{\n"
 "      vec3 adir = abs(dir);\n"
-"      vec2 tc;\n"
-"      vec2 offset;\n"
-"      float ma;\n"
-"      if (adir.x > adir.y)\n"
-"      {\n"
-"              if (adir.x > adir.z) // X\n"
-"              {\n"
-"                      ma = adir.x;\n"
-"                      tc = dir.zy;\n"
-"                      offset = vec2(mix(0.5, 1.5, dir.x < 0.0), 0.5);\n"
-"              }\n"
-"              else // Z\n"
-"              {\n"
-"                      ma = adir.z;\n"
-"                      tc = dir.xy;\n"
-"                      offset = vec2(mix(0.5, 1.5, dir.z < 0.0), 2.5);\n"
-"              }\n"
-"      }\n"
-"      else\n"
-"      {\n"
-"              if (adir.y > adir.z) // Y\n"
-"              {\n"
-"                      ma = adir.y;\n"
-"                      tc = dir.xz;\n"
-"                      offset = vec2(mix(0.5, 1.5, dir.y < 0.0), 1.5);\n"
-"              }\n"
-"              else // Z\n"
-"              {\n"
-"                      ma = adir.z;\n"
-"                      tc = dir.xy;\n"
-"                      offset = vec2(mix(0.5, 1.5, dir.z < 0.0), 2.5);\n"
-"              }\n"
-"      }\n"
-"\n"
-"      vec3 stc = vec3(tc * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma;\n"
-"      stc.xy += offset * ShadowMap_Parameters.y;\n"
-"      stc.z += ShadowMap_Parameters.z;\n"
-"      return stc;\n"
+"      float ma = adir.z;\n"
+"      vec4 proj = vec4(dir, 2.5);\n"
+"      if (adir.x > ma) { ma = adir.x; proj = vec4(dir.zyx, 0.5); }\n"
+"      if (adir.y > ma) { ma = adir.y; proj = vec4(dir.xzy, 1.5); }\n"
+"      vec2 aparams = ShadowMap_Parameters.xy / ma;\n"
+"      return vec3(proj.xy * aparams.x + vec2(proj.z < 0.0 ? 1.5 : 0.5, proj.w) * ShadowMap_Parameters.z, aparams.y + ShadowMap_Parameters.w);\n"
 "}\n"
 "#  endif\n"
 "# endif\n"
@@ -2221,56 +2186,21 @@ const char *builtincgshaderstring =
 "#  ifdef USESHADOWMAPVSDCT\n"
 "float3 GetShadowMapTC2D(float3 dir, float4 ShadowMap_Parameters, samplerCUBE Texture_CubeProjection)\n"
 "{\n"
-"   float3 adir = abs(dir);\n"
-"   float4 proj = texCUBE(Texture_CubeProjection, dir);\n"
-"   float ma = max(max(adir.x, adir.y), adir.z);\n"
-"   float3 stc = float3(lerp(dir.xy, dir.zz, proj.xy) * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma;\n"
-"   stc.xy += proj.zw * ShadowMap_Parameters.y;\n"
-"   stc.z += ShadowMap_Parameters.z;\n"
-"   return stc;\n"
+"      float3 adir = abs(dir);\n"
+"      float2 aparams = ShadowMap_Parameters.xy / max(max(adir.x, adir.y), adir.z);\n"
+"      float4 proj = texCUBEe(Texture_CubeProjection, dir);\n"
+"      return float3(mix(dir.xy, dir.zz, proj.xy) * aparams.x + proj.zw * ShadowMap_Parameters.z, aparams.y + ShadowMap_Parameters.w);\n"
 "}\n"
 "#  else\n"
 "float3 GetShadowMapTC2D(float3 dir, float4 ShadowMap_Parameters)\n"
 "{\n"
 "      float3 adir = abs(dir);\n"
-"      float2 tc;\n"
-"      float2 offset;\n"
-"      float ma;\n"
-"      if (adir.x > adir.y)\n"
-"      {\n"
-"              if (adir.x > adir.z) // X\n"
-"              {\n"
-"                      ma = adir.x;\n"
-"                      tc = dir.zy;\n"
-"                      offset = float2(lerp(0.5, 1.5, dir.x < 0.0), 0.5);\n"
-"              }\n"
-"              else // Z\n"
-"              {\n"
-"                      ma = adir.z;\n"
-"                      tc = dir.xy;\n"
-"                      offset = float2(lerp(0.5, 1.5, dir.z < 0.0), 2.5);\n"
-"              }\n"
-"      }\n"
-"      else\n"
-"      {\n"
-"              if (adir.y > adir.z) // Y\n"
-"              {\n"
-"                      ma = adir.y;\n"
-"                      tc = dir.xz;\n"
-"                      offset = float2(lerp(0.5, 1.5, dir.y < 0.0), 1.5);\n"
-"              }\n"
-"              else // Z\n"
-"              {\n"
-"                      ma = adir.z;\n"
-"                      tc = dir.xy;\n"
-"                      offset = float2(lerp(0.5, 1.5, dir.z < 0.0), 2.5);\n"
-"              }\n"
-"      }\n"
-"\n"
-"      float3 stc = float3(tc * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma;\n"
-"      stc.xy += offset * ShadowMap_Parameters.y;\n"
-"      stc.z += ShadowMap_Parameters.z;\n"
-"      return stc;\n"
+"      float ma = adir.z;\n"
+"      float4 proj = float4(dir, 2.5);\n"
+"      if (adir.x > ma) { ma = adir.x; proj = float4(dir.zyx, 0.5); }\n"
+"      if (adir.y > ma) { ma = adir.y; proj = float4(dir.xzy, 1.5); }\n"
+"      float2 aparams = ShadowMap_Parameters.xy / ma;\n"
+"      return float3(proj.xy * aparams.x + float2(proj.z < 0.0 ? 1.5 : 0.5, proj.w) * ShadowMap_Parameters.z, aparams.y + ShadowMap_Parameters.w);\n"
 "}\n"
 "#  endif\n"
 "# endif\n"
@@ -11137,7 +11067,7 @@ static void R_DrawWorldTextureSurfaceList(int texturenumsurfaces, const msurface
 {
        CHECKGLERROR
        RSurf_SetupDepthAndCulling();
-       if (r_showsurfaces.integer == 3 && !prepass && (rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY))
+       if (r_showsurfaces.integer == 3 && !prepass && !(rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY))
        {
                R_DrawTextureSurfaceList_ShowSurfaces3(texturenumsurfaces, texturesurfacelist, writedepth);
                return;
@@ -11162,7 +11092,7 @@ static void R_DrawModelTextureSurfaceList(int texturenumsurfaces, const msurface
 {
        CHECKGLERROR
        RSurf_SetupDepthAndCulling();
-       if (r_showsurfaces.integer == 3 && !prepass && (rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY))
+       if (r_showsurfaces.integer == 3 && !prepass && !(rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY))
        {
                R_DrawTextureSurfaceList_ShowSurfaces3(texturenumsurfaces, texturesurfacelist, writedepth);
                return;
@@ -12098,6 +12028,16 @@ static void R_DrawModelDecals_Entity(entity_render_t *ent)
                        VectorCopy(decal->vertex3f[2], v3f + 6);
                }
 
+               if (r_refdef.fogenabled)
+               {
+                       alpha = RSurf_FogVertex(v3f);
+                       VectorScale(c4f, alpha, c4f);
+                       alpha = RSurf_FogVertex(v3f + 3);
+                       VectorScale(c4f + 4, alpha, c4f + 4);
+                       alpha = RSurf_FogVertex(v3f + 6);
+                       VectorScale(c4f + 8, alpha, c4f + 8);
+               }
+
                v3f += 9;
                c4f += 12;
                t2f += 6;
@@ -12108,25 +12048,6 @@ static void R_DrawModelDecals_Entity(entity_render_t *ent)
        {
                r_refdef.stats.drawndecals += numtris;
 
-               if (r_refdef.fogenabled)
-               {
-                       switch(vid.renderpath)
-                       {
-                       case RENDERPATH_GL20:
-                       case RENDERPATH_CGGL:
-                       case RENDERPATH_GL13:
-                       case RENDERPATH_GL11:
-                               for (i = 0, v3f = decalsystem->vertex3f, c4f = decalsystem->color4f;i < numtris*3;i++, v3f += 3, c4f += 4)
-                               {
-                                       alpha = RSurf_FogVertex(v3f);
-                                       c4f[0] *= alpha;
-                                       c4f[1] *= alpha;
-                                       c4f[2] *= alpha;
-                               }
-                               break;
-                       }
-               }
-
                // now render the decals all at once
                // (this assumes they all use one particle font texture!)
                RSurf_ActiveCustomEntity(&rsurface.matrix, &rsurface.inversematrix, rsurface.ent_flags, rsurface.ent_shadertime, 1, 1, 1, 1, numdecals*3, decalsystem->vertex3f, decalsystem->texcoord2f, NULL, NULL, NULL, decalsystem->color4f, numtris, decalsystem->element3i, decalsystem->element3s, false, false);