From: vortex Date: Mon, 12 Oct 2009 19:30:54 +0000 (+0000) Subject: Experimental r_shadow_shadowmapping_quality cvar which makes a lightradius-based... X-Git-Tag: xonotic-v0.1.0preview~1302 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=116cb2da1e510ddc5ad6abc7a6ffe3ee926dea0f;p=xonotic%2Fdarkplaces.git Experimental r_shadow_shadowmapping_quality cvar which makes a lightradius-based shadowmap resolution calculation instead of LOD'ed one. Quality 1 will make shadowmapres 200 for light with radius 200, quality 0.5 will make 100 for same light. LOD is used, but in other manner, currently no parms for it. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9332 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/r_shadow.c b/r_shadow.c index 57d7bcea..b0467c28 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -293,6 +293,7 @@ cvar_t r_shadow_shadowmapping_precision = {CVAR_SAVE, "r_shadow_shadowmapping_pr cvar_t r_shadow_shadowmapping_vsdct = {CVAR_SAVE, "r_shadow_shadowmapping_vsdct", "1", "enables use of virtual shadow depth cube texture"}; cvar_t r_shadow_shadowmapping_minsize = {CVAR_SAVE, "r_shadow_shadowmapping_minsize", "32", "shadowmap size limit"}; cvar_t r_shadow_shadowmapping_maxsize = {CVAR_SAVE, "r_shadow_shadowmapping_maxsize", "512", "shadowmap size limit"}; +cvar_t r_shadow_shadowmapping_quality = {CVAR_SAVE, "r_shadow_shadowmapping_quality", "0", "Makes shadowmaps to have initial resolution of this number of pixels per light source radius unit. Like, light with radius 200 will have initial shadowmaps with resolution 200. This overrides default LOD-based shadowmaps resolution formula. Might be good in some situations but futher testing is required."}; cvar_t r_shadow_shadowmapping_lod_bias = {CVAR_SAVE, "r_shadow_shadowmapping_lod_bias", "16", "shadowmap size bias"}; cvar_t r_shadow_shadowmapping_lod_scale = {CVAR_SAVE, "r_shadow_shadowmapping_lod_scale", "128", "shadowmap size scaling parameter"}; cvar_t r_shadow_shadowmapping_bordersize = {CVAR_SAVE, "r_shadow_shadowmapping_bordersize", "4", "shadowmap size bias for filtering"}; @@ -691,6 +692,7 @@ void R_Shadow_Init(void) Cvar_RegisterVariable(&r_shadow_shadowmapping_texturetype); Cvar_RegisterVariable(&r_shadow_shadowmapping_filterquality); Cvar_RegisterVariable(&r_shadow_shadowmapping_precision); + Cvar_RegisterVariable(&r_shadow_shadowmapping_quality); Cvar_RegisterVariable(&r_shadow_shadowmapping_maxsize); Cvar_RegisterVariable(&r_shadow_shadowmapping_minsize); Cvar_RegisterVariable(&r_shadow_shadowmapping_lod_bias); @@ -4156,7 +4158,12 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible) nearestpoint[1] = bound(rtlight->cullmins[1], r_refdef.view.origin[1], rtlight->cullmaxs[1]); nearestpoint[2] = bound(rtlight->cullmins[2], r_refdef.view.origin[2], rtlight->cullmaxs[2]); distance = VectorDistance(nearestpoint, r_refdef.view.origin); - lodlinear = (int)(r_shadow_shadowmapping_lod_bias.value + r_shadow_shadowmapping_lod_scale.value * rtlight->radius / max(1.0f, distance)); + + // VorteX: loosy quality mode, might be good in some situations + if (r_shadow_shadowmapping_quality.value) + lodlinear = ( rtlight->radius * r_shadow_shadowmapping_quality.value ) / pow ( max(1.0f,(distance/rtlight->radius)), 0.5 ); + else + lodlinear = (int)(r_shadow_shadowmapping_lod_bias.value + r_shadow_shadowmapping_lod_scale.value * rtlight->radius / max(1.0f, distance)); lodlinear = bound(r_shadow_shadowmapping_minsize.integer, lodlinear, r_shadow_shadowmapping_maxsize.integer); if (castshadows && (r_shadow_shadowmode == R_SHADOW_SHADOWMODE_SHADOWMAP2D || r_shadow_shadowmode == R_SHADOW_SHADOWMODE_SHADOWMAPRECTANGLE || r_shadow_shadowmode == R_SHADOW_SHADOWMODE_SHADOWMAPCUBESIDE))