X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=r_shadow.c;h=65955f50d2dd845af9dc523fca94a3a43bf87a7e;hb=27b8e67dec8c8084ba38ed8201dc54ccd46fdb23;hp=e6fda0f5d398178d1042c64f0105b56889740314;hpb=a8d25d8be54fbd3f1a5e63ec8933d3d4d3f2d3d9;p=xonotic%2Fdarkplaces.git diff --git a/r_shadow.c b/r_shadow.c index e6fda0f5..65955f50 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -24,6 +24,7 @@ r_shadow_rendermode_t; typedef enum r_shadow_shadowmode_e { + R_SHADOW_SHADOWMODE_DISABLED, R_SHADOW_SHADOWMODE_SHADOWMAP2D } r_shadow_shadowmode_t; @@ -46,6 +47,8 @@ int r_shadow_readbuffer; #endif int r_shadow_cullface_front, r_shadow_cullface_back; GLuint r_shadow_fbo2d; +int r_shadow_shadowmode_shadowmapping; // cached value of r_shadow_shadowmapping cvar +int r_shadow_shadowmode_deferred; // cached value of r_shadow_deferred cvar r_shadow_shadowmode_t r_shadow_shadowmode; int r_shadow_shadowmapfilterquality; int r_shadow_shadowmapdepthbits; @@ -297,6 +300,8 @@ static void R_Shadow_MakeShadowMap(int texturesize); static void R_Shadow_MakeVSDCT(void); static void R_Shadow_SetShadowMode(void) { + r_shadow_shadowmode_shadowmapping = r_shadow_shadowmapping.integer; + r_shadow_shadowmode_deferred = r_shadow_deferred.integer; r_shadow_shadowmapborder = bound(1, r_shadow_shadowmapping_bordersize.integer, 16); r_shadow_shadowmaptexturesize = bound(256, r_shadow_shadowmapping_texturesize.integer, (int)vid.maxtexturesize_2d); r_shadow_shadowmapmaxsize = bound(r_shadow_shadowmapborder+2, r_shadow_shadowmapping_maxsize.integer, r_shadow_shadowmaptexturesize / 8); @@ -307,32 +312,31 @@ static void R_Shadow_SetShadowMode(void) r_shadow_shadowmapsampler = false; r_shadow_shadowmappcf = 0; r_shadow_shadowmapdepthtexture = r_fb.usedepthtextures; - r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D; - Mod_AllocLightmap_Init(&r_shadow_shadowmapatlas_state, r_main_mempool, r_shadow_shadowmaptexturesize, r_shadow_shadowmaptexturesize); - if (r_shadow_shadowmapping.integer || r_shadow_deferred.integer) + r_shadow_shadowmode = R_SHADOW_SHADOWMODE_DISABLED; + if (r_shadow_shadowmode_shadowmapping || r_shadow_shadowmode_deferred) { - switch(vid.renderpath) + switch (vid.renderpath) { case RENDERPATH_GL32: - if(r_shadow_shadowmapfilterquality < 0) + if (r_shadow_shadowmapfilterquality < 0) { if (!r_fb.usedepthtextures) r_shadow_shadowmappcf = 1; - else if((strstr(gl_vendor, "NVIDIA") || strstr(gl_renderer, "Radeon HD")) && r_shadow_shadowmapshadowsampler) + else if ((strstr(gl_vendor, "NVIDIA") || strstr(gl_renderer, "Radeon HD")) && r_shadow_shadowmapshadowsampler) { r_shadow_shadowmapsampler = true; r_shadow_shadowmappcf = 1; } - else if(vid.support.amd_texture_texture4 || vid.support.arb_texture_gather) + else if (vid.support.amd_texture_texture4 || vid.support.arb_texture_gather) r_shadow_shadowmappcf = 1; - else if((strstr(gl_vendor, "ATI") || strstr(gl_vendor, "Advanced Micro Devices")) && !strstr(gl_renderer, "Mesa") && !strstr(gl_version, "Mesa")) + else if ((strstr(gl_vendor, "ATI") || strstr(gl_vendor, "Advanced Micro Devices")) && !strstr(gl_renderer, "Mesa") && !strstr(gl_version, "Mesa")) r_shadow_shadowmappcf = 1; else r_shadow_shadowmapsampler = r_shadow_shadowmapshadowsampler; } else { - r_shadow_shadowmapsampler = r_shadow_shadowmapshadowsampler; + r_shadow_shadowmapsampler = r_shadow_shadowmapshadowsampler; switch (r_shadow_shadowmapfilterquality) { case 1: @@ -353,10 +357,20 @@ static void R_Shadow_SetShadowMode(void) r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D; break; case RENDERPATH_GLES2: + r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D; break; } } + switch (r_shadow_shadowmode) + { + case R_SHADOW_SHADOWMODE_SHADOWMAP2D: + Mod_AllocLightmap_Init(&r_shadow_shadowmapatlas_state, r_main_mempool, r_shadow_shadowmaptexturesize, r_shadow_shadowmaptexturesize); + break; + case R_SHADOW_SHADOWMODE_DISABLED: + break; + } + if(R_CompileShader_CheckStaticParms()) R_GLSL_Restart_f(&cmd_client); } @@ -367,13 +381,16 @@ qboolean R_Shadow_ShadowMappingEnabled(void) { case R_SHADOW_SHADOWMODE_SHADOWMAP2D: return true; - default: + case R_SHADOW_SHADOWMODE_DISABLED: return false; } + return false; } static void R_Shadow_FreeShadowMaps(void) { + R_Shadow_UncompileWorldLights(); + Mod_AllocLightmap_Free(&r_shadow_shadowmapatlas_state); R_Shadow_SetShadowMode(); @@ -393,6 +410,7 @@ static void R_Shadow_FreeShadowMaps(void) if (r_shadow_shadowmapvsdcttexture) R_FreeTexture(r_shadow_shadowmapvsdcttexture); r_shadow_shadowmapvsdcttexture = NULL; + } static void r_shadow_start(void) @@ -400,7 +418,7 @@ static void r_shadow_start(void) // allocate vertex processing arrays memset(&r_shadow_bouncegrid_state, 0, sizeof(r_shadow_bouncegrid_state)); r_shadow_attenuationgradienttexture = NULL; - r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D; + r_shadow_shadowmode = R_SHADOW_SHADOWMODE_DISABLED; r_shadow_shadowmap2ddepthtexture = NULL; r_shadow_shadowmap2ddepthbuffer = NULL; r_shadow_shadowmapvsdcttexture = NULL; @@ -473,7 +491,6 @@ static void R_Shadow_FreeDeferred(void); static void r_shadow_shutdown(void) { CHECKGLERROR - R_Shadow_UncompileWorldLights(); R_Shadow_FreeShadowMaps(); @@ -1457,8 +1474,8 @@ static void R_Shadow_MakeShadowMap(int texturesize) r_shadow_fbo2d = R_Mesh_CreateFramebufferObject(r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL); } break; - default: - return; + case R_SHADOW_SHADOWMODE_DISABLED: + break; } } @@ -1533,10 +1550,9 @@ static void R_Shadow_SetShadowmapParametersForLight(qboolean noselfshadowpass) static void R_Shadow_RenderMode_ShadowMap(int side, int size, int x, int y) { - float nearclip, farclip, bias; + float nearclip, farclip; r_viewport_t viewport; int flipped; - float clearcolor[4]; if (r_shadow_rendermode != R_SHADOW_RENDERMODE_SHADOWMAP2D) { @@ -1556,7 +1572,6 @@ static void R_Shadow_RenderMode_ShadowMap(int side, int size, int x, int y) 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_Viewport_InitRectSideView(&viewport, &rsurface.rtlight->matrix_lighttoworld, side, size, r_shadow_shadowmapborder, nearclip, farclip, NULL, x, y); R_SetViewport(&viewport); @@ -1565,7 +1580,6 @@ static void R_Shadow_RenderMode_ShadowMap(int side, int size, int x, int y) r_refdef.view.cullface_front = flipped ? r_shadow_cullface_back : r_shadow_cullface_front; r_refdef.view.cullface_back = flipped ? r_shadow_cullface_front : r_shadow_cullface_back; - Vector4Set(clearcolor, 1,1,1,1); if (r_shadow_shadowmap2ddepthbuffer) GL_ColorMask(1,1,1,1); else @@ -2003,9 +2017,9 @@ static void R_Shadow_BounceGrid_AssignPhotons_Task(taskqueue_task_t *t) // is probably fine (and they use the same timer) if (r_shadow_culllights_trace.integer) { - if (rtlight->trace_timer != realtime && R_CanSeeBox(rtlight->trace_timer == 0 ? r_shadow_culllights_trace_tempsamples.integer : r_shadow_culllights_trace_samples.integer, r_shadow_culllights_trace_eyejitter.value, r_shadow_culllights_trace_enlarge.value, r_shadow_culllights_trace_expand.value, r_shadow_culllights_trace_pad.value, r_refdef.view.origin, rtlight->cullmins, rtlight->cullmaxs)) - rtlight->trace_timer = realtime; - if (realtime - rtlight->trace_timer > r_shadow_culllights_trace_delay.value) + if (rtlight->trace_timer != host.realtime && R_CanSeeBox(rtlight->trace_timer == 0 ? r_shadow_culllights_trace_tempsamples.integer : r_shadow_culllights_trace_samples.integer, r_shadow_culllights_trace_eyejitter.value, r_shadow_culllights_trace_enlarge.value, r_shadow_culllights_trace_expand.value, r_shadow_culllights_trace_pad.value, r_refdef.view.origin, rtlight->cullmins, rtlight->cullmaxs)) + rtlight->trace_timer = host.realtime; + if (host.realtime - rtlight->trace_timer > r_shadow_culllights_trace_delay.value) continue; } // skip if expanded light box is offscreen @@ -2070,8 +2084,8 @@ static void R_Shadow_BounceGrid_AssignPhotons_Task(taskqueue_task_t *t) } // compute a seed for the unstable random modes - Math_RandomSeed_FromInts(&randomseed, 0, 0, 0, realtime * 1000.0); - seed = realtime * 1000.0; + Math_RandomSeed_FromInts(&randomseed, 0, 0, 0, host.realtime * 1000.0); + seed = host.realtime * 1000.0; for (lightindex = 0; lightindex < range2; lightindex++) { @@ -2582,10 +2596,10 @@ static void R_Shadow_BounceGrid_ConvertPixelsAndUpload(void) break; } - r_shadow_bouncegrid_state.lastupdatetime = realtime; + r_shadow_bouncegrid_state.lastupdatetime = host.realtime; } -void R_Shadow_BounceGrid_ClearTex_Task(taskqueue_task_t *t) +static void R_Shadow_BounceGrid_ClearTex_Task(taskqueue_task_t *t) { memset(r_shadow_bouncegrid_state.highpixels, 0, r_shadow_bouncegrid_state.numpixels * sizeof(float[4])); t->done = 1; @@ -2790,7 +2804,7 @@ void R_Shadow_UpdateBounceGridTexture(void) } // if all the settings seem identical to the previous update, return - if (r_shadow_bouncegrid_state.texture && (settings.staticmode || realtime < r_shadow_bouncegrid_state.lastupdatetime + r_shadow_bouncegrid_dynamic_updateinterval.value) && !settingschanged) + if (r_shadow_bouncegrid_state.texture && (settings.staticmode || host.realtime < r_shadow_bouncegrid_state.lastupdatetime + r_shadow_bouncegrid_dynamic_updateinterval.value) && !settingschanged) return; // store the new settings @@ -3043,7 +3057,6 @@ void R_RTLight_Compile(rtlight_t *rtlight) // compile the light rtlight->compiled = true; - rtlight->shadowmode = rtlight->shadow ? (int)r_shadow_shadowmode : -1; rtlight->static_numleafs = 0; rtlight->static_numleafpvsbytes = 0; rtlight->static_leaflist = NULL; @@ -3452,12 +3465,8 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight) // all at once at the start of a level, not when it stalls gameplay. // (especially important to benchmarks) // compile light - if (rtlight->isstatic && !nolight && (!rtlight->compiled || (rtlight->shadow && rtlight->shadowmode != (int)r_shadow_shadowmode)) && r_shadow_realtime_world_compile.integer) - { - if (rtlight->compiled) - R_RTLight_Uncompile(rtlight); + if (rtlight->isstatic && !nolight && !rtlight->compiled && r_shadow_realtime_world_compile.integer) R_RTLight_Compile(rtlight); - } // load cubemap rtlight->currentcubemap = rtlight->cubemapname[0] ? R_GetCubemap(rtlight->cubemapname) : r_texture_whitecube; @@ -3468,7 +3477,7 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight) /* if (rtlight->selected) { - f = 2 + sin(realtime * M_PI * 4.0); + f = 2 + sin(host.realtime * M_PI * 4.0); VectorScale(rtlight->currentcolor, f, rtlight->currentcolor); } */ @@ -3491,9 +3500,9 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight) // skip if the light box is not visible to traceline if (r_shadow_culllights_trace.integer) { - if (rtlight->trace_timer != realtime && R_CanSeeBox(rtlight->trace_timer == 0 ? r_shadow_culllights_trace_tempsamples.integer : r_shadow_culllights_trace_samples.integer, r_shadow_culllights_trace_eyejitter.value, r_shadow_culllights_trace_enlarge.value, r_shadow_culllights_trace_expand.value, r_shadow_culllights_trace_pad.value, r_refdef.view.origin, rtlight->cullmins, rtlight->cullmaxs)) - rtlight->trace_timer = realtime; - if (realtime - rtlight->trace_timer > r_shadow_culllights_trace_delay.value) + if (rtlight->trace_timer != host.realtime && R_CanSeeBox(rtlight->trace_timer == 0 ? r_shadow_culllights_trace_tempsamples.integer : r_shadow_culllights_trace_samples.integer, r_shadow_culllights_trace_eyejitter.value, r_shadow_culllights_trace_enlarge.value, r_shadow_culllights_trace_expand.value, r_shadow_culllights_trace_pad.value, r_refdef.view.origin, rtlight->cullmins, rtlight->cullmaxs)) + rtlight->trace_timer = host.realtime; + if (host.realtime - rtlight->trace_timer > r_shadow_culllights_trace_delay.value) return; } @@ -3718,7 +3727,7 @@ static void R_Shadow_DrawLightShadowMaps(rtlight_t *rtlight) { int i; int numsurfaces; - unsigned char *shadowtrispvs, *lighttrispvs, *surfacesides; + unsigned char *shadowtrispvs, *surfacesides; int numlightentities; int numlightentities_noselfshadow; int numshadowentities; @@ -3766,7 +3775,6 @@ static void R_Shadow_DrawLightShadowMaps(rtlight_t *rtlight) shadowentities = rtlight->cached_shadowentities; shadowentities_noselfshadow = rtlight->cached_shadowentities_noselfshadow; shadowtrispvs = rtlight->cached_shadowtrispvs; - lighttrispvs = rtlight->cached_lighttrispvs; surfacelist = rtlight->cached_surfacelist; // make this the active rtlight for rendering purposes @@ -3861,15 +3869,11 @@ static void R_Shadow_DrawLight(rtlight_t *rtlight) { int i; int numsurfaces; - unsigned char *shadowtrispvs, *lighttrispvs; + unsigned char *lighttrispvs; int numlightentities; int numlightentities_noselfshadow; - int numshadowentities; - int numshadowentities_noselfshadow; entity_render_t **lightentities; entity_render_t **lightentities_noselfshadow; - entity_render_t **shadowentities; - entity_render_t **shadowentities_noselfshadow; int *surfacelist; qboolean castshadows; @@ -3887,14 +3891,9 @@ static void R_Shadow_DrawLight(rtlight_t *rtlight) numlightentities = rtlight->cached_numlightentities; numlightentities_noselfshadow = rtlight->cached_numlightentities_noselfshadow; - numshadowentities = rtlight->cached_numshadowentities; - numshadowentities_noselfshadow = rtlight->cached_numshadowentities_noselfshadow; numsurfaces = rtlight->cached_numsurfaces; lightentities = rtlight->cached_lightentities; lightentities_noselfshadow = rtlight->cached_lightentities_noselfshadow; - shadowentities = rtlight->cached_shadowentities; - shadowentities_noselfshadow = rtlight->cached_shadowentities_noselfshadow; - shadowtrispvs = rtlight->cached_shadowtrispvs; lighttrispvs = rtlight->cached_lighttrispvs; surfacelist = rtlight->cached_surfacelist; castshadows = rtlight->castshadows; @@ -3917,20 +3916,11 @@ static void R_Shadow_DrawLight(rtlight_t *rtlight) if (castshadows && r_shadow_shadowmode == R_SHADOW_SHADOWMODE_SHADOWMAP2D) { - float borderbias; - int size; - float shadowmapoffsetnoselfshadow = 0; matrix4x4_t radiustolight = rtlight->matrix_worldtolight; Matrix4x4_Abs(&radiustolight); - size = rtlight->shadowmapatlassidesize; - borderbias = r_shadow_shadowmapborder / (float)(size - r_shadow_shadowmapborder); - //Con_Printf("distance %f lodlinear %i size %i\n", distance, lodlinear, size); - if (rtlight->cached_numshadowentities_noselfshadow) - shadowmapoffsetnoselfshadow = rtlight->shadowmapatlassidesize * 2; - // render lighting using the depth texture as shadowmap // draw lighting in the unmasked areas if (numsurfaces + numlightentities) @@ -4057,7 +4047,7 @@ void R_Shadow_DrawPrepass(void) } #define MAX_SCENELIGHTS 65536 -qboolean R_Shadow_PrepareLights_AddSceneLight(rtlight_t *rtlight) +static qboolean R_Shadow_PrepareLights_AddSceneLight(rtlight_t *rtlight) { if (r_shadow_scenemaxlights <= r_shadow_scenenumlights) { @@ -4085,8 +4075,9 @@ void R_Shadow_PrepareLights(void) int shadowmaptexturesize = bound(256, r_shadow_shadowmapping_texturesize.integer, (int)vid.maxtexturesize_2d); int shadowmapmaxsize = bound(shadowmapborder+2, r_shadow_shadowmapping_maxsize.integer, shadowmaptexturesize / 8); - if (r_shadow_shadowmaptexturesize != shadowmaptexturesize || - !(r_shadow_shadowmapping.integer || r_shadow_deferred.integer) || + if (r_shadow_shadowmode_shadowmapping != r_shadow_shadowmapping.integer || + r_shadow_shadowmode_deferred != r_shadow_deferred.integer || + r_shadow_shadowmaptexturesize != shadowmaptexturesize || r_shadow_shadowmapvsdct != (r_shadow_shadowmapping_vsdct.integer != 0 && vid.renderpath == RENDERPATH_GL32) || r_shadow_shadowmapfilterquality != r_shadow_shadowmapping_filterquality.integer || r_shadow_shadowmapshadowsampler != r_shadow_shadowmapping_useshadowsampler.integer || @@ -4111,17 +4102,17 @@ void R_Shadow_PrepareLights(void) break; } - if (r_shadow_prepass_width != vid.width || r_shadow_prepass_height != vid.height) + if (r_shadow_prepass_width != r_fb.screentexturewidth || r_shadow_prepass_height != r_fb.screentextureheight) { R_Shadow_FreeDeferred(); r_shadow_usingdeferredprepass = true; - r_shadow_prepass_width = vid.width; - r_shadow_prepass_height = vid.height; - r_shadow_prepassgeometrydepthbuffer = R_LoadTextureRenderBuffer(r_shadow_texturepool, "prepassgeometrydepthbuffer", vid.width, vid.height, TEXTYPE_DEPTHBUFFER24); - r_shadow_prepassgeometrynormalmaptexture = R_LoadTexture2D(r_shadow_texturepool, "prepassgeometrynormalmap", vid.width, vid.height, NULL, TEXTYPE_COLORBUFFER32F, TEXF_RENDERTARGET | TEXF_CLAMP | TEXF_ALPHA | TEXF_FORCENEAREST, -1, NULL); - r_shadow_prepasslightingdiffusetexture = R_LoadTexture2D(r_shadow_texturepool, "prepasslightingdiffuse", vid.width, vid.height, NULL, TEXTYPE_COLORBUFFER16F, TEXF_RENDERTARGET | TEXF_CLAMP | TEXF_ALPHA | TEXF_FORCENEAREST, -1, NULL); - r_shadow_prepasslightingspeculartexture = R_LoadTexture2D(r_shadow_texturepool, "prepasslightingspecular", vid.width, vid.height, NULL, TEXTYPE_COLORBUFFER16F, TEXF_RENDERTARGET | TEXF_CLAMP | TEXF_ALPHA | TEXF_FORCENEAREST, -1, NULL); + r_shadow_prepass_width = r_fb.screentexturewidth; + r_shadow_prepass_height = r_fb.screentextureheight; + r_shadow_prepassgeometrydepthbuffer = R_LoadTextureRenderBuffer(r_shadow_texturepool, "prepassgeometrydepthbuffer", r_fb.screentexturewidth, r_fb.screentextureheight, TEXTYPE_DEPTHBUFFER24); + r_shadow_prepassgeometrynormalmaptexture = R_LoadTexture2D(r_shadow_texturepool, "prepassgeometrynormalmap", r_fb.screentexturewidth, r_fb.screentextureheight, NULL, TEXTYPE_COLORBUFFER32F, TEXF_RENDERTARGET | TEXF_CLAMP | TEXF_ALPHA | TEXF_FORCENEAREST, -1, NULL); + r_shadow_prepasslightingdiffusetexture = R_LoadTexture2D(r_shadow_texturepool, "prepasslightingdiffuse", r_fb.screentexturewidth, r_fb.screentextureheight, NULL, TEXTYPE_COLORBUFFER16F, TEXF_RENDERTARGET | TEXF_CLAMP | TEXF_ALPHA | TEXF_FORCENEAREST, -1, NULL); + r_shadow_prepasslightingspeculartexture = R_LoadTexture2D(r_shadow_texturepool, "prepasslightingspecular", r_fb.screentexturewidth, r_fb.screentextureheight, NULL, TEXTYPE_COLORBUFFER16F, TEXF_RENDERTARGET | TEXF_CLAMP | TEXF_ALPHA | TEXF_FORCENEAREST, -1, NULL); // set up the geometry pass fbo (depth + normalmap) r_shadow_prepassgeometryfbo = R_Mesh_CreateFramebufferObject(r_shadow_prepassgeometrydepthbuffer, r_shadow_prepassgeometrynormalmaptexture, NULL, NULL, NULL); @@ -4672,10 +4663,7 @@ void R_Shadow_DrawCoronas(void) rtlight = r_refdef.scene.lights[i]; if (rtlight->corona_visibility <= 0) continue; - if (gl_flashblend.integer) - R_DrawCorona(rtlight, rtlight->corona, rtlight->radius * rtlight->coronasizescale * 2.0f); - else - R_DrawCorona(rtlight, rtlight->corona * r_coronas.value * 0.25f, rtlight->radius * rtlight->coronasizescale); + R_DrawCorona(rtlight, rtlight->corona * r_coronas.value * 0.25f, rtlight->radius * rtlight->coronasizescale); } } @@ -5428,7 +5416,7 @@ static void R_Shadow_EditLights_Edit_f(cmd_state_t *cmd) VectorCopy(r_shadow_selectedlight->color, color); radius = r_shadow_selectedlight->radius; style = r_shadow_selectedlight->style; - if (r_shadow_selectedlight->cubemapname) + if (*r_shadow_selectedlight->cubemapname) strlcpy(cubemapname, r_shadow_selectedlight->cubemapname, sizeof(cubemapname)); else cubemapname[0] = 0; @@ -5963,7 +5951,7 @@ static void R_Shadow_EditLights_CopyInfo_f(cmd_state_t *cmd) VectorCopy(r_shadow_selectedlight->color, r_shadow_bufferlight.color); r_shadow_bufferlight.radius = r_shadow_selectedlight->radius; r_shadow_bufferlight.style = r_shadow_selectedlight->style; - if (r_shadow_selectedlight->cubemapname) + if (*r_shadow_selectedlight->cubemapname) strlcpy(r_shadow_bufferlight.cubemapname, r_shadow_selectedlight->cubemapname, sizeof(r_shadow_bufferlight.cubemapname)); else r_shadow_bufferlight.cubemapname[0] = 0; @@ -6034,21 +6022,21 @@ static void R_Shadow_EditLights_Init(void) Cvar_RegisterVariable(&r_editlights_current_specular); Cvar_RegisterVariable(&r_editlights_current_normalmode); Cvar_RegisterVariable(&r_editlights_current_realtimemode); - Cmd_AddCommand(&cmd_client, "r_editlights_help", R_Shadow_EditLights_Help_f, "prints documentation on console commands and variables in rtlight editing system"); - Cmd_AddCommand(&cmd_client, "r_editlights_clear", R_Shadow_EditLights_Clear_f, "removes all world lights (let there be darkness!)"); - Cmd_AddCommand(&cmd_client, "r_editlights_reload", R_Shadow_EditLights_Reload_f, "reloads rtlights file (or imports from .lights file or .ent file or the map itself)"); - Cmd_AddCommand(&cmd_client, "r_editlights_save", R_Shadow_EditLights_Save_f, "save .rtlights file for current level"); - Cmd_AddCommand(&cmd_client, "r_editlights_spawn", R_Shadow_EditLights_Spawn_f, "creates a light with default properties (let there be light!)"); - Cmd_AddCommand(&cmd_client, "r_editlights_edit", R_Shadow_EditLights_Edit_f, "changes a property on the selected light"); - Cmd_AddCommand(&cmd_client, "r_editlights_editall", R_Shadow_EditLights_EditAll_f, "changes a property on ALL lights at once (tip: use radiusscale and colorscale to alter these properties)"); - Cmd_AddCommand(&cmd_client, "r_editlights_remove", R_Shadow_EditLights_Remove_f, "remove selected light"); - Cmd_AddCommand(&cmd_client, "r_editlights_toggleshadow", R_Shadow_EditLights_ToggleShadow_f, "toggle on/off the shadow option on the selected light"); - Cmd_AddCommand(&cmd_client, "r_editlights_togglecorona", R_Shadow_EditLights_ToggleCorona_f, "toggle on/off the corona option on the selected light"); - Cmd_AddCommand(&cmd_client, "r_editlights_importlightentitiesfrommap", R_Shadow_EditLights_ImportLightEntitiesFromMap_f, "load lights from .ent file or map entities (ignoring .rtlights or .lights file)"); - Cmd_AddCommand(&cmd_client, "r_editlights_importlightsfile", R_Shadow_EditLights_ImportLightsFile_f, "load lights from .lights file (ignoring .rtlights or .ent files and map entities)"); - Cmd_AddCommand(&cmd_client, "r_editlights_copyinfo", R_Shadow_EditLights_CopyInfo_f, "store a copy of all properties (except origin) of the selected light"); - Cmd_AddCommand(&cmd_client, "r_editlights_pasteinfo", R_Shadow_EditLights_PasteInfo_f, "apply the stored properties onto the selected light (making it exactly identical except for origin)"); - Cmd_AddCommand(&cmd_client, "r_editlights_lock", R_Shadow_EditLights_Lock_f, "lock selection to current light, if already locked - unlock"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_help", R_Shadow_EditLights_Help_f, "prints documentation on console commands and variables in rtlight editing system"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_clear", R_Shadow_EditLights_Clear_f, "removes all world lights (let there be darkness!)"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_reload", R_Shadow_EditLights_Reload_f, "reloads rtlights file (or imports from .lights file or .ent file or the map itself)"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_save", R_Shadow_EditLights_Save_f, "save .rtlights file for current level"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_spawn", R_Shadow_EditLights_Spawn_f, "creates a light with default properties (let there be light!)"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_edit", R_Shadow_EditLights_Edit_f, "changes a property on the selected light"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_editall", R_Shadow_EditLights_EditAll_f, "changes a property on ALL lights at once (tip: use radiusscale and colorscale to alter these properties)"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_remove", R_Shadow_EditLights_Remove_f, "remove selected light"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_toggleshadow", R_Shadow_EditLights_ToggleShadow_f, "toggle on/off the shadow option on the selected light"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_togglecorona", R_Shadow_EditLights_ToggleCorona_f, "toggle on/off the corona option on the selected light"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_importlightentitiesfrommap", R_Shadow_EditLights_ImportLightEntitiesFromMap_f, "load lights from .ent file or map entities (ignoring .rtlights or .lights file)"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_importlightsfile", R_Shadow_EditLights_ImportLightsFile_f, "load lights from .lights file (ignoring .rtlights or .ent files and map entities)"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_copyinfo", R_Shadow_EditLights_CopyInfo_f, "store a copy of all properties (except origin) of the selected light"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_pasteinfo", R_Shadow_EditLights_PasteInfo_f, "apply the stored properties onto the selected light (making it exactly identical except for origin)"); + Cmd_AddCommand(CMD_CLIENT, "r_editlights_lock", R_Shadow_EditLights_Lock_f, "lock selection to current light, if already locked - unlock"); }