"vec3 GetShadowMapTC2D(vec3 dir)\n"
"{\n"
" vec3 adir = abs(dir);\n"
-" float ma = max(max(adir.x, adir.y), adir.z);\n"
+" vec2 aparams = ShadowMap_Parameters.xy / max(max(adir.x, adir.y), adir.z);\n"
" vec4 proj = textureCube(Texture_CubeProjection, dir);\n"
-" vec3 stc = vec3(mix(dir.xy, dir.zz, proj.xy) * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma;\n"
-" stc += vec3(proj.zw * ShadowMap_Parameters.y, ShadowMap_Parameters.z);\n"
-" return stc;\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"
" 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"
-" vec3 stc = vec3(proj.xy * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma;\n"
-" stc += vec3(vec2(proj.z < 0.0 ? 1.5 : 0.5, proj.w) * ShadowMap_Parameters.y, ShadowMap_Parameters.z);\n"
-" return stc;\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"
"float3 GetShadowMapTC2D(float3 dir, float4 ShadowMap_Parameters, samplerCUBE Texture_CubeProjection)\n"
"{\n"
" float3 adir = abs(dir);\n"
-" float ma = max(max(adir.x, adir.y), adir.z);\n"
-" float4 proj = texCUBE(Texture_CubeProjection, dir);\n"
-" float3 stc = float3(lerp(dir.xy, dir.zz, proj.xy) * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma;\n"
-" stc += float3(proj.zw * ShadowMap_Parameters.y, ShadowMap_Parameters.z);\n"
-" return stc;\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"
" 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"
-" float3 stc = float3(proj.xy * ShadowMap_Parameters.x, ShadowMap_Parameters.w) / ma;\n"
-" stc += float3(vec2(proj.z < 0.0 ? 1.5 : 0.5, proj.w) * ShadowMap_Parameters.y, ShadowMap_Parameters.z);\n"
-" return stc;\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"
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;
- r_shadow_shadowmap_parameters[2] = 0.5f + 0.5f * (farclip + nearclip) / (farclip - nearclip);
- r_shadow_shadowmap_parameters[3] = -nearclip * farclip / (farclip - nearclip) - 0.5f * bias;
+ r_shadow_shadowmap_parameters[1] = -nearclip * farclip / (farclip - nearclip) - 0.5f * bias;
+ r_shadow_shadowmap_parameters[3] = 0.5f + 0.5f * (farclip + nearclip) / (farclip - nearclip);
r_shadow_shadowmapside = side;
r_shadow_shadowmapsize = size;
switch (r_shadow_shadowmode)
{
case R_SHADOW_SHADOWMODE_SHADOWMAP2D:
r_shadow_shadowmap_parameters[0] = 0.5f * (size - r_shadow_shadowmapborder);
- r_shadow_shadowmap_parameters[1] = r_shadow_shadowmapvsdct ? 2.5f*size : size;
+ r_shadow_shadowmap_parameters[2] = r_shadow_shadowmapvsdct ? 2.5f*size : size;
R_Viewport_InitRectSideView(&viewport, &rsurface.rtlight->matrix_lighttoworld, side, size, r_shadow_shadowmapborder, nearclip, farclip, NULL);
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_SHADOWMAP2D) goto init_done;
break;
case R_SHADOW_SHADOWMODE_SHADOWMAPRECTANGLE:
r_shadow_shadowmap_parameters[0] = 0.5f * (size - r_shadow_shadowmapborder);
- r_shadow_shadowmap_parameters[1] = r_shadow_shadowmapvsdct ? 2.5f*size : size;
+ r_shadow_shadowmap_parameters[2] = r_shadow_shadowmapvsdct ? 2.5f*size : size;
R_Viewport_InitRectSideView(&viewport, &rsurface.rtlight->matrix_lighttoworld, side, size, r_shadow_shadowmapborder, nearclip, farclip, NULL);
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_SHADOWMAPRECTANGLE) goto init_done;
break;
case R_SHADOW_SHADOWMODE_SHADOWMAPCUBESIDE:
r_shadow_shadowmap_parameters[0] = 1.0f;
- r_shadow_shadowmap_parameters[1] = 1.0f;
+ r_shadow_shadowmap_parameters[2] = 1.0f;
R_Viewport_InitCubeSideView(&viewport, &rsurface.rtlight->matrix_lighttoworld, side, size, nearclip, farclip, NULL);
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_SHADOWMAPCUBESIDE) goto init_done;