From: havoc Date: Fri, 9 Feb 2007 03:22:34 +0000 (+0000) Subject: added back portal culling to rtlights because svbsp code is not working as well as... X-Git-Tag: xonotic-v0.1.0preview~3603 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6eb558bf99ee54e06944b5ef3e87c0a64f0bfe7c;p=xonotic%2Fdarkplaces.git added back portal culling to rtlights because svbsp code is not working as well as it's supposed to git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6811 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rsurf.c b/gl_rsurf.c index 9a848f87..f334200f 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -774,11 +774,24 @@ void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, floa info.pvs = NULL; R_UpdateAllTextureInfo(ent); - // recurse the bsp tree, checking leafs and surfaces for visibility - // optionally using svbsp for exact culling of compiled lights - // (or if the user enables dlight svbsp culling, which is mostly for - // debugging not actual use) - R_Q1BSP_CallRecursiveGetLightInfo(&info, r_shadow_compilingrtlight ? r_shadow_realtime_world_compilesvbsp.integer : r_shadow_realtime_dlight_svbspculling.integer); + if (r_shadow_compilingrtlight && r_shadow_realtime_world_compileportalculling.integer) + { + // use portal recursion for exact light volume culling, and exact surface checking + Portal_Visibility(info.model, info.relativelightorigin, info.outleaflist, info.outleafpvs, &info.outnumleafs, info.outsurfacelist, info.outsurfacepvs, &info.outnumsurfaces, NULL, 0, true, info.lightmins, info.lightmaxs, info.outmins, info.outmaxs); + } + else if (r_shadow_realtime_dlight_portalculling.integer) + { + // use portal recursion for exact light volume culling, but not the expensive exact surface checking + Portal_Visibility(info.model, info.relativelightorigin, info.outleaflist, info.outleafpvs, &info.outnumleafs, info.outsurfacelist, info.outsurfacepvs, &info.outnumsurfaces, NULL, 0, r_shadow_realtime_dlight_portalculling.integer >= 2, info.lightmins, info.lightmaxs, info.outmins, info.outmaxs); + } + else + { + // recurse the bsp tree, checking leafs and surfaces for visibility + // optionally using svbsp for exact culling of compiled lights + // (or if the user enables dlight svbsp culling, which is mostly for + // debugging not actual use) + R_Q1BSP_CallRecursiveGetLightInfo(&info, r_shadow_compilingrtlight ? r_shadow_realtime_world_compilesvbsp.integer : r_shadow_realtime_dlight_svbspculling.integer); + } // limit combined leaf box to light boundaries outmins[0] = max(info.outmins[0] - 1, info.lightmins[0]); diff --git a/r_shadow.c b/r_shadow.c index 93e677e0..e04f8a1d 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -215,6 +215,7 @@ cvar_t r_shadow_frontsidecasting = {0, "r_shadow_frontsidecasting", "1", "whethe cvar_t r_shadow_realtime_dlight = {CVAR_SAVE, "r_shadow_realtime_dlight", "1", "enables rendering of dynamic lights such as explosions and rocket light"}; cvar_t r_shadow_realtime_dlight_shadows = {CVAR_SAVE, "r_shadow_realtime_dlight_shadows", "1", "enables rendering of shadows from dynamic lights"}; cvar_t r_shadow_realtime_dlight_svbspculling = {0, "r_shadow_realtime_dlight_svbspculling", "0", "enables svbsp optimization on dynamic lights (very slow!)"}; +cvar_t r_shadow_realtime_dlight_portalculling = {0, "r_shadow_realtime_dlight_portalculling", "0", "enables portal optimization on dynamic lights (slow!)"}; cvar_t r_shadow_realtime_world = {CVAR_SAVE, "r_shadow_realtime_world", "0", "enables rendering of full world lighting (whether loaded from the map, or a .rtlights file, or a .ent file, or a .lights file produced by hlight)"}; cvar_t r_shadow_realtime_world_dlightshadows = {CVAR_SAVE, "r_shadow_realtime_world_dlightshadows", "1", "enables shadows from dynamic lights when using full world lighting"}; cvar_t r_shadow_realtime_world_lightmaps = {CVAR_SAVE, "r_shadow_realtime_world_lightmaps", "0", "brightness to render lightmaps when using full world lighting, try 0.5 for a tenebrae-like appearance"}; @@ -222,6 +223,7 @@ cvar_t r_shadow_realtime_world_shadows = {CVAR_SAVE, "r_shadow_realtime_world_sh cvar_t r_shadow_realtime_world_compile = {0, "r_shadow_realtime_world_compile", "1", "enables compilation of world lights for higher performance rendering"}; cvar_t r_shadow_realtime_world_compileshadow = {0, "r_shadow_realtime_world_compileshadow", "1", "enables compilation of shadows from world lights for higher performance rendering"}; cvar_t r_shadow_realtime_world_compilesvbsp = {0, "r_shadow_realtime_world_compilesvbsp", "1", "enables svbsp optimization during compilation"}; +cvar_t r_shadow_realtime_world_compileportalculling = {0, "r_shadow_realtime_world_compileportalculling", "1", "enables portal-based culling optimization during compilation"}; cvar_t r_shadow_scissor = {0, "r_shadow_scissor", "1", "use scissor optimization of light rendering (restricts rendering to the portion of the screen affected by the light)"}; cvar_t r_shadow_shadow_polygonfactor = {0, "r_shadow_shadow_polygonfactor", "0", "how much to enlarge shadow volume polygons when rendering (should be 0!)"}; cvar_t r_shadow_shadow_polygonoffset = {0, "r_shadow_shadow_polygonoffset", "1", "how much to push shadow volumes into the distance when rendering, to reduce chances of zfighting artifacts (should not be less than 0)"}; @@ -403,6 +405,7 @@ void R_Shadow_Init(void) Cvar_RegisterVariable(&r_shadow_realtime_dlight); Cvar_RegisterVariable(&r_shadow_realtime_dlight_shadows); Cvar_RegisterVariable(&r_shadow_realtime_dlight_svbspculling); + Cvar_RegisterVariable(&r_shadow_realtime_dlight_portalculling); Cvar_RegisterVariable(&r_shadow_realtime_world); Cvar_RegisterVariable(&r_shadow_realtime_world_dlightshadows); Cvar_RegisterVariable(&r_shadow_realtime_world_lightmaps); @@ -410,6 +413,7 @@ void R_Shadow_Init(void) Cvar_RegisterVariable(&r_shadow_realtime_world_compile); Cvar_RegisterVariable(&r_shadow_realtime_world_compileshadow); Cvar_RegisterVariable(&r_shadow_realtime_world_compilesvbsp); + Cvar_RegisterVariable(&r_shadow_realtime_world_compileportalculling); Cvar_RegisterVariable(&r_shadow_scissor); Cvar_RegisterVariable(&r_shadow_shadow_polygonfactor); Cvar_RegisterVariable(&r_shadow_shadow_polygonoffset); diff --git a/r_shadow.h b/r_shadow.h index 05b72812..ff698d93 100644 --- a/r_shadow.h +++ b/r_shadow.h @@ -18,6 +18,7 @@ extern cvar_t r_shadow_frontsidecasting; extern cvar_t r_shadow_realtime_dlight; extern cvar_t r_shadow_realtime_dlight_shadows; extern cvar_t r_shadow_realtime_dlight_svbspculling; +extern cvar_t r_shadow_realtime_dlight_portalculling; extern cvar_t r_shadow_realtime_world; extern cvar_t r_shadow_realtime_world_dlightshadows; extern cvar_t r_shadow_realtime_world_lightmaps; @@ -25,6 +26,7 @@ extern cvar_t r_shadow_realtime_world_shadows; extern cvar_t r_shadow_realtime_world_compile; extern cvar_t r_shadow_realtime_world_compileshadow; extern cvar_t r_shadow_realtime_world_compilesvbsp; +extern cvar_t r_shadow_realtime_world_compileportalculling; extern cvar_t r_shadow_scissor; extern cvar_t r_shadow_shadow_polygonfactor; extern cvar_t r_shadow_shadow_polygonoffset;