Skip to content

Commit

Permalink
FOV is Dead (Long Live FOV) [MDB IGNORE] (#25600) (#34)
Browse files Browse the repository at this point in the history
* [MIRROR] FOV is Dead (Long Live FOV) [MDB IGNORE] (#25600)

* FOV is Dead (Long Live FOV)

* Update _megafauna.dm

* Update _vehicle.dm

* FOV Hotfix: Actually offsets gameplane render relays

* removes redundant visual_shadow

* removes GAME_PLANE_UPPER references

* Update mob_movement.dm

---------

Co-authored-by: LemonInTheDark <[email protected]>
Co-authored-by: Bloop <[email protected]>
Co-authored-by: Gandalf <[email protected]>

* Disables the FOV visual cue

* Revert "Disables the FOV visual cue"

This reverts commit 6f5785c79e8c5a376da7f347a25bed2a4bb19d29.

* Just disables the mask fov

* Update wind_turbine.dm

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: LemonInTheDark <[email protected]>
Co-authored-by: Gandalf <[email protected]>
  • Loading branch information
4 people authored and Iajret committed Jan 3, 2024
1 parent a06249a commit 345defd
Show file tree
Hide file tree
Showing 90 changed files with 216 additions and 315 deletions.
60 changes: 28 additions & 32 deletions code/__DEFINES/layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,31 @@
//KEEP THESE IN A NICE ACSCENDING ORDER, PLEASE

//NEVER HAVE ANYTHING BELOW THIS PLANE ADJUST IF YOU NEED MORE SPACE
#define LOWEST_EVER_PLANE -100
#define LOWEST_EVER_PLANE -50

#define FIELD_OF_VISION_BLOCKER_PLANE -90
// Doesn't really layer, just throwing this in here cause it's the best place imo
#define FIELD_OF_VISION_BLOCKER_PLANE -45
#define FIELD_OF_VISION_BLOCKER_RENDER_TARGET "*FIELD_OF_VISION_BLOCKER_RENDER_TARGET"

#define CLICKCATCHER_PLANE -80
#define CLICKCATCHER_PLANE -40

#define PLANE_SPACE -25
#define PLANE_SPACE -21
#define PLANE_SPACE_PARALLAX -20

#define GRAVITY_PULSE_PLANE -13
#define GRAVITY_PULSE_PLANE -12
#define GRAVITY_PULSE_RENDER_TARGET "*GRAVPULSE_RENDER_TARGET"

#define RENDER_PLANE_TRANSPARENT -12 //Transparent plane that shows openspace underneath the floor
#define RENDER_PLANE_TRANSPARENT -11 //Transparent plane that shows openspace underneath the floor

#define TRANSPARENT_FLOOR_PLANE -11
#define TRANSPARENT_FLOOR_PLANE -10

#define FLOOR_PLANE -10

#define WALL_PLANE -9
#define GAME_PLANE -8
#define GAME_PLANE_FOV_HIDDEN -7
#define GAME_PLANE_UPPER -6
#define WALL_PLANE_UPPER -5
#define GAME_PLANE_UPPER_FOV_HIDDEN -4
#define FLOOR_PLANE -6

#define WALL_PLANE -5
#define GAME_PLANE -4
#define ABOVE_GAME_PLANE -3
///Slightly above the game plane but does not catch mouse clicks. Useful for certain visuals that should be clicked through, like seethrough trees
#define SEETHROUGH_PLANE -3
#define ABOVE_GAME_PLANE -2
#define SEETHROUGH_PLANE -2

#define RENDER_PLANE_GAME_WORLD -1

Expand Down Expand Up @@ -91,31 +87,36 @@

//-------------------- HUD ---------------------
//HUD layer defines
#define HUD_PLANE 40
#define ABOVE_HUD_PLANE 41
#define HUD_PLANE 35
#define ABOVE_HUD_PLANE 36

///Plane of the "splash" icon used that shows on the lobby screen
#define SPLASHSCREEN_PLANE 50
#define SPLASHSCREEN_PLANE 37

// The largest plane here must still be less than RENDER_PLANE_GAME

//-------------------- Rendering ---------------------
#define RENDER_PLANE_GAME 100
#define RENDER_PLANE_NON_GAME 101
#define RENDER_PLANE_GAME 40
/// If fov is enabled we'll draw game to this and do shit to it
#define RENDER_PLANE_GAME_MASKED 41
/// The bit of the game plane that is let alone is sent here
#define RENDER_PLANE_GAME_UNMASKED 42
#define RENDER_PLANE_NON_GAME 45

// Only VERY special planes should be here, as they are above not just the game, but the UI planes as well.

/// Plane related to the menu when pressing Escape.
/// Needed so that we can apply a blur effect to EVERYTHING, and guarantee we are above all UI.
#define ESCAPE_MENU_PLANE 105
#define ESCAPE_MENU_PLANE 46

#define RENDER_PLANE_MASTER 110
#define RENDER_PLANE_MASTER 50

// Lummox I swear to god I will find you
// NOTE! You can only ever have planes greater then -10000, if you add too many with large offsets you will brick multiz
// Same can be said for large multiz maps. Tread carefully mappers
#define HIGHEST_EVER_PLANE RENDER_PLANE_MASTER
/// The range unique planes can be in
/// Try and keep this to a nice whole number, so it's easy to look at a plane var and know what's going on
#define PLANE_RANGE (HIGHEST_EVER_PLANE - LOWEST_EVER_PLANE)

// PLANE_SPACE layer(s)
Expand Down Expand Up @@ -188,8 +189,6 @@
#define NOT_HIGH_OBJ_LAYER 3.5
#define HIGH_OBJ_LAYER 3.6
#define BELOW_MOB_LAYER 3.7

// GAME_PLANE_FOV_HIDDEN layers
#define LOW_MOB_LAYER 3.75
#define LYING_MOB_LAYER 3.8
#define VEHICLE_LAYER 3.9
Expand All @@ -199,21 +198,16 @@
#define MOB_ABOVE_PIGGYBACK_LAYER 4.06
#define MOB_UPPER_LAYER 4.07
#define HITSCAN_PROJECTILE_LAYER 4.09 //above all mob but still hidden by FoV

// GAME_PLANE_UPPER layers
#define ABOVE_MOB_LAYER 4.1
#define WALL_OBJ_LAYER 4.25
#define TRAM_SIGNAL_LAYER 4.26
// WALL_PLANE_UPPER layers
#define EDGED_TURF_LAYER 4.3
#define ON_EDGED_TURF_LAYER 4.35

// GAME_PLANE_UPPER_FOV_HIDDEN layers
#define SPACEVINE_LAYER 4.4
#define LARGE_MOB_LAYER 4.5
#define SPACEVINE_MOB_LAYER 4.6

// Intermediate layer used by both GAME_PLANE_FOV_HIDDEN and ABOVE_GAME_PLANE
// Intermediate layer used by both GAME_PLANE and ABOVE_GAME_PLANE
#define ABOVE_ALL_MOB_LAYER 4.7

// ABOVE_GAME_PLANE layers
Expand All @@ -229,6 +223,8 @@
*/
#define WATER_VISUAL_OVERLAY_LAYER 1000

// SEETHROUGH_PLANE layers here, tho it has no layer values

//---------- LIGHTING -------------

// LIGHTING_PLANE layers
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
// Being close enough to the supermatter makes it heal at higher temperatures
// and emit less heat. Present on /mob or /datum/mind
#define TRAIT_SUPERMATTER_SOOTHER "supermatter_soother"
/// Mob has fov applied to it
#define TRAIT_FOV_APPLIED "fov_applied"

/// Trait added when a revenant is visible.
#define TRAIT_REVENANT_REVEALED "revenant_revealed"
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_FORBID_MINING_SHUTTLE_CONSOLE_OUTSIDE_STATION" = TRAIT_FORBID_MINING_SHUTTLE_CONSOLE_OUTSIDE_STATION,
"TRAIT_FORCED_GRAVITY" = TRAIT_FORCED_GRAVITY,
"TRAIT_FORCED_STANDING" = TRAIT_FORCED_STANDING,
"TRAIT_FOV_APPLIED" = TRAIT_FOV_APPLIED,
"TRAIT_FREE_FLOAT_MOVEMENT" = TRAIT_FREE_FLOAT_MOVEMENT,
"TRAIT_FREE_HYPERSPACE_MOVEMENT" = TRAIT_FREE_HYPERSPACE_MOVEMENT,
"TRAIT_FREE_HYPERSPACE_SOFTCORDON_MOVEMENT" = TRAIT_FREE_HYPERSPACE_SOFTCORDON_MOVEMENT,
Expand Down
105 changes: 41 additions & 64 deletions code/_onclick/hud/rendering/plane_masters/plane_master_subtypes.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
/atom/movable/screen/plane_master/field_of_vision_blocker
name = "Field of vision blocker"
documentation = "This is one of those planes that's only used as a filter. It cuts out a portion of the game plate and does effects to it."
plane = FIELD_OF_VISION_BLOCKER_PLANE
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
render_target = FIELD_OF_VISION_BLOCKER_RENDER_TARGET
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_relay_planes = list()
// We do NOT allow offsetting, because there's no case where you would want to block only one layer, at least currently
allows_offsetting = FALSE
// We mark as multiz_scaled FALSE so transforms don't effect us, and we draw to the planes below us as if they were us.
// This is safe because we will ALWAYS be on the top z layer, so it DON'T MATTER
multiz_scaled = FALSE

/atom/movable/screen/plane_master/field_of_vision_blocker/show_to(mob/mymob)
. = ..()
if(!. || !mymob)
return .
RegisterSignal(mymob, SIGNAL_ADDTRAIT(TRAIT_FOV_APPLIED), PROC_REF(fov_enabled), override = TRUE)
RegisterSignal(mymob, SIGNAL_REMOVETRAIT(TRAIT_FOV_APPLIED), PROC_REF(fov_disabled), override = TRUE)
if(HAS_TRAIT(mymob, TRAIT_FOV_APPLIED))
fov_enabled(mymob)
else
fov_disabled(mymob)

/atom/movable/screen/plane_master/field_of_vision_blocker/proc/fov_enabled(mob/source)
SIGNAL_HANDLER
if(force_hidden == FALSE)
return
unhide_plane(source)

/atom/movable/screen/plane_master/field_of_vision_blocker/proc/fov_disabled(mob/source)
SIGNAL_HANDLER
hide_plane(source)

/atom/movable/screen/plane_master/clickcatcher
name = "Click Catcher"
documentation = "Contains the screen object we use as a backdrop to catch clicks on portions of the screen that would otherwise contain nothing else. \
Expand Down Expand Up @@ -168,69 +203,17 @@
add_relay_to(GET_NEW_PLANE(EMISSIVE_RENDER_PLATE, offset), relay_layer = EMISSIVE_WALL_LAYER, relay_color = GLOB.em_block_color)

/atom/movable/screen/plane_master/game
name = "Lower game world"
documentation = "Exists mostly because of FOV shit. Basically, if you've just got a normal not ABOVE fov thing, and you don't want it masked, stick it here yeah?"
name = "Game"
documentation = "Holds most non floor/wall things. Anything on this plane \"wants\" to interlayer depending on position."
plane = GAME_PLANE
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)

/atom/movable/screen/plane_master/game_world_fov_hidden
name = "lower game world fov hidden"
documentation = "If you want something to be hidden by fov, stick it on this plane. We're masked by the fov blocker plane, so the items on us can actually well, disappear."
plane = GAME_PLANE_FOV_HIDDEN
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)

