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
params:
outline_color: "#00FF0055"
light_boost: 2
+ light_gamma: 0.9
+ light_whitepoint: 1
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);
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);
}