Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit df044da

Browse files
ThatLingJamieD1
andauthored
Backports several SSlighting improvements: overlay lighting (#17271)
* Backports SSlighting optimizations * Overlay lighting, first version compiles * Change conflicting defines * Sparks and beams dont count towards lumcount * Fix rendering * Various fixes * Fix errors * Fix PDA light 1 * a * Update game_options.txt * Fix plasmaman helmet * Fixes * Glowy changes Co-authored-by: Jamie D <993128+JamieD1@users.noreply.github.com>
1 parent 1504f07 commit df044da

File tree

136 files changed

+1565
-882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1565
-882
lines changed

_maps/RandomRuins/SpaceRuins/bigape.dmm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/area/ruin/powered)
3232
"g" = (
3333
/obj/item/flashlight/lamp/bananalamp{
34-
brightness_on = 10
34+
light_range = 10
3535
},
3636
/obj/structure/table/wood,
3737
/obj/structure/fans/tiny/invisible,

code/__DEFINES/layers.dm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@
107107
#define RAD_TEXT_LAYER 15.1
108108

109109

110-
#define ABOVE_LIGHTING_PLANE 16
111-
#define ABOVE_LIGHTING_LAYER 16
110+
#define O_LIGHTING_VISUAL_PLANE 16
111+
#define O_LIGHTING_VISUAL_LAYER 16
112+
#define O_LIGHTING_VISUAL_RENDER_TARGET "O_LIGHT_VISUAL_PLANE"
113+
114+
#define ABOVE_LIGHTING_PLANE 17
115+
#define ABOVE_LIGHTING_LAYER 17
112116
#define ABOVE_LIGHTING_RENDER_TARGET "ABOVE_LIGHTING_PLANE"
113117

114118
#define FLOOR_OPENSPACE_PLANE 17

code/__DEFINES/lighting.dm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
///Object doesn't use any of the light systems. Should be changed to add a light source to the object.
2+
#define NO_LIGHT_SUPPORT 0
3+
///Light made with the lighting datums, applying a matrix.
4+
#define STATIC_LIGHT 1
5+
///Light made by masking the lighting darkness plane.
6+
#define MOVABLE_LIGHT 2
7+
8+
///Is a movable light source attached to another movable (its loc), meaning that the lighting component should go one level deeper.
9+
#define LIGHT_ATTACHED (1<<0)
10+
11+
///This light doesn't affect turf's lumcount calculations. Set to 1<<15 to ignore conflicts
12+
#define LIGHT_NO_LUMCOUNT (1<<15)
13+
114
//Bay lighting engine shit, not in /code/modules/lighting because BYOND is being shit about it
215
/// frequency, in 1/10ths of a second, of the lighting process
316
#define LIGHTING_INTERVAL 5

code/__DEFINES/machines.dm

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
// channel numbers for power
2-
#define EQUIP 1
3-
#define LIGHT 2
4-
#define ENVIRON 3
5-
#define TOTAL 4 //for total power used only
6-
#define STATIC_EQUIP 5
7-
#define STATIC_LIGHT 6
8-
#define STATIC_ENVIRON 7
1+
// These are indexes in a list, and indexes for "dynamic" and static channels should be kept contiguous
2+
#define AREA_USAGE_EQUIP 1
3+
#define AREA_USAGE_LIGHT 2
4+
#define AREA_USAGE_ENVIRON 3
5+
#define AREA_USAGE_TOTAL 4
6+
#define AREA_USAGE_STATIC_EQUIP 5
7+
#define AREA_USAGE_STATIC_LIGHT 6
8+
#define AREA_USAGE_STATIC_ENVIRON 7
9+
#define AREA_USAGE_LEN AREA_USAGE_STATIC_ENVIRON // largest idx
10+
/// Index of the first dynamic usage channel
11+
#define AREA_USAGE_DYNAMIC_START AREA_USAGE_EQUIP
12+
/// Index of the last dynamic usage channel
13+
#define AREA_USAGE_DYNAMIC_END AREA_USAGE_ENVIRON
14+
/// Index of the first static usage channel
15+
#define AREA_USAGE_STATIC_START AREA_USAGE_STATIC_EQUIP
16+
/// Index of the last static usage channel
17+
#define AREA_USAGE_STATIC_END AREA_USAGE_STATIC_ENVIRON
918

1019
//Power use
1120
#define NO_POWER_USE 0

code/__DEFINES/mobs.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,6 @@
381381

382382
///Define for spawning megafauna instead of a mob for cave gen
383383
#define SPAWN_MEGAFAUNA "bluh bluh huge boss"
384+
385+
///Swarmer flags
386+
#define SWARMER_LIGHT_ON (1<<0)

code/_onclick/hud/plane_master.dm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@
7676

7777
/atom/movable/screen/plane_master/lighting/Initialize()
7878
. = ..()
79-
filters += filter(type="alpha", render_source=EMISSIVE_RENDER_TARGET, flags=MASK_INVERSE)
80-
filters += filter(type="alpha", render_source=EMISSIVE_UNBLOCKABLE_RENDER_TARGET, flags=MASK_INVERSE)
79+
filters += filter(type="alpha", render_source = EMISSIVE_RENDER_TARGET, flags = MASK_INVERSE)
80+
filters += filter(type="alpha", render_source = EMISSIVE_UNBLOCKABLE_RENDER_TARGET, flags = MASK_INVERSE)
81+
filters += filter(type="alpha", render_source = O_LIGHTING_VISUAL_RENDER_TARGET, flags = MASK_INVERSE)
8182

8283
/**
8384
* Things placed on this mask the lighting plane. Doesn't render directly.
@@ -155,3 +156,11 @@
155156
filters = list()
156157
if(istype(mymob) && mymob.client?.prefs?.ambientocclusion)
157158
filters += AMBIENT_OCCLUSION
159+
160+
/atom/movable/screen/plane_master/o_light_visual
161+
name = "overlight light visual plane master"
162+
layer = O_LIGHTING_VISUAL_LAYER
163+
plane = O_LIGHTING_VISUAL_PLANE
164+
render_target = O_LIGHTING_VISUAL_RENDER_TARGET
165+
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
166+
blend_mode = BLEND_MULTIPLY

code/controllers/subsystem/lighting.dm

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
GLOBAL_LIST_EMPTY(lighting_update_lights) // List of lighting sources queued for update.
2-
GLOBAL_LIST_EMPTY(lighting_update_corners) // List of lighting corners queued for update.
3-
GLOBAL_LIST_EMPTY(lighting_update_objects) // List of lighting objects queued for update.
4-
51
SUBSYSTEM_DEF(lighting)
62
name = "Lighting"
73
wait = 2
84
init_order = INIT_ORDER_LIGHTING
95
flags = SS_TICKER
6+
var/static/list/sources_queue = list() // List of lighting sources queued for update.
7+
var/static/list/corners_queue = list() // List of lighting corners queued for update.
8+
var/static/list/objects_queue = list() // List of lighting objects queued for update.
109

1110
loading_points = 6 SECONDS // Yogs -- loading times
1211

1312
/datum/controller/subsystem/lighting/stat_entry(msg)
14-
msg = "L:[GLOB.lighting_update_lights.len]|C:[GLOB.lighting_update_corners.len]|O:[GLOB.lighting_update_objects.len]"
13+
msg = "L:[length(sources_queue)]|C:[length(corners_queue)]|O:[length(objects_queue)]"
1514
return ..()
1615

1716

@@ -34,9 +33,10 @@ SUBSYSTEM_DEF(lighting)
3433
MC_SPLIT_TICK_INIT(3)
3534
if(!init_tick_checks)
3635
MC_SPLIT_TICK
36+
var/list/queue = sources_queue
3737
var/i = 0
38-
for (i in 1 to GLOB.lighting_update_lights.len)
39-
var/datum/light_source/L = GLOB.lighting_update_lights[i]
38+
for (i in 1 to length(queue))
39+
var/datum/light_source/L = queue[i]
4040

4141
L.update_corners()
4242

@@ -47,31 +47,34 @@ SUBSYSTEM_DEF(lighting)
4747
else if (MC_TICK_CHECK)
4848
break
4949
if (i)
50-
GLOB.lighting_update_lights.Cut(1, i+1)
50+
queue.Cut(1, i+1)
5151
i = 0
5252

5353
if(!init_tick_checks)
5454
MC_SPLIT_TICK
5555

56-
for (i in 1 to GLOB.lighting_update_corners.len)
57-
var/datum/lighting_corner/C = GLOB.lighting_update_corners[i]
56+
queue = corners_queue
57+
for (i in 1 to length(queue))
58+
var/datum/lighting_corner/C = queue[i]
5859

60+
C.needs_update = FALSE //update_objects() can call qdel if the corner is storing no data
5961
C.update_objects()
60-
C.needs_update = FALSE
62+
6163
if(init_tick_checks)
6264
CHECK_TICK
6365
else if (MC_TICK_CHECK)
6466
break
6567
if (i)
66-
GLOB.lighting_update_corners.Cut(1, i+1)
68+
queue.Cut(1, i+1)
6769
i = 0
6870

6971

7072
if(!init_tick_checks)
7173
MC_SPLIT_TICK
7274

73-
for (i in 1 to GLOB.lighting_update_objects.len)
74-
var/datum/lighting_object/O = GLOB.lighting_update_objects[i]
75+
queue = objects_queue
76+
for (i in 1 to length(queue))
77+
var/datum/lighting_object/O = queue[i]
7578

7679
if (QDELETED(O))
7780
continue
@@ -83,7 +86,7 @@ SUBSYSTEM_DEF(lighting)
8386
else if (MC_TICK_CHECK)
8487
break
8588
if (i)
86-
GLOB.lighting_update_objects.Cut(1, i+1)
89+
queue.Cut(1, i+1)
8790

8891

8992
/datum/controller/subsystem/lighting/Recover()

0 commit comments

Comments
 (0)