/atom/movable/screen/plane_master/game_world_fov_hidden/Initialize(mapload, datum/hud/hud_owner)
. = ..()
add_filter("vision_cone", 1, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(FIELD_OF_VISION_BLOCKER_RENDER_TARGET, offset), flags = MASK_INVERSE))

/atom/movable/screen/plane_master/field_of_vision_blocker
name = "Field of vision blocker"
documentation = "This is one of those planes that's only used as a filter. It masks out things that want to be hidden by fov.\
<br>Literally just contains FOV images, or masks."
plane = FIELD_OF_VISION_BLOCKER_PLANE
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
render_target = FIELD_OF_VISION_BLOCKER_RENDER_TARGET
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_relay_planes = list()
// We do NOT allow offsetting, because there's no case where you would want to block only one layer, at least currently
allows_offsetting = FALSE
start_hidden = TRUE
// We mark as multiz_scaled FALSE so transforms don't effect us, and we draw to the planes below us as if they were us.
// This is safe because we will ALWAYS be on the top z layer, so it DON'T MATTER
multiz_scaled = FALSE

/atom/movable/screen/plane_master/field_of_vision_blocker/Initialize(mapload, datum/hud/hud_owner, datum/plane_master_group/home, offset)
. = ..()
mirror_parent_hidden()

