]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Further interaction outline tweaks (tonemap rework) (#19898)
authordeathride58 <deathride58@users.noreply.github.com>
Wed, 27 Sep 2023 09:22:32 +0000 (05:22 -0400)
committerGitHub <noreply@github.com>
Wed, 27 Sep 2023 09:22:32 +0000 (19:22 +1000)
Resources/Prototypes/Shaders/outline.yml
Resources/Textures/Shaders/outline.swsl

index 83b99f07eae868de00a3e0f583acfc931446ab16..57ea6a485a99d4ca350f71c720cce6119f2dbb10 100644 (file)
@@ -4,7 +4,9 @@
   path: "/Textures/Shaders/outline.swsl"
   params:
     outline_color: "#FF000055"
-    light_boost: 1
+    light_boost: 2
+    light_gamma: 1.5
+    light_whitepoint: 48
 
 - type: shader
   id: SelectionOutlineInrange
@@ -13,3 +15,5 @@
   params:
     outline_color: "#00FF0055"
     light_boost: 2
+    light_gamma: 0.9
+    light_whitepoint: 1
index d465946ae649a8c506796244ae2ec88645f9bafc..bef244555c07e2b351e2cd9fa5de0309fbbac31e 100644 (file)
@@ -31,6 +31,12 @@ uniform highp float outline_width; // = 2.0;
 uniform highp vec4 outline_color; // =vec4(1.0,0.0,0.0,0.33);
 uniform bool outline_fullbright; // =false;
 uniform highp float light_boost; // = 4.0;
+uniform highp float light_gamma; // = 1.0;
+uniform highp float light_whitepoint; // = 1.0;
+
+highp float grayscale(highp vec3 col) {
+       return mix(0.0, 1.0, (col.r * 0.299) + (col.g * 0.587) + (col.b * 0.114)); //These luminance values are taken from Rec. ITU-R BT.601-7. This isn't suitable for player-facing grayscaling due to SDTV having a funky colorspace, but it's perfect for outlines.
+}
 
 void fragment() {
        highp vec4 col = zTexture(UV);
@@ -72,7 +78,7 @@ void fragment() {
     maxa = max(a, maxa);
     mina = min(a, mina);
 
-       lowp float sampledLight = outline_fullbright ? 1.0 : sqrt(mix(0.0, 1.0, (lightSample.r * 0.34) + (lightSample.g * 0.5) + (lightSample.b * 0.16)) * light_boost);
-       COLOR = mix(col, outline_color * vec4(vec3(sampledLight), 1.0), maxa - col.a);
+       lowp float sampledLight = outline_fullbright ? 1.0 : clamp( (pow( grayscale(lightSample.rgb) * light_whitepoint, light_gamma) / light_whitepoint ) * light_boost, 0.0, 1.0);
+       COLOR = mix(col, outline_color * vec4(vec3(1.0), sampledLight), maxa - col.a);
        lightSample = vec3(1.0);
 }