mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-01-02 13:34:49 +00:00
Optimizes lighting overlays for slow clients.
Ports https://github.com/tgstation/tgstation/pull/25778 and https://github.com/tgstation/tgstation/pull/25861 * Instead of using color matrix for all overlays, fully dark and fully light use static black and transparant icon states without color matrix. * Also implements LIGHTING_ROUND_VALUE so that lighting values actually will reach 0 or 1.
This commit is contained in:
@@ -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_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_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.
|
#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.
|
||||||
|
|
||||||
|
|||||||
@@ -98,20 +98,28 @@
|
|||||||
lighting_update_corners += src
|
lighting_update_corners += src
|
||||||
|
|
||||||
/datum/lighting_corner/proc/update_overlays()
|
/datum/lighting_corner/proc/update_overlays()
|
||||||
|
|
||||||
// Cache these values a head of time so 4 individual lighting overlays don't all calculate them individually.
|
// 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.
|
var/mx = max(lum_r, lum_g, lum_b) // Scale it so 1 is the strongest lum, if it is above 1.
|
||||||
. = 1 // factor
|
. = 1 // factor
|
||||||
if (mx > 1)
|
if (mx > 1)
|
||||||
. = 1 / mx
|
. = 1 / mx
|
||||||
|
|
||||||
|
#if LIGHTING_SOFT_THRESHOLD != 0
|
||||||
else if (mx < LIGHTING_SOFT_THRESHOLD)
|
else if (mx < LIGHTING_SOFT_THRESHOLD)
|
||||||
. = 0 // 0 means soft lighting.
|
. = 0 // 0 means soft lighting.
|
||||||
|
|
||||||
cache_r = lum_r * . || LIGHTING_SOFT_THRESHOLD
|
cache_r = round(lum_r * ., LIGHTING_ROUND_VALUE) || LIGHTING_SOFT_THRESHOLD
|
||||||
cache_g = lum_g * . || LIGHTING_SOFT_THRESHOLD
|
cache_g = round(lum_g * ., LIGHTING_ROUND_VALUE) || LIGHTING_SOFT_THRESHOLD
|
||||||
cache_b = lum_b * . || LIGHTING_SOFT_THRESHOLD
|
cache_b = round(lum_b * ., LIGHTING_ROUND_VALUE) || LIGHTING_SOFT_THRESHOLD
|
||||||
cache_mx = mx
|
#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)
|
for (var/TT in masters)
|
||||||
var/turf/T = TT
|
var/turf/T = TT
|
||||||
|
|||||||
@@ -59,16 +59,52 @@
|
|||||||
|
|
||||||
var/max = max(cr.cache_mx, cg.cache_mx, cb.cache_mx, ca.cache_mx)
|
var/max = max(cr.cache_mx, cg.cache_mx, cb.cache_mx, ca.cache_mx)
|
||||||
|
|
||||||
color = list(
|
var/rr = cr.cache_r
|
||||||
cr.cache_r, cr.cache_g, cr.cache_b, 0,
|
var/rg = cr.cache_g
|
||||||
cg.cache_r, cg.cache_g, cg.cache_b, 0,
|
var/rb = cr.cache_b
|
||||||
cb.cache_r, cb.cache_g, cb.cache_b, 0,
|
|
||||||
ca.cache_r, ca.cache_g, ca.cache_b, 0,
|
var/gr = cg.cache_r
|
||||||
0, 0, 0, 1
|
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()
|
/atom/movable/lighting_overlay/singularity_act()
|
||||||
return
|
return
|
||||||
|
|||||||
BIN
icons/effects/lighting_overlay.dmi
Normal file
BIN
icons/effects/lighting_overlay.dmi
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Reference in New Issue
Block a user