/atom/movable/screen/plane_master/game_world_upper
name = "Upper game world"
documentation = "Ok so fov is kinda fucky, because planes in byond serve both as effect groupings and as rendering orderers. Since that's true, we need a plane that we can stick stuff that draws above fov blocked stuff on."
plane = GAME_PLANE_UPPER
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)

/atom/movable/screen/plane_master/wall_upper
name = "Upper wall"
documentation = "There are some walls that want to render above most things (mostly minerals since they shift over.\
<br>We draw them to their own plane so we can hijack them for our emissive mask stuff"
plane = WALL_PLANE_UPPER
render_relay_planes = list(RENDER_PLANE_GAME_WORLD, LIGHT_MASK_PLANE)

/atom/movable/screen/plane_master/wall_upper/Initialize(mapload, datum/hud/hud_owner, datum/plane_master_group/home, offset)
. = ..()
add_relay_to(GET_NEW_PLANE(EMISSIVE_RENDER_PLATE, offset), relay_layer = EMISSIVE_WALL_LAYER, relay_color = GLOB.em_block_color)

/atom/movable/screen/plane_master/game_world_upper_fov_hidden
name = "Upper game world fov hidden"
documentation = "Just as we need a place to draw things \"above\" the hidden fov plane, we also need to be able to hide stuff that draws over the upper game plane."
plane = GAME_PLANE_UPPER_FOV_HIDDEN
/atom/movable/screen/plane_master/game_world_above
name = "Upper Game"
documentation = "For stuff you want to draw like the game plane, but not ever below its contents"
plane = ABOVE_GAME_PLANE
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)

