"// 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"
"# 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"
"# 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"
"}\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"
"\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"
"}\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"
"# 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"
" 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"