Further interaction outline tweaks (tonemap rework) (#19898)

This commit is contained in:
deathride58
2023-09-27 05:22:32 -04:00
committed by GitHub
parent cbaab5dc36
commit 136e895f83
2 changed files with 13 additions and 3 deletions

View 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

View 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);
}