/atom/movable/screen/plane_master/game_world_upper_fov_hidden/Initialize(mapload, datum/hud/hud_owner)
. = ..()
// Dupe of the other hidden plane
add_filter("vision_cone", 1, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(FIELD_OF_VISION_BLOCKER_RENDER_TARGET, offset), flags = MASK_INVERSE))

/atom/movable/screen/plane_master/seethrough
name = "Seethrough"
documentation = "Holds the seethrough versions (done using image overrides) of large objects. Mouse transparent, so you can click through them."
Expand All @@ -239,12 +222,6 @@
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)
start_hidden = TRUE

/atom/movable/screen/plane_master/game_world_above
name = "Above game world"
documentation = "We need a place that's unmasked by fov that also draws above the upper game world fov hidden plane. I told you fov was hacky man."
plane = ABOVE_GAME_PLANE
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)

/**
* Plane master that byond will by default draw to
* Shouldn't be used, exists to prevent people using plane 0
Expand Down
95 changes: 93 additions & 2 deletions code/_onclick/hud/rendering/render_plate.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
/atom/movable/screen/plane_master/rendering_plate/game_plate
name = "Game rendering plate"
documentation = "Holds all objects that are ahhh, in character? is maybe the best way to describe it.\
<br>We apply a displacement effect from the gravity pulse plane too, so we can warp the game world."
<br>We apply a displacement effect from the gravity pulse plane too, so we can warp the game world.\
<br>If we have fov enabled we'll relay this onto two different rendering plates to apply fov effects to only a portion. If not, we just draw straight to master"
plane = RENDER_PLANE_GAME
render_relay_planes = list(RENDER_PLANE_MASTER)

Expand All @@ -84,6 +85,97 @@
// We're basically using alpha as better constant here btw
add_filter("spook_color", 2, color_matrix_filter(list(0.75,0.13,0.13,0, 0.13,0.7,0.13,0, 0.13,0.13,0.75,0, -0.06,-0.09,-0.08,1, 0,0,0,0)))

/atom/movable/screen/plane_master/rendering_plate/game_plate/show_to(mob/mymob)
. = ..()
if(!. || !mymob)
return .
RegisterSignal(mymob, SIGNAL_ADDTRAIT(TRAIT_FOV_APPLIED), PROC_REF(fov_enabled), override = TRUE)
RegisterSignal(mymob, SIGNAL_REMOVETRAIT(TRAIT_FOV_APPLIED), PROC_REF(fov_disabled), override = TRUE)
if(HAS_TRAIT(mymob, TRAIT_FOV_APPLIED))
fov_enabled(mymob)
else
fov_disabled(mymob)

/atom/movable/screen/plane_master/rendering_plate/game_plate/proc/fov_enabled(mob/source)
SIGNAL_HANDLER
add_relay_to(GET_NEW_PLANE(RENDER_PLANE_GAME_UNMASKED, offset))
add_relay_to(GET_NEW_PLANE(RENDER_PLANE_GAME_MASKED, offset))
remove_relay_from(GET_NEW_PLANE(RENDER_PLANE_MASTER, offset))

/atom/movable/screen/plane_master/rendering_plate/game_plate/proc/fov_disabled(mob/source)
SIGNAL_HANDLER
remove_relay_from(GET_NEW_PLANE(RENDER_PLANE_GAME_UNMASKED, offset))
remove_relay_from(GET_NEW_PLANE(RENDER_PLANE_GAME_MASKED, offset))
add_relay_to(GET_NEW_PLANE(RENDER_PLANE_MASTER, offset))

///renders the parts of the plate unmasked by fov
/atom/movable/screen/plane_master/rendering_plate/unmasked_game_plate
name = "Unmasked Game rendering plate"
documentation = "Holds the bits of the game plate that aren't impacted by fov.\
<br>We use an alpha mask to cut out the bits we plan on dealing with elsewhere"
plane = RENDER_PLANE_GAME_UNMASKED
render_relay_planes = list(RENDER_PLANE_MASTER)

/atom/movable/screen/plane_master/rendering_plate/unmasked_game_plate/Initialize(mapload, datum/hud/hud_owner, datum/plane_master_group/home, offset)
. = ..()
add_filter("fov_handled", 1, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(FIELD_OF_VISION_BLOCKER_RENDER_TARGET, offset), flags = MASK_INVERSE))

/atom/movable/screen/plane_master/rendering_plate/unmasked_game_plate/show_to(mob/mymob)
. = ..()
if(!. || !mymob)
return .
RegisterSignal(mymob, SIGNAL_ADDTRAIT(TRAIT_FOV_APPLIED), PROC_REF(fov_enabled), override = TRUE)
RegisterSignal(mymob, SIGNAL_REMOVETRAIT(TRAIT_FOV_APPLIED), PROC_REF(fov_disabled), override = TRUE)
if(HAS_TRAIT(mymob, TRAIT_FOV_APPLIED))
fov_enabled(mymob)
else
fov_disabled(mymob)

/atom/movable/screen/plane_master/rendering_plate/unmasked_game_plate/proc/fov_enabled(mob/source)
SIGNAL_HANDLER
if(force_hidden == FALSE)
return
unhide_plane(source)

/atom/movable/screen/plane_master/rendering_plate/unmasked_game_plate/proc/fov_disabled(mob/source)
SIGNAL_HANDLER
hide_plane(source)

///renders the parts of the plate masked by fov
/atom/movable/screen/plane_master/rendering_plate/masked_game_plate
name = "FOV Game rendering plate"
documentation = "Contains the bits of the game plate that are hidden by some form of fov\
<br>Applies a color matrix to dim and create contrast, alongside a blur. Goal is only half being able to see stuff"
plane = RENDER_PLANE_GAME_MASKED
render_relay_planes = list(RENDER_PLANE_MASTER)

/atom/movable/screen/plane_master/rendering_plate/masked_game_plate/Initialize(mapload, datum/hud/hud_owner, datum/plane_master_group/home, offset)
. = ..()
add_filter("fov_blur", 1, gauss_blur_filter(1.8))
add_filter("fov_handled_space", 2, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(FIELD_OF_VISION_BLOCKER_RENDER_TARGET, offset)))
add_filter("fov_matrix", 3, color_matrix_filter(list(0.5,-0.15,-0.15,0, -0.15,0.5,-0.15,0, -0.15,-0.15,0.5,0, 0,0,0,1, 0,0,0,0)))

/atom/movable/screen/plane_master/rendering_plate/masked_game_plate/show_to(mob/mymob)
. = ..()
if(!. || !mymob)
return .
RegisterSignal(mymob, SIGNAL_ADDTRAIT(TRAIT_FOV_APPLIED), PROC_REF(fov_enabled), override = TRUE)
RegisterSignal(mymob, SIGNAL_REMOVETRAIT(TRAIT_FOV_APPLIED), PROC_REF(fov_disabled), override = TRUE)
if(HAS_TRAIT(mymob, TRAIT_FOV_APPLIED))
fov_enabled(mymob)
else
fov_disabled(mymob)

/atom/movable/screen/plane_master/rendering_plate/masked_game_plate/proc/fov_enabled(mob/source)
SIGNAL_HANDLER
if(force_hidden == FALSE)
return
unhide_plane(source)

/atom/movable/screen/plane_master/rendering_plate/masked_game_plate/proc/fov_disabled(mob/source)
SIGNAL_HANDLER
hide_plane(source)

// Blackness renders weird when you view down openspace, because of transforms and borders and such
// This is a consequence of not using lummy's grouped transparency, but I couldn't get that to work without totally fucking up
// Sight flags, and shooting vis_contents usage to the moon. So we're doin it different.
Expand Down Expand Up @@ -293,7 +385,6 @@
plane = RENDER_PLANE_NON_GAME
render_relay_planes = list(RENDER_PLANE_MASTER)


/**
* Plane master proc called in Initialize() that creates relay objects, and sets them uo as needed
* Sets:
Expand Down
Loading

0 comments on commit 345defd

Please sign in to comment.