Light-reactive interaction outlines (#18343)

This commit is contained in:
deathride58
2023-08-02 06:07:12 -04:00
committed by GitHub
parent 5b66eb36d7
commit 2db1c1600f
2 changed files with 7 additions and 5 deletions

View File

@@ -4,6 +4,7 @@
path: "/Textures/Shaders/outline.swsl"
params:
outline_color: "#FF000055"
light_boost: 2
- type: shader
id: SelectionOutlineInrange
@@ -11,3 +12,4 @@
path: "/Textures/Shaders/outline.swsl"
params:
outline_color: "#00FF0055"
light_boost: 4

View File

@@ -27,12 +27,10 @@
//
//************************************************************************
light_mode unshaded;
//shader_type canvas_item;
uniform highp float outline_width; // = 2.0;
// TODO: implement that hint_color thingy.
//uniform vec4 outline_color: hint_color;
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;
void fragment() {
highp vec4 col = zTexture(UV);
@@ -74,5 +72,7 @@ void fragment() {
maxa = max(a, maxa);
mina = min(a, mina);
COLOR = mix(col, outline_color, maxa-col.a);
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 * sampledLight, maxa - col.a);
lightSample = vec3(1.0);
}