outline tweak
This commit is contained in:
parent
aab5edd1ac
commit
c67a1c99e7
2 changed files with 25 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ shader_type canvas_item;
|
||||||
|
|
||||||
uniform sampler2D screen_tex : hint_screen_texture, repeat_disable, filter_nearest;
|
uniform sampler2D screen_tex : hint_screen_texture, repeat_disable, filter_nearest;
|
||||||
uniform vec3 outline_color : source_color = vec3(1.0);
|
uniform vec3 outline_color : source_color = vec3(1.0);
|
||||||
|
uniform float min_value = 0.6;
|
||||||
|
|
||||||
vec3 inv(vec3 x) {
|
vec3 inv(vec3 x) {
|
||||||
return 1.0 - x;
|
return 1.0 - x;
|
||||||
|
|
@ -9,6 +10,24 @@ vec3 inv(vec3 x) {
|
||||||
vec3 screen(vec3 src, vec3 dst) {
|
vec3 screen(vec3 src, vec3 dst) {
|
||||||
return inv(inv(dst)*inv(src));
|
return inv(inv(dst)*inv(src));
|
||||||
}
|
}
|
||||||
|
// All components are in the range [0…1], including hue.
|
||||||
|
vec3 rgb2hsv(vec3 c)
|
||||||
|
{
|
||||||
|
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||||
|
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||||
|
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||||
|
|
||||||
|
float d = q.x - min(q.w, q.y);
|
||||||
|
float e = 1.0e-10;
|
||||||
|
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||||
|
}
|
||||||
|
// All components are in the range [0…1], including hue.
|
||||||
|
vec3 hsv2rgb(vec3 c)
|
||||||
|
{
|
||||||
|
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||||
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||||
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||||
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
vec4 base = textureLod(screen_tex, SCREEN_UV, 0.0);
|
vec4 base = textureLod(screen_tex, SCREEN_UV, 0.0);
|
||||||
|
|
@ -21,6 +40,9 @@ void fragment() {
|
||||||
min_alpha = min(min_alpha, texture(screen_tex, UV - vec2(0, 1) * SCREEN_PIXEL_SIZE).a);
|
min_alpha = min(min_alpha, texture(screen_tex, UV - vec2(0, 1) * SCREEN_PIXEL_SIZE).a);
|
||||||
|
|
||||||
float edge = clamp(alpha - min_alpha, 0.0, 1.0);
|
float edge = clamp(alpha - min_alpha, 0.0, 1.0);
|
||||||
vec3 blended = screen(outline_color.rgb, base.rgb);
|
vec3 base_hsv = rgb2hsv(base.rgb);
|
||||||
|
base_hsv.z = clamp(mix(min_value, 1.0, base_hsv.z), 0.0, 1.0);
|
||||||
|
vec3 boosted = hsv2rgb(base_hsv);
|
||||||
|
vec3 blended = screen(outline_color.rgb, boosted.rgb);
|
||||||
COLOR = mix(base, vec4(blended, 1.0), edge);
|
COLOR = mix(base, vec4(blended, 1.0), edge);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,8 @@ shader_parameter/top_ribbon_color = Color(0.4, 0.4, 0.4, 1)
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_xdrfk"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_xdrfk"]
|
||||||
shader = ExtResource("11_xdrfk")
|
shader = ExtResource("11_xdrfk")
|
||||||
shader_parameter/outline_color = Color(0.5014065, 0.50140655, 0.50140643, 1)
|
shader_parameter/outline_color = Color(0, 0, 0, 1)
|
||||||
|
shader_parameter/min_value = 0.6
|
||||||
|
|
||||||
[node name="Game" type="Node2D" unique_id=1186062666]
|
[node name="Game" type="Node2D" unique_id=1186062666]
|
||||||
visibility_layer = 3
|
visibility_layer = 3
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue