From: eihrul Date: Wed, 30 Sep 2009 08:59:11 +0000 (+0000) Subject: added in stub permutations for shadowmap2d and shadowmapcube cases X-Git-Tag: xonotic-v0.1.0preview~1376 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f7870cd9acfd26f80c7e2285401a3881d4a9d24f;p=xonotic%2Fdarkplaces.git added in stub permutations for shadowmap2d and shadowmapcube cases git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9257 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index 5cb50b50..6bb40f4a 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -449,6 +449,8 @@ static const char *builtinshaderstring = "// written by Forest 'LordHavoc' Hale\n" "#ifdef USESHADOWMAPRECT\n" "#extension GL_ARB_texture_rectangle : enable\n" +"#endif\n" +"#ifdef USESHADOWMAP2D\n" "# ifdef HASTEXTUREGATHER\n" "# extension GL_ARB_texture_gather : enable\n" "# else\n" @@ -458,6 +460,9 @@ static const char *builtinshaderstring = "# endif\n" "# endif\n" "#endif\n" +"#ifdef USESHADOWMAPCUBE\n" +"#extension GL_EXT_gpu_shader4 : enable\n" +"#endif\n" "\n" "// common definitions between vertex shader and fragment shader:\n" "\n" @@ -773,10 +778,28 @@ static const char *builtinshaderstring = "# else\n" "uniform sampler2DRect Texture_ShadowMapRect;\n" "# endif\n" +"#endif\n" "\n" +"#ifdef USESHADOWMAP2D\n" +"# ifdef USESHADOWSAMPLER\n" +"uniform sampler2DShadow Texture_ShadowMap2D;\n" +"# else\n" +"uniform sampler2D Texture_ShadowMap2D;\n" +"# endif\n" +"#endif\n" +"\n" +"#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D)\n" "uniform samplerCube Texture_CubeProjection;\n" "#endif\n" "\n" +"#ifdef USESHADOWMAPCUBE\n" +"# ifdef USESHADOWSAMPLER\n" +"uniform samplerCubeShadow Texture_ShadowMapCube;\n" +"# else\n" +"uniform samplerCube Texture_ShadowMapCube;\n" +"# endif\n" +"#endif\n" +"\n" "uniform myhalf3 LightColor;\n" "uniform myhalf3 AmbientColor;\n" "uniform myhalf3 DiffuseColor;\n" @@ -872,12 +895,12 @@ static const char *builtinshaderstring = "}\n" "#endif // USEOFFSETMAPPING\n" "\n" -"#ifdef USESHADOWMAPRECT \n" +"#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D) || defined(USESHADOWMAPCUBE)\n" "uniform vec4 ShadowMap_TextureScale;\n" -"#if 0\n" "uniform vec4 ShadowMap_Parameters;\n" "#endif\n" "\n" +"#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D)\n" "vec3 GetShadowMapTC2D(vec3 dir)\n" "{\n" " vec3 adir = abs(dir);\n" @@ -958,11 +981,22 @@ static const char *builtinshaderstring = "\n" " return vec3(tc * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma + vec3(offset * ShadowMap_Parameters.y, ShadowMap_Parameters.z);\n" "# else\n" +"# ifdef USESHADOWMAPRECT \n" " return vec3(textureCube(Texture_CubeProjection, dir.xyz).ra * ShadowMap_TextureScale.xy, ShadowMap_TextureScale.z + ShadowMap_TextureScale.w / max(max(adir.x, adir.y), adir.z));\n" +"# else\n" +" return vec3(textureCube(Texture_CubeProjection, dir.xyz).ra, ShadowMap_Parameters.z + ShadowMap_Parameters.w / max(max(adir.x, adir.y), adir.z));\n" +"# endif\n" "# endif\n" "}\n" +"#endif // defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D)\n" "\n" -"#endif // USESHADOWMAPRECT\n" +"#ifdef USESHADOWMAPCUBE\n" +"vec4 GetShadowMapTCCube(vec3 dir)\n" +"{\n" +" vec3 adir = abs(dir);\n" +" return vec4(dir, ShadowMap_Parameters.z + ShadowMap_Parameters.w / max(max(adir.x, adir.y), adir.z));\n" +"}\n" +"#endif\n" "\n" "#if !showshadowmap\n" "# ifdef USESHADOWMAPRECT\n" @@ -1044,8 +1078,35 @@ static const char *builtinshaderstring = "}\n" "# endif\n" "\n" -"#endif\n" +"# ifdef USESHADOWMAP2D\n" +"float ShadowMapCompare(vec3 dir)\n" +"{\n" +" vec3 shadowmaptc = GetShadowMapTC2D(dir);\n" +" float f;\n" +"# ifdef USESHADOWSAMPLER\n" +" f = shadow2D(Texture_ShadowMap2D, shadowmaptc).r;\n" +"# else\n" +" f = step(shadowmaptc.z, texture2D(Texture_ShadowMap2D, shadowmaptc.xy).r);\n" +"# endif\n" +" return f;\n" +"}\n" +"# endif\n" "\n" +"# ifdef USESHADOWMAPCUBE\n" +"float ShadowMapCompare(vec3 dir)\n" +"{\n" +" // apply depth texture cubemap as light filter\n" +" vec4 shadowmaptc = GetShadowMapTCCube(dir);\n" +" float f;\n" +"# ifdef USESHADOWSAMPLER\n" +" f = shadowCube(Texture_ShadowMapCube, shadowmaptc).r;\n" +"# else\n" +" f = step(shadowmaptc.w, textureCube(Texture_ShadowMapCube, shadowmaptc.xyz).r);\n" +"# endif\n" +" return f;\n" +"}\n" +"# endif\n" +"#endif\n" "\n" "#ifdef MODE_WATER\n" "\n" @@ -1182,9 +1243,9 @@ static const char *builtinshaderstring = "# endif\n" "# endif\n" "\n" -"#ifdef USESHADOWMAPRECT\n" +"#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAPCUBE) || defined(USESHADOWMAP2D)\n" "#if !showshadowmap\n" -" color.rgb *= ShadowMapCompare(CubeVector);\n" +" color.rgb *= ShadowMapCompare(CubeVector);\n" "#endif\n" "#endif\n" "\n" @@ -1357,6 +1418,21 @@ static const char *builtinshaderstring = " gl_FragColor = texture2DRect(Texture_ShadowMapRect, GetShadowMapTC2D(CubeVector).xy);\n" "# endif\n" "# endif\n" +"# ifdef USESHADOWMAP2D\n" +"# ifdef USESHADOWSAMPLER\n" +" gl_FragColor = shadow2D(Texture_ShadowMap2D, GetShadowMapTC2D(CubeVector).xyz);\n" +"# else\n" +" gl_FragColor = texture2D(Texture_ShadowMap2D, GetShadowMapTC2D(CubeVector).xy);\n" +"# endif\n" +"# endif\n" +"\n" +"# ifdef USESHADOWMAPCUBE\n" +"# ifdef USESHADOWSAMPLER\n" +" gl_FragColor = shadowCube(Texture_ShadowMapCube, GetShadowMapTCCube(CubeVector));\n" +"# else\n" +" gl_FragColor = textureCube(Texture_ShadowMapCube, GetShadowMapTCCube(CubeVector).xyz);\n" +"# endif\n" +"# endif\n" "#endif\n" "}\n" "#endif // !MODE_REFRACTION\n"