From 291f0b85560cd311a4fd69b67af2bac70828927a Mon Sep 17 00:00:00 2001 From: Mloc Date: Sun, 12 Jul 2015 15:47:13 +0100 Subject: [PATCH] client optimizations for lighting overlays Removes lighting transitions- they don't work with the new system. Greyscale overlays now use BLEND_OVERLAY instead of BLEND_MULTIPLY for better client performance. Light overlays in total darkness are now made invisible. Signed-off-by: Mloc --- code/modules/lighting/_lighting_defs.dm | 1 - code/modules/lighting/lighting_overlay.dm | 44 +++++++++++------------ code/modules/lighting/~lighting_undefs.dm | 1 - 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/code/modules/lighting/_lighting_defs.dm b/code/modules/lighting/_lighting_defs.dm index 57e6cc22d2a..21fdafdaebf 100644 --- a/code/modules/lighting/_lighting_defs.dm +++ b/code/modules/lighting/_lighting_defs.dm @@ -3,7 +3,6 @@ #define LIGHTING_FALLOFF 1 // type of falloff to use for lighting; 1 for circular, 2 for square #define LIGHTING_LAMBERTIAN 1 // use lambertian shading for light sources #define LIGHTING_HEIGHT 1 // height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone -#define LIGHTING_TRANSITIONS 1 // smooth, animated transitions, similar to /tg/station #define LIGHTING_ROUND_VALUE (1 / 128) //Value used to round lumcounts, values smaller than 1/255 don't matter (if they do, thanks sinking points), greater values will make lighting less precise, but in turn increase performance, VERY SLIGHTLY. #define LIGHTING_LAYER 10 // drawing layer for lighting overlays diff --git a/code/modules/lighting/lighting_overlay.dm b/code/modules/lighting/lighting_overlay.dm index a0bba14eebd..a22023d9836 100644 --- a/code/modules/lighting/lighting_overlay.dm +++ b/code/modules/lighting/lighting_overlay.dm @@ -8,7 +8,6 @@ icon_state = "light1" layer = LIGHTING_LAYER invisibility = INVISIBILITY_LIGHTING - blend_mode = BLEND_MULTIPLY color = "#000000" var/lum_r @@ -53,32 +52,31 @@ lighting_update_overlays += src /atom/movable/lighting_overlay/proc/update_overlay() - var/mx = max(lum_r, lum_g, lum_b) - . = 1 // factor - if(mx > 1) - . = 1/mx - #if LIGHTING_TRANSITIONS == 1 - animate(src, - color = rgb(lum_r * 255 * ., lum_g * 255 * ., lum_b * 255 * .), - LIGHTING_INTERVAL - 1 - ) - #else - color = rgb(lum_r * 255 * ., lum_g * 255 * ., lum_b * 255 * .) - #endif - var/turf/T = loc if(istype(T)) //Incase we're not on a turf, pool ourselves, something happened. - if(color != "#000000") - T.luminosity = 1 - else //No light, set the turf's luminosity to 0 to remove it from view() - #if LIGHTING_TRANSITIONS == 1 - spawn(LIGHTING_INTERVAL - 1) + if(lum_r == lum_g && lum_r == lum_b) //greyscale + blend_mode = BLEND_OVERLAY + if(lum_r <= 0) + T.luminosity = 0 + color = "#000000" + alpha = 255 + else + T.luminosity = 1 + color = "#000000" + alpha = (1 - min(lum_r, 1)) * 255 + else + alpha = 255 + var/mx = max(lum_r, lum_g, lum_b) + . = 1 // factor + if(mx > 1) + . = 1/mx + blend_mode = BLEND_MULTIPLY + color = rgb(lum_r * 255 * ., lum_g * 255 * ., lum_b * 255 * .) + if(color != "#000000") + T.luminosity = 1 + else //No light, set the turf's luminosity to 0 to remove it from view() T.luminosity = 0 - #else - T.luminosity = 0 - #endif - else warning("A lighting overlay realised its loc was NOT a turf (actual loc: [loc][loc ? ", " + loc.type : ""]) in update_overlay() and got pooled!") qdel(src) diff --git a/code/modules/lighting/~lighting_undefs.dm b/code/modules/lighting/~lighting_undefs.dm index 9308cc6b65a..772f70557a1 100644 --- a/code/modules/lighting/~lighting_undefs.dm +++ b/code/modules/lighting/~lighting_undefs.dm @@ -3,7 +3,6 @@ #undef LIGHTING_FALLOFF #undef LIGHTING_LAMBERTIAN #undef LIGHTING_HEIGHT -#undef LIGHTING_TRANSITIONS #undef LIGHTING_RESOLUTION #undef LIGHTING_LAYER