"\n"
"#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D)\n"
"# ifdef USESHADOWMAPORTHO\n"
-"# define GetShadowMapTC2D(dir) (min(dir, vec3(ShadowMap_Parameters.zw, 1.0)))\n"
+"# define GetShadowMapTC2D(dir) (min(dir, ShadowMap_Parameters.xyz))\n"
"# else\n"
"# ifdef USESHADOWMAPVSDCT\n"
"vec3 GetShadowMapTC2D(vec3 dir)\n"
"\n"
"# endif\n"
"# ifdef USESHADOWMAPORTHO\n"
-" return mix(ShadowMap_Parameters.x, ShadowMap_Parameters.y, f);\n"
+" return mix(ShadowMap_Parameters.w, 1.0, f);\n"
"# else\n"
" return f;\n"
"# endif\n"
"# endif\n"
"# endif\n"
"# ifdef USESHADOWMAPORTHO\n"
-" return mix(ShadowMap_Parameters.x, ShadowMap_Parameters.y, f);\n"
+" return mix(ShadowMap_Parameters.w, 1.0, f);\n"
"# else\n"
" return f;\n"
"# endif\n"
"#if defined(MODE_LIGHTSOURCE) || defined(MODE_DEFERREDLIGHTSOURCE) || defined(USESHADOWMAPORTHO)\n"
"#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D)\n"
"# ifdef USESHADOWMAPORTHO\n"
-"# define GetShadowMapTC2D(dir, ShadowMap_Parameters) (min(dir, float3(ShadowMap_Parameters.zw, 1.0)))\n"
+"# define GetShadowMapTC2D(dir, ShadowMap_Parameters) (min(dir, ShadowMap_Parameters.xyz))\n"
"# else\n"
"# ifdef USESHADOWMAPVSDCT\n"
"float3 GetShadowMapTC2D(float3 dir, float4 ShadowMap_Parameters, samplerCUBE Texture_CubeProjection)\n"
"\n"
"# endif\n"
"# ifdef USESHADOWMAPORTHO\n"
-" return lerp(ShadowMap_Parameters.x, ShadowMap_Parameters.y, f);\n"
+" return lerp(ShadowMap_Parameters.w, 1.0, f);\n"
"# else\n"
" return f;\n"
"# endif\n"
"# endif\n"
"# endif\n"
"# ifdef USESHADOWMAPORTHO\n"
-" return lerp(ShadowMap_Parameters.x, ShadowMap_Parameters.y, f);\n"
+" return lerp(ShadowMap_Parameters.w, 1.0, f);\n"
"# else\n"
" return f;\n"
"# endif\n"
size = 2*r_shadow_shadowmapmaxsize;
scale = r_shadow_shadowmapping_precision.value;
radius = 0.5f * size / scale;
+
Math_atov(r_shadows_throwdirection.string, shadowdir);
VectorNormalize(shadowdir);
dot1 = DotProduct(r_refdef.view.forward, shadowdir);
void R_DrawModelShadowMaps(void)
{
int i;
- float relativethrowdistance, scale, size, radius, nearclip, farclip, dot1, dot2;
+ float relativethrowdistance, scale, size, radius, nearclip, farclip, bias, dot1, dot2;
entity_render_t *ent;
vec3_t relativelightorigin;
vec3_t relativelightdirection, relativeforward, relativeright;
}
size = 2*r_shadow_shadowmapmaxsize;
-
- r_shadow_shadowmap_parameters[0] = bound(0.0f, 1.0f - r_shadows_darken.value, 1.0f);
- r_shadow_shadowmap_parameters[1] = 1.0f;
- r_shadow_shadowmap_parameters[2] = size;
- r_shadow_shadowmap_parameters[3] = size;
-
scale = r_shadow_shadowmapping_precision.value / size;
radius = 0.5f / scale;
nearclip = -r_shadows_throwdistance.value;
farclip = r_shadows_throwdistance.value;
+ bias = r_shadow_shadowmapping_bias.value * r_shadow_shadowmapping_nearclip.value / (2 * r_shadows_throwdistance.value) * (1024.0f / size);
+
+ r_shadow_shadowmap_parameters[0] = size;
+ r_shadow_shadowmap_parameters[1] = size;
+ r_shadow_shadowmap_parameters[2] = 1.0;
+ r_shadow_shadowmap_parameters[3] = bound(0.0f, 1.0f - r_shadows_darken.value, 1.0f);
+
Math_atov(r_shadows_throwdirection.string, shadowdir);
VectorNormalize(shadowdir);
Math_atov(r_shadows_focus.string, shadowfocus);
Matrix4x4_Concat(&mvpmatrix, &r_refdef.view.viewport.projectmatrix, &r_refdef.view.viewport.viewmatrix);
Matrix4x4_Invert_Full(&invmvpmatrix, &mvpmatrix);
Matrix4x4_CreateScale3(&scalematrix, size, -size, 1);
- Matrix4x4_AdjustOrigin(&scalematrix, 0, size, 0);
+ Matrix4x4_AdjustOrigin(&scalematrix, 0, size, -0.5f * bias);
Matrix4x4_Concat(&texmatrix, &scalematrix, &shadowmatrix);
Matrix4x4_Concat(&r_shadow_shadowmapmatrix, &texmatrix, &invmvpmatrix);