Files
Aurora.3/code/modules/rendering/plane_master.dm
T
Matt Atlas cca0dfe7b6 Ports /tg/ and CM planemasters to replace our renderers. (#21458)
Part one of our nefarious plans to destroy lag forever, and also
accomplish some cool shit.

This replaces our renderer system with plane masters, this will also be
used to turn skyboxes into backdrops and thus totally remove skybox
updating lag. Additionally, this will let us manipulate entire planes
very easily to do all sorts of zany shit. All credit goes to the
original coders, this is some seriously cool stuff.

Also fixes some bizarre smoothing behaviour, reduces updateoverlays
calls since now not every single structure in the game tries smoothing
with nothing.

<img width="1349" height="1349" alt="image"
src="https://github.com/user-attachments/assets/9b7cecd7-3c47-448b-9dd8-9b904640bf82"
/>
<img width="1349" height="1349" alt="image"
src="https://github.com/user-attachments/assets/647d75a2-1bff-45ca-ab92-0aea10631afd"
/>

---------

Co-authored-by: Matt Atlas <liermattia@gmail.com>
2025-10-16 11:39:15 +00:00

183 lines
6.4 KiB
Plaintext

/atom/movable/screen/plane_master
screen_loc = "CENTER"
icon_state = "blank"
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
blend_mode = BLEND_OVERLAY
plane = LOWEST_EVER_PLANE
var/show_alpha = 255
var/hide_alpha = 0
//--rendering relay vars--
///integer: what plane we will relay this planes render to
var/render_relay_plane = RENDER_PLANE_GAME
///bool: Whether this plane should get a render target automatically generated
var/generate_render_target = TRUE
///integer: blend mode to apply to the render relay in case you dont want to use the plane_masters blend_mode
var/blend_mode_override
///reference: current relay this plane is utilizing to render
var/obj/render_plane_relay/relay
/atom/movable/screen/plane_master/proc/Show(override)
alpha = override || show_alpha
/atom/movable/screen/plane_master/proc/Hide(override)
alpha = override || hide_alpha
//Why do plane masters need a backdrop sometimes? Read https://secure.byond.com/forum/?post=2141928
//Trust me, you need one. Period. If you don't think you do, you're doing something extremely wrong.
/atom/movable/screen/plane_master/proc/backdrop(mob/mymob)
SHOULD_CALL_PARENT(TRUE)
if(!isnull(render_relay_plane))
relay_render_to_plane(mymob, render_relay_plane)
///Contains most things in the game world
/atom/movable/screen/plane_master/game_world
name = "game world plane master"
plane = GAME_PLANE
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/rendering_plate/game_world/Initialize(mapload, datum/hud/hud_owner)
. = ..()
add_filter("displacer", 1, displacement_map_filter(render_source = DISPLACEMENT_PLATE_RENDER_TARGET, size = 10))
/atom/movable/screen/plane_master/game_world_above
name = "above game world plane master"
plane = ABOVE_GAME_PLANE
/atom/movable/screen/plane_master/ghost
name = "ghost plane master"
plane = GHOST_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
/// Plane master handling display of building roofs. They're meant to become invisible when inside a building.
/atom/movable/screen/plane_master/roof
name = "roof plane master"
plane = ROOF_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/space
name = "space plane master"
plane = SPACE_PLANE
blend_mode = BLEND_OVERLAY
/// Plane master handling skyboxes.
/atom/movable/screen/plane_master/skybox
name = "skybox plane master"
plane = SKYBOX_PLANE
blend_mode = BLEND_MULTIPLY
appearance_flags = PLANE_MASTER
/**
* Plane master handling byond internal blackness
* vars are set as to replicate behavior when rendering to other planes
* do not touch this unless you know what you are doing
*/
/atom/movable/screen/plane_master/blackness
name = "darkness plane master"
plane = BLACKNESS_PLANE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
blend_mode = BLEND_MULTIPLY
appearance_flags = PLANE_MASTER | NO_CLIENT_COLOR | PIXEL_SCALE
//byond internal end
/*!
* This system works by exploiting BYONDs color matrix filter to use layers to handle emissive blockers.
*
* Emissive overlays are pasted with an atom color that converts them to be entirely some specific color.
* Emissive blockers are pasted with an atom color that converts them to be entirely some different color.
* Emissive overlays and emissive blockers are put onto the same plane.
* The layers for the emissive overlays and emissive blockers cause them to mask eachother similar to normal BYOND objects.
* A color matrix filter is applied to the emissive plane to mask out anything that isn't whatever the emissive color is.
* This is then used to alpha mask the lighting plane.
*/
///Contains all lighting objects
/atom/movable/screen/plane_master/lighting
name = "lighting plane master"
plane = LIGHTING_PLANE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
blend_mode = BLEND_MULTIPLY
/atom/movable/screen/plane_master/lighting/Initialize()
. = ..()
add_filter("emissives", 1, alpha_mask_filter(render_source = EMISSIVE_RENDER_TARGET, flags = MASK_INVERSE))
/**
* Handles emissive overlays and emissive blockers.
*/
/atom/movable/screen/plane_master/emissive
name = "emissive plane master"
plane = EMISSIVE_PLANE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_target = EMISSIVE_RENDER_TARGET
render_relay_plane = null
/atom/movable/screen/plane_master/emissive/Initialize()
. = ..()
add_filter("em_block_masking", 1, color_matrix_filter(GLOB.em_mask_matrix))
/atom/movable/screen/plane_master/above_lighting
name = "above lighting plane master"
plane = ABOVE_LIGHTING_PLANE
render_relay_plane = RENDER_PLANE_GAME
/atom/movable/screen/plane_master/runechat
name = "runechat plane master"
plane = RUNECHAT_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/runechat/backdrop(mob/mymob)
. = ..()
remove_filter("AO")
add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA"))
/atom/movable/screen/plane_master/fullscreen
name = "fullscreen alert plane"
plane = FULLSCREEN_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/atom/movable/screen/plane_master/hud
name = "HUD plane"
plane = HUD_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/cinematic
name = "cinematic plane"
plane = CINEMATIC_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/displacement
name = "displacement plane"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
plane = DISPLACEMENT_PLATE_RENDER_LAYER
render_target = DISPLACEMENT_PLATE_RENDER_TARGET
render_relay_plane = null
/atom/movable/screen/plane_master/open_space
name = "open space plane"
plane = OPEN_SPACE_PLANE_END //aurora snowflake: our openspace system works bottom up, not top down like CM's
/atom/movable/screen/plane_master/open_space/Initialize(mapload, offset)
name = "open space plane [offset]"
plane -= offset
. = ..()
add_filter("multizblur", 1, gauss_blur_filter(0.5 + 0.25 * (offset + 1)))
/atom/movable/screen/plane_master/openspace_backdrop
name = "open space plane master"
plane = OPENSPACE_BACKDROP_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_MULTIPLY
alpha = 255
/atom/movable/screen/plane_master/openspace_backdrop/Initialize()
. = ..()
filters = list()
filters += filter(type = "drop_shadow", color = "#04080FAA", size = -10)
filters += filter(type = "drop_shadow", color = "#04080FAA", size = -15)
filters += filter(type = "drop_shadow", color = "#04080FAA", size = -20)