Skip to content

Commit

Permalink
fix bloom the right way (#1011)
Browse files Browse the repository at this point in the history
* fix bloom the right way

* ok i guess
  • Loading branch information
Kapu1178 authored Jun 30, 2024
1 parent 70dc242 commit b251857
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions code/modules/lighting/lighting_corner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@
lum_g += delta_g
lum_b += delta_b

add_r = clamp((lum_r - 1.1) * 0.3, 0, 0.22)
add_g = clamp((lum_g - 1.1) * 0.3, 0, 0.22)
add_b = clamp((lum_b - 1.1) * 0.3, 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

if (!needs_update)
needs_update = TRUE
SSlighting.corners_queue += src
Expand All @@ -125,9 +114,13 @@
if (largest_color_luminosity > 1)
. = 1 / largest_color_luminosity

// var/old_r = cache_r
// var/old_g = cache_g
// var/old_b = cache_b
var/old_r = cache_r
var/old_g = cache_g
var/old_b = cache_b

var/old_add_r = add_r
var/old_add_g = add_g
var/old_add_b = add_b

#if LIGHTING_SOFT_THRESHOLD != 0
else if (largest_color_luminosity < LIGHTING_SOFT_THRESHOLD)
Expand All @@ -142,14 +135,24 @@
cache_b = round(lum_b * ., LIGHTING_ROUND_VALUE)
#endif

add_r = clamp((lum_r - 1.1) * 0.3, 0, 0.22)
add_g = clamp((lum_g - 1.1) * 0.3, 0, 0.22)
add_b = clamp((lum_b - 1.1) * 0.3, 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

src.largest_color_luminosity = round(largest_color_luminosity, LIGHTING_ROUND_VALUE)
#ifdef VISUALIZE_LIGHT_UPDATES
if(!SSlighting.allow_duped_corners && old_r == cache_r && old_g == cache_g && old_b == cache_b)
if(!SSlighting.allow_duped_corners && old_r == cache_r && old_g == cache_g && old_b == cache_b && old_add_r == add_r && old_add_b == add_b && old_add_g == add_g)
return
#else
// For some reason, preventing duped corners breaks bloom, so it's disabled.
// if(old_r == cache_r && old_g == cache_g && old_b == cache_b)
// return
if(old_r == cache_r && old_g == cache_g && old_b == cache_b && old_add_r == add_r && old_add_b == add_b && old_add_g == add_g)
return
#endif

var/datum/lighting_object/lighting_object = master_NE?.lighting_object
Expand Down

0 comments on commit b251857

Please sign in to comment.