Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bloom fx #12521

Merged
merged 6 commits into from
Jun 1, 2024
Merged

Bloom fx #12521

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions code/__defines/__renderer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,31 @@
#define LIGHTING_LAYER 1
#define ABOVE_LIGHTING_LAYER 2

#define EFFECTS_ABOVE_LIGHTING_PLANE 4 // For glowy eyes, laser beams, etc. that shouldn't be affected by darkness
#define LIGHTING_EXPOSURE_PLANE 4

#define LIGHTING_LAMPS_PLANE 6

#define LIGHTING_EMISSIVE_BLOOM_PLANE 7

#define LIGHTING_RENDER_TARGET "*LIGHTING_RENDER_TARGET"

#define EFFECTS_ABOVE_LIGHTING_PLANE 8 // For glowy eyes, laser beams, etc. that shouldn't be affected by darkness
#define EYE_GLOW_LAYER 1
#define BEAM_PROJECTILE_LAYER 2
#define SUPERMATTER_WALL_LAYER 3
#define SPLASH_TEXT_LAYER 4

#define OBFUSCATION_PLANE 5 // AI
#define OBFUSCATION_PLANE 9 // AI

#define FULLSCREEN_PLANE 6 // for fullscreen overlays that do not cover the hud.
#define FULLSCREEN_PLANE 10 // for fullscreen overlays that do not cover the hud.

#define FULLSCREEN_LAYER 0
#define DAMAGE_LAYER 1
#define IMPAIRED_LAYER 2
#define BLIND_LAYER 3
#define CRIT_LAYER 4

#define HUD_PLANE 7
#define HUD_PLANE 11
#define UNDER_HUD_LAYER 0
#define HUD_BASE_LAYER 1
#define HUD_CLICKABLE_LAYER 2
Expand All @@ -168,11 +176,11 @@
#define HUD_HOLOMARKER_LAYER 5
#define HUD_HOLOMARKER_SELF_LAYER 6

#define ABOVE_HUD_PLANE 8
#define ABOVE_HUD_PLANE 12
#define ABOVE_HUD_LAYER 5

/// This plane masks out lighting, to create an "emissive" effect for e.g glowing screens in otherwise dark areas.
#define EMISSIVE_PLANE 10
#define EMISSIVE_PLANE 13
#define EMISSIVE_TARGET "*emissive"
/// The layer you should use when you -really- don't want an emissive overlay to be blocked.
#define EMISSIVE_LAYER_UNBLOCKABLE 9999
Expand All @@ -189,7 +197,9 @@
#define TURF_RENDERER "TURF"
#define GAME_RENDERER "GAME"
#define OBSERVERS_RENDERER "OBSERVERS"
#define LIGHTING_RENDERER "LIGHTING"
#define LIGHTING_RENDERER "LIGHTING"
#define ADDITIVE_LIGHTING_RENDERER "LIGHTING_ADDITIVE"
#define LIGHTING_LAMPS_RENDERER "LIGHTING_LAMPS_RENDERER"
#define ABOVE_LIGHTING_RENDERER "ABOVE_LIGHTING"
#define SCREEN_EFFECTS_RENDERER "SCREEN_EFFECTS"
#define INTERFACE_RENDERER "INTERFACE"
Expand All @@ -201,7 +211,6 @@
#define STEAM_EFFECT_TARGET "*steam"
#define STEAM_COMPOSITE_TARGET "*steamc"
#define OBFUSCATION_RENDERER "OBFUSCATION"

#define SCENE_GROUP_RENDERER "SCENE_GROUP"
#define SCREEN_GROUP_RENDERER "SCREEN_GROUP"
#define FINAL_GROUP_RENDERER "FINAL_GROUP"
Expand Down
127 changes: 127 additions & 0 deletions code/__defines/_render.dm
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/renderer)
1, 1, 1, 1 // Mapping
)
mouse_opacity = MOUSE_OPACITY_UNCLICKABLE
render_target_name = LIGHTING_RENDER_TARGET

/atom/movable/renderer/lighting/Initialize(mapload, mob/owner)
. = ..()
Expand All @@ -198,7 +199,111 @@ INITIALIZE_IMMEDIATE(/atom/movable/renderer)
name = ABOVE_LIGHTING_RENDERER
group = RENDER_GROUP_SCENE
plane = EFFECTS_ABOVE_LIGHTING_PLANE
alpha = 0

/// For BLOOOOM

/atom/movable/renderer/lighting_lamps_renderer
name = LIGHTING_LAMPS_RENDERER
group = RENDER_GROUP_SCENE
plane = LIGHTING_LAMPS_PLANE
relay_blend_mode = BLEND_OVERLAY
appearance_flags = PLANE_MASTER | NO_CLIENT_COLOR

/atom/movable/renderer/lighting_lamps_renderer/Initialize(mapload, mob/owner)
. = ..()
GraphicsUpdate()

/atom/movable/renderer/lighting_lamps_renderer/GraphicsUpdate()
. = ..()
remove_filter("lamps_glow")
remove_filter("lamps_glare")

