From bb089668b2283c55d6af035fc5f0b73547bf2b6f Mon Sep 17 00:00:00 2001 From: eihrul Date: Sat, 24 Oct 2009 20:49:47 +0000 Subject: [PATCH] sanity checks on shadowmap size relative to border size git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9398 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_backend.c | 2 -- r_shadow.c | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gl_backend.c b/gl_backend.c index 9ef466a9..f41c975e 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -546,8 +546,6 @@ void R_Viewport_InitCubeSideView(r_viewport_t *v, const matrix4x4_t *cameramatri void R_Viewport_InitRectSideView(r_viewport_t *v, const matrix4x4_t *cameramatrix, int side, int size, int border, float nearclip, float farclip, const float *nearplane) { matrix4x4_t tempmatrix, basematrix; - if (border > size - 2) - border = size - 2; memset(v, 0, sizeof(*v)); v->type = R_VIEWPORTTYPE_PERSPECTIVECUBESIDE; v->cameramatrix = *cameramatrix; diff --git a/r_shadow.c b/r_shadow.c index 938f28e1..000f1c19 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -4189,8 +4189,11 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible) if ((r_shadow_shadowmapmaxsize >> i) > lodlinear) r_shadow_shadowmaplod = i; - size = r_shadow_shadowmode == R_SHADOW_SHADOWMODE_SHADOWMAPCUBESIDE ? r_shadow_shadowmapmaxsize >> r_shadow_shadowmaplod : lodlinear; - size = bound(1, size, r_shadow_shadowmapmaxsize); + if (r_shadow_shadowmode == R_SHADOW_SHADOWMODE_SHADOWMAPCUBESIDE) + size = max(1, r_shadow_shadowmapmaxsize >> r_shadow_shadowmaplod); + else + size = bound(r_shadow_shadowmapborder, lodlinear, r_shadow_shadowmapmaxsize); + borderbias = r_shadow_shadowmapborder / (float)(size - r_shadow_shadowmapborder); if (numsurfaces) -- 2.39.2