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

[PORT] Bloom, Glare and exposure from TauCeti #605

Merged
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
5 changes: 5 additions & 0 deletions code/__DEFINES/layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@
//---------- LIGHTING -------------
///Normal 1 per turf dynamic lighting underlays
#define LIGHTING_PLANE 100
#define LIGHTING_EXPOSURE_PLANE 101 // Light sources "cones"
#define LIGHTING_LAMPS_SELFGLOW 102 // Light sources glow (lamps, doors overlay, etc.)
#define LIGHTING_LAMPS_PLANE 103 // Light sources themselves (lamps, screens, etc.)
#define LIGHTING_LAMPS_GLARE 104 // Light glare (optional setting)
#define LIGHTING_LAMPS_RENDER_TARGET "*LIGHTING_LAMPS_RENDER_TARGET"

///Lighting objects that are "free floating"
#define O_LIGHTING_VISUAL_PLANE 110
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,8 @@ GLOBAL_LIST_EMPTY(all_loadout_datums)
/// just so we can ensure it is loaded regardless of whether someone opens the loadout UI
/// (because it also inits our loadout datums)
GLOBAL_LIST_INIT(loadout_categories, init_loadout_categories())

#define BLOOM_HIGH 0
#define BLOOM_MED 1 //default.
#define BLOOM_LOW 2
#define BLOOM_DISABLE 3 //this option must be the highest number
11 changes: 11 additions & 0 deletions code/__HELPERS/filters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,14 @@ GLOBAL_LIST_INIT(master_filter_info, list(
filter = in_atom.get_filter("wibbly-[i]")
animate(filter)
in_atom.remove_filter("wibbly-[i]")

/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
201 changes: 201 additions & 0 deletions code/__HELPERS/matrices.dm
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,204 @@ round(cos_inv_third+sqrt3_sin, 0.001), round(cos_inv_third-sqrt3_sin, 0.001), ro
power++ //Transfer to output, increment power, repeat until the input pile is all used

return output

/datum/ColorMatrix
var/list/matrix
var/combined = 1
var/const/lumR = 0.3086 // or 0.2125
var/const/lumG = 0.6094 // or 0.7154
var/const/lumB = 0.0820 // or 0.0721

/datum/ColorMatrix/New(mat, contrast = 1, brightness = null)
..()

if(istext(mat))
SetPreset(mat)
if(!matrix)
SetColor(mat, contrast, brightness)
else if(isnum(mat))
SetSaturation(mat, contrast, brightness)
else
matrix = mat

/datum/ColorMatrix/proc/Reset()
matrix = list(1,0,0,
0,1,0,
0,0,1)

/datum/ColorMatrix/proc/Get(contrast = 1)
var/list/mat = matrix
mat = mat.Copy()

for(var/i = 1 to min(mat.len, 12))
mat[i] *= contrast

return mat

/datum/ColorMatrix/proc/SetSaturation(s, c = 1, b = null)
var/sr = (1 - s) * lumR
var/sg = (1 - s) * lumG
var/sb = (1 - s) * lumB

matrix = list(c * (sr + s), c * (sr), c * (sr),
c * (sg), c * (sg + s), c * (sg),
c * (sb), c * (sb), c * (sb + s))

SetBrightness(b)

/datum/ColorMatrix/proc/SetBrightness(brightness)
if(brightness == null) return

if(!matrix)
Reset()


if(matrix.len == 9 || matrix.len == 16)
matrix += brightness
matrix += brightness
matrix += brightness

if(matrix.len == 16)
matrix += 0

else if(matrix.len == 12)
for(var/i = matrix.len to matrix.len - 3 step -1)
matrix[i] = brightness

else if(matrix.len == 3)
for(var/i = matrix.len - 1 to matrix.len - 4 step -1)
matrix[i] = brightness

/datum/ColorMatrix/proc/hex2value(hex)
var/num1 = copytext(hex, 1, 2)
var/num2 = copytext(hex, 2)

if(isnum(text2num(num1)))
num1 = text2num(num1)
else
num1 = text2ascii(lowertext(num1)) - 87

if(isnum(text2num(num1)))
num2 = text2num(num1)
else
num2 = text2ascii(lowertext(num2)) - 87

return num1 * 16 + num2

/datum/ColorMatrix/proc/SetColor(color, contrast = 1, brightness = null)
var/rr = hex2value(copytext(color, 2, 4)) / 255
var/gg = hex2value(copytext(color, 4, 6)) / 255
var/bb = hex2value(copytext(color, 6, 8)) / 255

rr = round(rr * 1000) / 1000 * contrast
gg = round(gg * 1000) / 1000 * contrast
bb = round(bb * 1000) / 1000 * contrast

matrix = list(rr, gg, bb,
rr, gg, bb,
rr, gg, bb)

SetBrightness(brightness)

/datum/ColorMatrix/proc/SetPreset(preset)
switch(lowertext(preset))
if("invert")
matrix = list(-1,0,0,
0,-1,0,
0,0,-1,
1,1,1)
if("nightsight")
matrix = list(1,1,1,
0,0,0,
0,0,0,
0.25,0.25,0.25)
if("nightsight_glasses")
matrix = list(1,1,1,
0,0,0,
0,0,0,
0.1,0.1,0.1)
if("thermal")
matrix = list(1.1, 0, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0)
if("hos")
matrix = list(1.2, 0.1, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0)
if("yellow")
matrix = list(1.2, 0.1, 0,
0, 1, 0,
0, 0, 1,
-0.05, -0.05, -0.05)
if("nvg")
matrix = list(1,0,0,
0,1.1,0,
0,0,1,
0,0,0)
if("meson")
matrix = list(1, 0, 0,
0, 1.1, 0,
0, 0, 1,
-0.05, -0.05, -0.05)
if("sci")
matrix = list(1, 0, 0.05,
0.05, 0.95, 0.05,
0.05, 0, 1,
0, 0, 0)
if("greyscale")
matrix = list(0.33, 0.33, 0.33,
0.33, 0.33, 0.33,
0.33, 0.33, 0.33,
0, 0, 0)
if("sepia")
matrix = list(0.393,0.349,0.272,
0.769,0.686,0.534,
0.189,0.168,0.131,
0,0,0)
if("black & white")
matrix = list(1.5,1.5,1.5,
1.5,1.5,1.5,
1.5,1.5,1.5,
-1,-1,-1)
if("polaroid")
matrix = list(1.438,-0.062,-0.062,
0.122,1.378,-0.122,
0.016,-0.016,1.483,
-0.03,0.05,-0.02)
if("bgr_d")
matrix = list(0,0,1,
0,1,0,
1,0,0,
0,0,-0.5)
if("brg_d")
matrix = list(0,0,1,
1,0,0,
0,1,0,
0,-0.5,0)
if("gbr_d")
matrix = list(0,1,0,
0,0,1,
1,0,0,
0,0,-0.5)
if("grb_d")
matrix = list(0,1,0,
1,0,0,
0,0,1,
0,-0.5,0)
if("rbg_d")
matrix = list(1,0,0,
0,0,1,
0,1,0,
-0.5,0,0)
if("rgb_d")
matrix = list(1,0,0,
0,1,0,
0,0,1,
-0.3,-0.3,-0.3)
if("rgb")
matrix = list(1,0,0,
0,1,0,
0,0,1,
0,0,0)
81 changes: 81 additions & 0 deletions code/_onclick/hud/rendering/plane_master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
///reference: current relay this plane is utilizing to render
var/atom/movable/render_plane_relay/relay

var/hidden_for_user = FALSE

/atom/movable/screen/plane_master/proc/Show(override)
alpha = override || show_alpha

Expand Down Expand Up @@ -135,6 +137,85 @@
add_filter("emissives", 1, alpha_mask_filter(render_source = EMISSIVE_RENDER_TARGET, flags = MASK_INVERSE))
add_filter("object_lighting", 2, alpha_mask_filter(render_source = O_LIGHTING_VISUAL_RENDER_TARGET, flags = MASK_INVERSE))

/atom/movable/screen/plane_master/exposure
name = "exposure plane master"
plane = LIGHTING_EXPOSURE_PLANE
appearance_flags = PLANE_MASTER|PIXEL_SCALE //should use client color
blend_mode = BLEND_ADD
blend_mode_override = BLEND_ADD
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_relay_plane = RENDER_PLANE_GAME

/atom/movable/screen/plane_master/exposure/backdrop(mob/mymob) // todo: prefs
. = ..()
remove_filter("blur_exposure")
if(istype(mymob) && mymob?.client?.prefs?.old_lighting)
return
add_filter("blur_exposure", 1, gauss_blur_filter(size = 20)) // by refs such blur is heavy, but tests were okay and this allow us more flexibility with setup

/atom/movable/screen/plane_master/lamps_selfglow
name = "lamps selfglow plane master"
plane = LIGHTING_LAMPS_SELFGLOW
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_ADD
blend_mode_override = BLEND_ADD
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_relay_plane = RENDER_PLANE_GAME

/atom/movable/screen/plane_master/lamps_selfglow/backdrop(mob/mymob) // todo: prefs
. = ..()
remove_filter("add_lamps_to_selfglow")
remove_filter("lamps_selfglow_bloom")

if(!istype(mymob))
return
if(mymob?.client?.prefs?.old_lighting)
return
var/bloomsize = 0
var/bloomoffset = 0
switch(mymob?.client?.prefs?.bloomlevel)
if(BLOOM_DISABLE)
return
if(BLOOM_LOW)
bloomsize = 2
bloomoffset = 1
if(BLOOM_MED)
bloomsize = 3
bloomoffset = 2
if(BLOOM_HIGH)
bloomsize = 5
bloomoffset = 3

add_filter("add_lamps_to_selfglow", 1, layering_filter(render_source = LIGHTING_LAMPS_RENDER_TARGET, blend_mode = BLEND_OVERLAY))
add_filter("lamps_selfglow_bloom", 1, bloom_filter(threshold = "#aaaaaa", size = bloomsize, offset = bloomoffset, alpha = 100))

/atom/movable/screen/plane_master/lamps
name = "lamps plane master"
plane = LIGHTING_LAMPS_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
blend_mode_override = BLEND_OVERLAY
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_relay_plane = RENDER_PLANE_GAME

render_target = LIGHTING_LAMPS_RENDER_TARGET

/atom/movable/screen/plane_master/lamps_glare
name = "lamps glare plane master"
plane = LIGHTING_LAMPS_GLARE
appearance_flags = PLANE_MASTER //should use client color
blend_mode_override = BLEND_OVERLAY
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_relay_plane = RENDER_PLANE_GAME

/atom/movable/screen/plane_master/lamps_glare/backdrop(mob/mymob)
. = ..()
remove_filter("add_lamps_to_glare")
remove_filter("lamps_glare")
if(istype(mymob) && mymob?.client?.prefs?.old_lighting || !mymob?.client?.prefs?.lampsglare)
return
add_filter("add_lamps_to_glare", 1, layering_filter(render_source = LIGHTING_LAMPS_RENDER_TARGET, blend_mode = BLEND_OVERLAY))
add_filter("lamps_glare", 1, radial_blur_filter(size = 0.05))

/**
* Handles emissive overlays and emissive blockers.
Expand Down
4 changes: 4 additions & 0 deletions code/_onclick/hud/rendering/plane_master_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ INITIALIZE_IMMEDIATE(/atom/movable/plane_master_controller)
GHOST_PLANE,
POINT_PLANE,
LIGHTING_PLANE,
LIGHTING_EXPOSURE_PLANE,
LIGHTING_LAMPS_SELFGLOW,
LIGHTING_LAMPS_PLANE,
LIGHTING_LAMPS_GLARE,
AREA_PLANE,
)

Expand Down
12 changes: 12 additions & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@
///Any light sources that are "inside" of us, for example, if src here was a mob that's carrying a flashlight, that flashlight's light source would be part of this list.
var/tmp/list/light_sources

var/glow_icon = 'icons/obj/lamps.dmi'
var/exposure_icon = 'icons/effects/exposures.dmi'

var/glow_icon_state
var/glow_colored = FALSE

var/exposure_icon_state
var/exposure_colored = TRUE

var/image/glow_overlay
var/image/exposure_overlay

/// Last name used to calculate a color for the chatmessage overlays
var/chat_color_name
/// Last color calculated for the the chatmessage overlays
Expand Down
1 change: 1 addition & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ GLOBAL_PROTECT(admin_verbs_debug)
//ZAS Debug Verbs
/client/proc/Zone_Info, //Right-Click Gas Debug Info
/client/proc/Test_ZAS_Connection, //ZAS Connection Test
/client/proc/debug_bloom,
)
GLOBAL_LIST_INIT(admin_verbs_possess, list(/proc/possess, /proc/release))
GLOBAL_PROTECT(admin_verbs_possess)
Expand Down
1 change: 1 addition & 0 deletions code/modules/admin/holder2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ GLOBAL_PROTECT(href_token)
var/datum/filter_editor/filteriffic
var/datum/particle_editor/particle_test
var/datum/colorblind_tester/color_test = new
var/datum/bloom_edit/debug_bloom

/// Whether or not the user tried to connect, but was blocked by 2FA
var/blocked_by_2fa = FALSE
Expand Down
Loading
Loading