+"#ifdef USESHADOWMAPRECT \n"
+"uniform vec4 ShadowMap_TextureScale;\n"
+"#if 0\n"
+"uniform vec4 ShadowMap_Parameters;\n"
+"#endif\n"
+"\n"
+"vec3 GetShadowMapTC2D(vec3 dir)\n"
+"{\n"
+" vec3 adir = abs(dir);\n"
+"# if 0\n"
+" vec2 tc;\n"
+" vec2 offset;\n"
+" float ma;\n"
+" if (adir.x > adir.y)\n"
+" {\n"
+" if (adir.x > adir.z)\n"
+" {\n"
+" ma = adir.x;\n"
+" if (dir.x >= 0.0)\n"
+" {\n"
+" // +X\n"
+" tc = vec2(-dir.z, -dir.y);\n"
+" offset = vec2(0.5, 0.5);\n"
+" }\n"
+" else\n"
+" {\n"
+" // -X\n"
+" tc = vec2( dir.z, -dir.y);\n"
+" offset = vec2(1.5, 0.5);\n"
+" }\n"
+" }\n"
+" else\n"
+" {\n"
+" ma = adir.z;\n"
+" if (dir.z >= 0.0)\n"
+" {\n"
+" // +Z\n"
+" tc = vec2( dir.x, -dir.y);\n"
+" offset = vec2(0.5, 2.5);\n"
+" }\n"
+" else\n"
+" {\n"
+" // -Z\n"
+" tc = vec2(-dir.x, -dir.y);\n"
+" offset = vec2(1.5, 2.5);\n"
+" }\n"
+" }\n"
+" }\n"
+" else\n"
+" {\n"
+" if (adir.y > adir.z)\n"
+" {\n"
+" ma = adir.y;\n"
+" if (dir.y >= 0.0)\n"
+" {\n"
+" // +Y\n"
+" tc = vec2( dir.x, dir.z);\n"
+" offset = vec2(0.5, 1.5);\n"
+" }\n"
+" else\n"
+" {\n"
+" // -Y\n"
+" tc = vec2( dir.x, -dir.z);\n"
+" offset = vec2(1.5, 1.5);\n"
+" }\n"
+" }\n"
+" else\n"
+" {\n"
+" ma = adir.z;\n"
+" if (dir.z >= 0.0)\n"
+" {\n"
+" // +Z\n"
+" tc = vec2(dir.x, -dir.y);\n"
+" offset = vec2(0.5, 2.5);\n"
+" }\n"
+" else\n"
+" {\n"
+" // -Z\n"
+" tc = vec2(-dir.x, -dir.y);\n"
+" offset = vec2(1.5, 2.5);\n"
+" }\n"
+" }\n"
+" }\n"
+"\n"
+" return vec3(tc * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma + vec3(offset * ShadowMap_Parameters.y, ShadowMap_Parameters.z);\n"
+"# else\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"
+"# endif\n"
+"}\n"
+"\n"
+"#endif // USESHADOWMAPRECT\n"
+"\n"
+"#if !showshadowmap\n"
+"# ifdef USESHADOWMAPRECT\n"
+"float ShadowMapCompare(vec3 dir)\n"
+"{\n"
+" vec3 shadowmaptc = GetShadowMapTC2D(dir);\n"
+" float f;\n"
+"# ifdef USESHADOWSAMPLER\n"
+"\n"
+"# ifdef USESHADOWMAPPCF\n"
+" f = dot(vec4(0.25),\n"
+" vec4(shadow2DRect(Texture_ShadowMapRect, shadowmaptc.xyz + vec3(-0.4, 1.0, 0.0)).r,\n"
+" shadow2DRect(Texture_ShadowMapRect, shadowmaptc.xyz + vec3(-1.0, -0.4, 0.0)).r,\n"
+" shadow2DRect(Texture_ShadowMapRect, shadowmaptc.xyz + vec3( 0.4, -1.0, 0.0)).r,\n"
+" shadow2DRect(Texture_ShadowMapRect, shadowmaptc.xyz + vec3( 1.0, 0.4, 0.0)).r));\n"
+"# else\n"
+" f = shadow2DRect(Texture_ShadowMapRect, shadowmaptc).r;\n"
+"# endif\n"
+"\n"
+"# else\n"
+"\n"
+"# ifdef USESHADOWMAPPCF\n"
+"# if defined(HASTEXTUREGATHER) || defined(HASTEXTURE4)\n"
+" vec2 offset = fract(shadowmaptc.xy - 0.5);\n"
+" vec4 group1 = step(shadowmaptc.z, textureGather(Texture_ShadowMapRect, shadowmaptc.xy + vec2(-1.0, -1.0))),\n"
+" group2 = step(shadowmaptc.z, textureGather(Texture_ShadowMapRect, shadowmaptc.xy + vec2( 1.0, -1.0))),\n"
+" group3 = step(shadowmaptc.z, textureGather(Texture_ShadowMapRect, shadowmaptc.xy + vec2(-1.0, 1.0))),\n"
+" group4 = step(shadowmaptc.z, textureGather(Texture_ShadowMapRect, shadowmaptc.xy + vec2( 1.0, 1.0))),\n"
+" cols = vec4(group1.ab, group2.ab) + vec4(group3.rg, group4.rg) +\n"
+" mix(vec4(group1.rg, group2.rg), vec4(group3.ab, group4.ab), offset.y);\n"
+" f = dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));\n"
+"# elif 1\n"
+" vec2 center = shadowmaptc.xy - 0.5, offset = fract(center);\n"
+" vec4 row1 = step(shadowmaptc.z,\n"
+" vec4(texture2DRect(Texture_ShadowMapRect, center + vec2(-1.0, -1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 0.0, -1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 1.0, -1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 2.0, -1.0)).r)),\n"
+" row2 = step(shadowmaptc.z,\n"
+" vec4(texture2DRect(Texture_ShadowMapRect, center + vec2(-1.0, 0.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 1.0, 0.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 2.0, 0.0)).r)),\n"
+" row3 = step(shadowmaptc.z,\n"
+" vec4(texture2DRect(Texture_ShadowMapRect, center + vec2(-1.0, 1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 0.0, 1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 1.0, 1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 2.0, 1.0)).r)),\n"
+" row4 = step(shadowmaptc.z,\n"
+" vec4(texture2DRect(Texture_ShadowMapRect, center + vec2(-1.0, 2.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 0.0, 2.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 1.0, 2.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, center + vec2( 2.0, 2.0)).r)),\n"
+" cols = row2 + row3 + mix(row1, row4, offset.y);\n"
+" f = dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));\n"
+"# else\n"
+" vec2 offset = fract(shadowmaptc.xy);\n"
+" vec3 row1 = step(shadowmaptc.z,\n"
+" vec3(texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2(-1.0, -1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2( 0.0, -1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2( 1.0, -1.0)).r)),\n"
+" row2 = step(shadowmaptc.z,\n"
+" vec3(texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2(-1.0, 0.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy).r,\n"
+" texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2( 1.0, 0.0)).r)),\n"
+" row3 = step(shadowmaptc.z,\n"
+" vec3(texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2(-1.0, 1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2( 0.0, 1.0)).r,\n"
+" texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2( 1.0, 1.0)).r)),\n"
+" cols = row2 + mix(row1, row3, offset.y);\n"
+" f = dot(mix(cols.xy, cols.yz, offset.x), vec2(0.25));\n"
+"# endif\n"
+"# else\n"
+" f = step(shadowmaptc.z, texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy).r);\n"
+"# endif\n"
+"\n"
+"# endif\n"
+" return f;\n"
+"}\n"
+"# endif\n"
+"\n"
+"#endif\n"
+"\n"
+"\n"