if(owner?.client)
var/level = owner.get_preference_value("LAMP_GLOW")
var/bloomsize = 0
var/bloomoffset = 0
switch(level)
if(GLOB.PREF_LOW)
bloomsize = 1
bloomoffset = 1
if(GLOB.PREF_MED)
bloomsize = 2
bloomoffset = 2
if(GLOB.PREF_HIGH)
bloomsize = 3
bloomoffset = 3

add_filter("lamps_glow", 1, bloom_filter(threshold = "#aaaaaa", size = bloomsize, offset = bloomoffset, alpha = 100))

if(owner?.client && owner.get_preference_value("LAMP_GLARE") == GLOB.PREF_ENABLED)
add_filter("lamps_glare", 2, radial_blur_filter(size = 0.05))


/atom/movable/renderer/additive_lighting
name = ADDITIVE_LIGHTING_RENDERER
group = RENDER_GROUP_SCENE
plane = LIGHTING_EXPOSURE_PLANE
relay_blend_mode = BLEND_ADD

/atom/movable/renderer/additive_lighting/Initialize(mapload, mob/owner)
. = ..()
GraphicsUpdate()

/atom/movable/renderer/additive_lighting/GraphicsUpdate()
. = ..()

remove_filter("blur_exposure")
alpha = 0

if(owner?.client && owner.get_preference_value("LAMP_EXPOSURE") == GLOB.PREF_ENABLED)
alpha = 255
owner.overlay_fullscreen("lighting_backdrop", /atom/movable/screen/fullscreen/lighting_backdrop)
add_filter("blur_exposure", 1, gauss_blur_filter(20))

/proc/gauss_blur_filter(size)
. = list("type" = "blur")
if(!isnull(size))
.["size"] = size

/proc/radial_blur_filter(size, x, y)
. = list("type" = "radial_blur")
if(!isnull(size))
.["size"] = size
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y

/proc/layering_filter(icon, render_source, x, y, flags, color, transform, blend_mode)
. = list("type" = "layer")
if(!isnull(icon))
.["icon"] = icon
if(!isnull(render_source))
.["render_source"] = render_source
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(color))
.["color"] = color
if(!isnull(flags))
.["flags"] = flags
if(!isnull(transform))
.["transform"] = transform
if(!isnull(blend_mode))
.["blend_mode"] = blend_mode

/proc/bloom_filter(threshold, size, offset, alpha)
. = list("type" = "bloom")
if(!isnull(threshold))
.["threshold"] = threshold
if(!isnull(size))
.["size"] = size
if(!isnull(offset))
.["offset"] = offset
if(!isnull(alpha))
.["alpha"] = alpha

/// Draws full screen visual effects, like pain and bluespace.
/atom/movable/renderer/screen_effects
Expand Down Expand Up @@ -242,6 +347,26 @@ INITIALIZE_IMMEDIATE(/atom/movable/renderer)
group = RENDER_GROUP_FINAL
plane = RENDER_GROUP_SCENE
mouse_opacity = MOUSE_OPACITY_NORMAL
var/renderer_contrast = FALSE
var/val1 = 1
var/val2 = -0.05

/atom/movable/renderer/scene_group/Initialize()
. = ..()
GraphicsUpdate()

/atom/movable/renderer/scene_group/GraphicsUpdate()
if(!renderer_contrast)
remove_filter("fov_matrix")
return

add_filter("fov_matrix", 3, color_matrix_filter(list(val1,val2,val2,0, val2,val1,val2,0, val2,val2,val1,0, 0,0,0,1, 0,0,0,0)))

/proc/color_matrix_filter(matrix/in_matrix, space)
. = list("type" = "color")
.["color"] = in_matrix
if(!isnull(space))
.["space"] = space

/// Render group for stuff OUTSIDE the typical game context - UI, full screen effects, etc.
/atom/movable/renderer/screen_group
Expand Down Expand Up @@ -378,3 +503,5 @@ INITIALIZE_IMMEDIATE(/atom/movable/renderer)
type = "color",
color = GLOB.em_mask_matrix
)
//add_filter("lamps_selfglow_bloom", 1, bloom_filter(threshold = "#aaaaaa", size = 5, offset = 3, alpha = 100))
//add_filter("lamps_glare", 1, radial_blur_filter(size = 0.05))
4 changes: 4 additions & 0 deletions code/__defines/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
#define LIGHTMODE_ALARM "alarm"
#define LIGHTMODE_READY "ready"
#define LIGHTMODE_RADSTORM "radiation_storm"

