diff --git a/code/__defines/lighting.dm b/code/__defines/lighting.dm index 58f2e96b145..0b581cf7801 100644 --- a/code/__defines/lighting.dm +++ b/code/__defines/lighting.dm @@ -10,9 +10,9 @@ #define LIGHTING_HEIGHT 1 // height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone #define LIGHTING_LAYER 10 // drawing layer for lighting overlays -#define LIGHTING_ICON 'icons/effects/lighting_overlay.png' // icon used for lighting shading effects +#define LIGHTING_ICON 'icons/effects/lighting_overlay.dmi' // icon used for lighting shading effects -#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_ROUND_VALUE (1 / 64) //Value used to round lumcounts, values smaller than 1/69 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_SOFT_THRESHOLD 0.05 // If the max of the lighting lumcounts of each spectrum drops below this, disable luminosity on the lighting overlays. diff --git a/code/modules/lighting/lighting_corner.dm b/code/modules/lighting/lighting_corner.dm index 907e7aab8b5..63ce1232535 100644 --- a/code/modules/lighting/lighting_corner.dm +++ b/code/modules/lighting/lighting_corner.dm @@ -98,20 +98,28 @@ lighting_update_corners += src /datum/lighting_corner/proc/update_overlays() - // Cache these values a head of time so 4 individual lighting overlays don't all calculate them individually. + var/lum_r = src.lum_r + var/lum_g = src.lum_g + var/lum_b = src.lum_b var/mx = max(lum_r, lum_g, lum_b) // Scale it so 1 is the strongest lum, if it is above 1. . = 1 // factor if (mx > 1) . = 1 / mx + #if LIGHTING_SOFT_THRESHOLD != 0 else if (mx < LIGHTING_SOFT_THRESHOLD) . = 0 // 0 means soft lighting. - cache_r = lum_r * . || LIGHTING_SOFT_THRESHOLD - cache_g = lum_g * . || LIGHTING_SOFT_THRESHOLD - cache_b = lum_b * . || LIGHTING_SOFT_THRESHOLD - cache_mx = mx + cache_r = round(lum_r * ., LIGHTING_ROUND_VALUE) || LIGHTING_SOFT_THRESHOLD + cache_g = round(lum_g * ., LIGHTING_ROUND_VALUE) || LIGHTING_SOFT_THRESHOLD + cache_b = round(lum_b * ., LIGHTING_ROUND_VALUE) || LIGHTING_SOFT_THRESHOLD + #else + cache_r = round(lum_r * ., LIGHTING_ROUND_VALUE) + cache_g = round(lum_g * ., LIGHTING_ROUND_VALUE) + cache_b = round(lum_b * ., LIGHTING_ROUND_VALUE) + #endif + cache_mx = round(mx, LIGHTING_ROUND_VALUE) for (var/TT in masters) var/turf/T = TT diff --git a/code/modules/lighting/lighting_overlay.dm b/code/modules/lighting/lighting_overlay.dm index 4679d1fafc1..559e3a87f8f 100644 --- a/code/modules/lighting/lighting_overlay.dm +++ b/code/modules/lighting/lighting_overlay.dm @@ -59,16 +59,52 @@ var/max = max(cr.cache_mx, cg.cache_mx, cb.cache_mx, ca.cache_mx) - color = list( - cr.cache_r, cr.cache_g, cr.cache_b, 0, - cg.cache_r, cg.cache_g, cg.cache_b, 0, - cb.cache_r, cb.cache_g, cb.cache_b, 0, - ca.cache_r, ca.cache_g, ca.cache_b, 0, - 0, 0, 0, 1 + var/rr = cr.cache_r + var/rg = cr.cache_g + var/rb = cr.cache_b + + var/gr = cg.cache_r + var/gg = cg.cache_g + var/gb = cg.cache_b + + var/br = cb.cache_r + var/bg = cb.cache_g + var/bb = cb.cache_b + + var/ar = ca.cache_r + var/ag = ca.cache_g + var/ab = ca.cache_b + + #if LIGHTING_SOFT_THRESHOLD != 0 + var/set_luminosity = max > LIGHTING_SOFT_THRESHOLD + #else + // Because of floating points, it won't even be a flat 0. + // This number is mostly arbitrary. + var/set_luminosity = max > 1e-6 + #endif + + if((rr & gr & br & ar) && (rg + gg + bg + ag + rb + gb + bb + ab == 8)) + //anything that passes the first case is very likely to pass the second, and addition is a little faster in this case + icon_state = "transparent" + color = null + else if(!set_luminosity) + icon_state = "dark" + color = null + else + icon_state = null + color = list( + rr, rg, rb, 00, + gr, gg, gb, 00, + br, bg, bb, 00, + ar, ag, ab, 00, + 00, 00, 00, 01 ) - luminosity = max > LIGHTING_SOFT_THRESHOLD + luminosity = set_luminosity +// Variety of overrides so the overlays don't get affected by weird things. +/atom/movable/lighting_overlay/ex_act() + return /atom/movable/lighting_overlay/singularity_act() return diff --git a/icons/effects/lighting_overlay.dmi b/icons/effects/lighting_overlay.dmi new file mode 100644 index 00000000000..51985c0c981 Binary files /dev/null and b/icons/effects/lighting_overlay.dmi differ