diff --git a/beestation.dme b/beestation.dme index 10cf2363351a9..74f59198fb2bf 100644 --- a/beestation.dme +++ b/beestation.dme @@ -2304,6 +2304,7 @@ #include "code\modules\client\preferences\entries\player\admin.dm" #include "code\modules\client\preferences\entries\player\ambient_occlusion.dm" #include "code\modules\client\preferences\entries\player\auto_fit_viewport.dm" +#include "code\modules\client\preferences\entries\player\bloom.dm" #include "code\modules\client\preferences\entries\player\buttons_locked.dm" #include "code\modules\client\preferences\entries\player\chat.dm" #include "code\modules\client\preferences\entries\player\crew_objectives.dm" diff --git a/code/__DEFINES/layers.dm b/code/__DEFINES/layers.dm index d82fa126271c1..2045550700461 100644 --- a/code/__DEFINES/layers.dm +++ b/code/__DEFINES/layers.dm @@ -108,6 +108,7 @@ //---------- LIGHTING ------------- ///Normal 1 per turf dynamic lighting objects #define LIGHTING_PLANE 100 +#define LIGHTING_PLANE_ADDITIVE 101 /// The plane for managing the global starlight effect #define STARLIGHT_PLANE 105 diff --git a/code/__DEFINES/lighting.dm b/code/__DEFINES/lighting.dm index b41fd762be551..6e92d2326eb6a 100644 --- a/code/__DEFINES/lighting.dm +++ b/code/__DEFINES/lighting.dm @@ -11,13 +11,8 @@ ///This light doesn't affect turf's lumcount calculations. Set to 1<<15 to ignore conflicts #define LIGHT_NO_LUMCOUNT (1<<15) -//Bay lighting engine shit, not in /code/modules/lighting because BYOND is being shit about it -#define LIGHTING_INTERVAL 5 // frequency, in 1/10ths of a second, of the lighting process - #define MINIMUM_USEFUL_LIGHT_RANGE 1.4 -#define LIGHTING_FALLOFF 1 //! type of falloff to use for lighting; 1 for circular, 2 for square -#define LIGHTING_LAMBERTIAN 0 //! use lambertian shading for light sources #define LIGHTING_HEIGHT 1 //! height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone #define LIGHTING_ROUND_VALUE (1 / 64) //! Value used to round lumcounts, values smaller than 1/129 don't matter (if they do, thanks sinking points), greater values will make lighting less precise, but in turn increase performance, VERY SLIGHTLY. @@ -71,6 +66,10 @@ #define LIGHT_RANGE_FIRE 3 //! How many tiles standard fires glow. +#define ADDITIVE_LIGHTING_PLANE_ALPHA_MAX 255 +#define ADDITIVE_LIGHTING_PLANE_ALPHA_NORMAL 128 +#define ADDITIVE_LIGHTING_PLANE_ALPHA_INVISIBLE 0 + #define LIGHTING_PLANE_ALPHA_VISIBLE 255 #define LIGHTING_PLANE_ALPHA_NV_TRAIT 250 #define LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE 192 diff --git a/code/_onclick/hud/rendering/plane_master.dm b/code/_onclick/hud/rendering/plane_master.dm index 2f34e79f8e5d1..f728dcc0c4930 100644 --- a/code/_onclick/hud/rendering/plane_master.dm +++ b/code/_onclick/hud/rendering/plane_master.dm @@ -114,6 +114,12 @@ add_filter("emissives", 1, layering_filter(render_source = EMISSIVE_RENDER_TARGET, blend_mode = BLEND_ADD)) add_filter("lighting", 3, alpha_mask_filter(render_source = O_LIGHTING_VISUAL_RENDER_TARGET, flags = MASK_INVERSE)) +/atom/movable/screen/plane_master/additive_lighting + name = "additive lighting plane master" + plane = LIGHTING_PLANE_ADDITIVE + blend_mode_override = BLEND_ADD + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + /** * Renders extremely blurred white stuff over space to give the effect of starlight lighting. */ diff --git a/code/_onclick/hud/rendering/plane_master_controller.dm b/code/_onclick/hud/rendering/plane_master_controller.dm index b6119c5103944..1ca7175013806 100644 --- a/code/_onclick/hud/rendering/plane_master_controller.dm +++ b/code/_onclick/hud/rendering/plane_master_controller.dm @@ -94,4 +94,5 @@ INITIALIZE_IMMEDIATE(/atom/movable/plane_master_controller) GHOST_PLANE, POINT_PLANE, LIGHTING_PLANE, + LIGHTING_PLANE_ADDITIVE, ) diff --git a/code/modules/atmospherics/environmental/LINDA_fire.dm b/code/modules/atmospherics/environmental/LINDA_fire.dm index 97ac99d761c12..476f6a1fb717e 100644 --- a/code/modules/atmospherics/environmental/LINDA_fire.dm +++ b/code/modules/atmospherics/environmental/LINDA_fire.dm @@ -37,7 +37,8 @@ blend_mode = BLEND_ADD light_system = MOVABLE_LIGHT light_range = LIGHT_RANGE_FIRE - light_power = 1 + // increase power for more bloom + light_power = 4 light_color = LIGHT_COLOR_FIRE var/volume = 125 @@ -112,18 +113,22 @@ heat_b = LERP(heat_b,255,normal_amt) heat_a -= gauss_lerp(temperature, -5000, 5000) * 128 greyscale_fire -= normal_amt + light_power = 4 if(temperature > 40000) //Past this temperature the fire will gradually turn a bright purple var/purple_amt = temperature < LERP(40000,200000,0.5) ? gauss_lerp(temperature, 40000, 200000) : 1 heat_r = LERP(heat_r,255,purple_amt) + light_power = 5 if(temperature > 200000 && temperature < 500000) //Somewhere at this temperature nitryl happens. var/sparkle_amt = gauss_lerp(temperature, 200000, 500000) var/mutable_appearance/sparkle_overlay = mutable_appearance('icons/effects/effects.dmi', "shieldsparkles") sparkle_overlay.blend_mode = BLEND_ADD sparkle_overlay.alpha = sparkle_amt * 255 + light_power = 6 add_overlay(sparkle_overlay) if(temperature > 400000 && temperature < 1500000) //Lightning because very anime. var/mutable_appearance/lightning_overlay = mutable_appearance(icon, "overcharged") lightning_overlay.blend_mode = BLEND_ADD + light_power = 6 add_overlay(lightning_overlay) if(temperature > 4500000) //This is where noblium happens. Some fusion-y effects. var/fusion_amt = temperature < LERP(4500000,12000000,0.5) ? gauss_lerp(temperature, 4500000, 12000000) : 1 @@ -139,6 +144,7 @@ heat_b = LERP(heat_b,150,fusion_amt) add_overlay(fusion_overlay) add_overlay(rainbow_overlay) + light_power = 8 set_light_color(rgb(LERP(250, heat_r, greyscale_fire), LERP(160, heat_g, greyscale_fire), LERP(25, heat_b, greyscale_fire))) diff --git a/code/modules/client/preferences/entries/player/bloom.dm b/code/modules/client/preferences/entries/player/bloom.dm new file mode 100644 index 0000000000000..d386ca91481c2 --- /dev/null +++ b/code/modules/client/preferences/entries/player/bloom.dm @@ -0,0 +1,12 @@ +/datum/preference/numeric/bloom + category = PREFERENCE_CATEGORY_GAME_PREFERENCES + db_key = "bloom_amount" + preference_type = PREFERENCE_PLAYER + minimum = 0 + maximum = 100 + +/datum/preference/numeric/bloom/create_default_value() + return round((ADDITIVE_LIGHTING_PLANE_ALPHA_NORMAL / 255) * 100) + +/datum/preference/numeric/bloom/apply_to_client(client/client, value) + client.mob?.update_sight() diff --git a/code/modules/client/preferences/preference_entry.dm b/code/modules/client/preferences/preference_entry.dm index 49ee69d77e192..35906477428e7 100644 --- a/code/modules/client/preferences/preference_entry.dm +++ b/code/modules/client/preferences/preference_entry.dm @@ -527,7 +527,7 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key()) "step" = step, ) -/// A prefernece whose value is always TRUE or FALSE +/// A preference whose value is always TRUE or FALSE /datum/preference/toggle abstract_type = /datum/preference/toggle diff --git a/code/modules/lighting/lighting_corner.dm b/code/modules/lighting/lighting_corner.dm index b637a8b499e23..17e82f9644345 100644 --- a/code/modules/lighting/lighting_corner.dm +++ b/code/modules/lighting/lighting_corner.dm @@ -28,6 +28,13 @@ var/cache_r = LIGHTING_SOFT_THRESHOLD var/cache_g = LIGHTING_SOFT_THRESHOLD var/cache_b = LIGHTING_SOFT_THRESHOLD + + //additive light values + var/add_r = 0 + var/add_g = 0 + var/add_b = 0 + var/applying_additive = FALSE + ///the maximum of sum_r, sum_g, and sum_b. if this is > 1 then the three cached color values are divided by this var/largest_color_luminosity = 0 @@ -111,10 +118,23 @@ self_r += delta_r self_g += delta_g self_b += delta_b + UPDATE_SUM_LUM(r) UPDATE_SUM_LUM(g) UPDATE_SUM_LUM(b) + add_r = clamp((self_r - 1.3) * 0.25, 0, 0.22) + add_g = clamp((self_g - 1.3) * 0.25, 0, 0.22) + add_b = clamp((self_b - 1.3) * 0.25, 0, 0.22) + + // Client-shredding, does not cull any additive overlays. + //applying_additive = add_r || add_g || add_b + // Cull additive overlays that would be below 0.03 alpha in any color. + applying_additive = max(add_r, add_g, add_b) > 0.03 + // Cull additive overlays whose color alpha sum is lower than 0.03 + //applying_additive = (add_r + add_g + add_b) > 0.03 + + #ifdef ZMIMIC_LIGHT_BLEED var/turf/T var/datum/lighting_corner/C diff --git a/code/modules/lighting/lighting_object.dm b/code/modules/lighting/lighting_object.dm index 7c38b44c3a95b..190c112d2fe09 100644 --- a/code/modules/lighting/lighting_object.dm +++ b/code/modules/lighting/lighting_object.dm @@ -12,6 +12,7 @@ var/needs_update = FALSE var/turf/myturf + var/mutable_appearance/additive_underlay /atom/movable/lighting_object/Initialize(mapload) . = ..() @@ -24,6 +25,9 @@ myturf.lighting_object = src myturf.luminosity = 0 + additive_underlay = mutable_appearance(LIGHTING_ICON, "light", FLOAT_LAYER, LIGHTING_PLANE_ADDITIVE, 255, RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM) + additive_underlay.blend_mode = BLEND_ADD + needs_update = TRUE SSlighting.objects_queue += src @@ -37,6 +41,7 @@ if (isturf(myturf)) myturf.lighting_object = null myturf.luminosity = initial(myturf.luminosity) + myturf.underlays -= additive_underlay myturf = null return ..() @@ -113,6 +118,36 @@ 00, 00, 00, 01 ) + if(cr.applying_additive || cg.applying_additive || cb.applying_additive || ca.applying_additive) + myturf.underlays -= additive_underlay + additive_underlay.icon_state = "light" + var/arr = cr.add_r + var/arb = cr.add_b + var/arg = cr.add_g + + var/agr = cg.add_r + var/agb = cg.add_b + var/agg = cg.add_g + + var/abr = cb.add_r + var/abb = cb.add_b + var/abg = cb.add_g + + var/aarr = ca.add_r + var/aarb = ca.add_b + var/aarg = ca.add_g + + additive_underlay.color = list( + arr, arg, arb, 00, + agr, agg, agb, 00, + abr, abg, abb, 00, + aarr, aarg, aarb, 00, + 00, 00, 00, 01 + ) + myturf.underlays += additive_underlay + else + myturf.underlays -= additive_underlay + luminosity = set_luminosity if (myturf.above) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 93c52ca742422..d9f21fd5e406e 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1083,6 +1083,12 @@ var/atom/movable/screen/plane_master/lighting/L = hud_used.plane_masters["[LIGHTING_PLANE]"] if (L) L.alpha = lighting_alpha + var/atom/movable/screen/plane_master/additive_lighting/LA = hud_used.plane_masters["[LIGHTING_PLANE_ADDITIVE]"] + if(LA) + var/bloom = ADDITIVE_LIGHTING_PLANE_ALPHA_NORMAL + if(client?.prefs) //If this ever doesn't work for some reason add update_sight() to /mob/living/Login() + bloom = client.prefs.read_preference(/datum/preference/numeric/bloom) * (ADDITIVE_LIGHTING_PLANE_ALPHA_MAX / 100) + LA.alpha = lighting_alpha * (bloom / 255) ///Update the mouse pointer of the attached client in this mob /mob/proc/update_mouse_pointer() diff --git a/code/modules/power/apc/apc_main.dm b/code/modules/power/apc/apc_main.dm index 075a44b1dce3f..ac89d0668d0fb 100644 --- a/code/modules/power/apc/apc_main.dm +++ b/code/modules/power/apc/apc_main.dm @@ -20,6 +20,8 @@ layer = ABOVE_WINDOW_LAYER zmm_flags = ZMM_MANGLE_PLANES + light_power = 0.85 + FASTDMM_PROP(\ diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index c29b72e53f5fa..a0662b1eb53a2 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -16,6 +16,9 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) var/uid = 1 var/static/gl_uid = 1 light_range = 4 + // this thing bright as hell (to increase bloom) + light_power = 5 + light_color = "#ffe016" resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF | FREEZE_PROOF flags_1 = PREVENT_CONTENTS_EXPLOSION_1 critical_machine = TRUE @@ -291,26 +294,41 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) distort.icon_state = "SM_base" distort.pixel_x = -32 distort.pixel_y = -32 + light_range = 4 + light_power = 5 + light_color = "#ffe016" if(SUPERMATTER_NORMAL, SUPERMATTER_NOTIFY, SUPERMATTER_WARNING) distort.icon = 'icons/effects/96x96.dmi' distort.icon_state = "SM_base_active" distort.pixel_x = -32 distort.pixel_y = -32 + light_range = 4 + light_power = 7 + light_color = "#ffe016" if(SUPERMATTER_DANGER) distort.icon = 'icons/effects/160x160.dmi' distort.icon_state = "SM_delam_1" distort.pixel_x = -64 distort.pixel_y = -64 + light_range = 5 + light_power = 10 + light_color = "#ffb516" if(SUPERMATTER_EMERGENCY) distort.icon = 'icons/effects/224x224.dmi' distort.icon_state = "SM_delam_2" distort.pixel_x = -96 distort.pixel_y = -96 + light_range = 6 + light_power = 10 + light_color = "#ff9208" if(SUPERMATTER_DELAMINATING) distort.icon = 'icons/effects/288x288.dmi' distort.icon_state = "SM_delam_3" distort.pixel_x = -128 distort.pixel_y = -128 + light_range = 7 + light_power = 15 + light_color = "#ff5006" return distort /obj/machinery/power/supermatter_crystal/proc/countdown() diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/bloom.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/bloom.tsx new file mode 100644 index 0000000000000..0ab15b26218f4 --- /dev/null +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/bloom.tsx @@ -0,0 +1,10 @@ +import { FeatureNumberInput, FeatureNumeric } from '../base'; + +export const bloom_amount: FeatureNumeric = { + name: 'Bloom Level', + category: 'GRAPHICS', + subcategory: 'Misc', + description: + 'What percentage of bloom to show. Bloom is a lighting effect that gives bright lights a whiteout effect. Disabling it entirely may increase client performance, if needed.', + component: FeatureNumberInput, +};