#define ADDITIVE_LIGHTING_PLANE_ALPHA_MAX 255
#define ADDITIVE_LIGHTING_PLANE_ALPHA_NORMAL 128
#define ADDITIVE_LIGHTING_PLANE_ALPHA_INVISIBLE 0
1 change: 1 addition & 0 deletions code/__defines/sound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
#define SFX_GLASS_KNOCK "glass_knock"
#define SFX_GIB "gib"
#define SFX_CLOWN "clown"
#define SFX_HEELS "heels"
#define SFX_HISS "hiss"
#define SFX_WHISTLE "whistle"
#define SFX_SNORE "snore"
Expand Down
4 changes: 4 additions & 0 deletions code/_global_vars/sfx.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,10 @@ GLOBAL_LIST_INIT(sfx_list, list(
'sound/effects/clownstep1.ogg',
'sound/effects/clownstep2.ogg'
),
SFX_HEELS = list(
'sound/effects/heelsstep1.ogg',
'sound/effects/heelsstep2.ogg'
),
SFX_HISS = list(
'sound/voice/hiss1.ogg',
'sound/voice/hiss2.ogg',
Expand Down
1 change: 1 addition & 0 deletions code/game/dna/dna2_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
H.update_eyes()
H.update_hair()
H.update_facial_hair()
H.update_transform()

return 1
else
Expand Down
54 changes: 51 additions & 3 deletions code/modules/client/preference_setup/global/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ GLOBAL_VAR_CONST(PREF_DARKNESS_INVISIBLE, "Invisible")
GLOBAL_VAR_CONST(PREF_SPLASH_MAPTEXT, "Maptext only")
GLOBAL_VAR_CONST(PREF_SPLASH_CHAT, "Chat only")
GLOBAL_VAR_CONST(PREF_SPLASH_BOTH, "Maptext and chat")
GLOBAL_VAR_CONST(PREF_ENABLED, "Enabled")
GLOBAL_VAR_CONST(PREF_DISABLED, "Disabled")


var/global/list/_client_preferences
var/global/list/_client_preferences_by_key
Expand Down Expand Up @@ -315,9 +318,53 @@ var/global/list/_client_preferences_by_type
options = list(GLOB.PREF_YES, GLOB.PREF_NO)

/datum/client_preference/ambient_occlusion/changed(mob/preference_mob, new_value)
if(preference_mob?.client)
var/atom/movable/renderer/R = preference_mob.renderers[GAME_RENDERER]
R.GraphicsUpdate()
if(isnull(preference_mob.client))
return

var/atom/movable/renderer/R = preference_mob.renderers[GAME_RENDERER]
R.GraphicsUpdate()

/datum/client_preference/glow
description = "Lighting: Lamp Glow"
key = "LAMP_GLOW"
category = PREF_CATEGORY_GRAPHICS
default_value = GLOB.PREF_MED
options = list(GLOB.PREF_OFF, GLOB.PREF_LOW, GLOB.PREF_MED, GLOB.PREF_HIGH)

/datum/client_preference/glow/changed(mob/preference_mob, new_value)
if(isnull(preference_mob.client))
return

var/atom/movable/renderer/R = preference_mob.renderers[LIGHTING_LAMPS_RENDERER]
R.GraphicsUpdate()

/datum/client_preference/glare
description = "Lighting: Lamp Glare"
key = "LAMP_GLARE"
category = PREF_CATEGORY_GRAPHICS
default_value = GLOB.PREF_ENABLED
options = list(GLOB.PREF_ENABLED, GLOB.PREF_DISABLED)

/datum/client_preference/glare/changed(mob/preference_mob, new_value)
if(isnull(preference_mob.client))
return

var/atom/movable/renderer/R = preference_mob.renderers[LIGHTING_LAMPS_RENDERER]
R.GraphicsUpdate()

/datum/client_preference/exposure
description = "Lighting: Lamp Exposure"
key = "LAMP_EXPOSURE"
category = PREF_CATEGORY_GRAPHICS
default_value = GLOB.PREF_ENABLED
options = list(GLOB.PREF_ENABLED, GLOB.PREF_DISABLED)

/datum/client_preference/exposure/changed(mob/preference_mob, new_value)
if(isnull(preference_mob.client))
return

var/atom/movable/renderer/R = preference_mob.renderers[ADDITIVE_LIGHTING_RENDERER]
R.GraphicsUpdate()

/datum/client_preference/graphics_quality
description = "Effects Quality"
Expand Down Expand Up @@ -494,6 +541,7 @@ var/global/list/_client_preferences_by_type
description = "Ghost lighting"
key = "GHOST_DARKVISION"
category = PREF_CATEGORY_GHOST
default_value = GLOB.PREF_DARKNESS_MOSTLY_VISIBLE
options = list(GLOB.PREF_DARKNESS_VISIBLE, GLOB.PREF_DARKNESS_MOSTLY_VISIBLE, GLOB.PREF_DARKNESS_BARELY_VISIBLE, GLOB.PREF_DARKNESS_INVISIBLE)

/********************
Expand Down
4 changes: 4 additions & 0 deletions code/modules/clothing/shoes/heels.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#define TRIP_CHANCE_INCREASE 0.5

/obj/item/clothing/shoes/heels/handle_movement(turf/walking, running)
if(running)
playsound(src, SFX_HEELS, 40, 1)
else
playsound(src, SFX_HEELS, 20, 1)
if(!can_trip())
trip_chance = 0
return
Expand Down
Loading
Loading