diff --git a/Resources/Prototypes/Shaders/outline.yml b/Resources/Prototypes/Shaders/outline.yml new file mode 100644 index 0000000000..56f7d4fa52 --- /dev/null +++ b/Resources/Prototypes/Shaders/outline.yml @@ -0,0 +1,7 @@ +- type: shader + id: selection_outline + kind: source + path: "/Shaders/outline.swsl" + params: + outline_width: 1 + outline_color: "#FF000055" diff --git a/Resources/Shaders/outline.swsl b/Resources/Shaders/outline.swsl new file mode 100644 index 0000000000..0c3ffc701b --- /dev/null +++ b/Resources/Shaders/outline.swsl @@ -0,0 +1,77 @@ +// Taken from the godot-demo-projects repo. +// GODOT ENGINE +// http://www.godotengine.org +// +// ************************************************************************ +// +// Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//************************************************************************ + +light_mode unshaded; +//shader_type canvas_item; +uniform float outline_width = 2.0; +// TODO: implement that hint_color thingy. +//uniform vec4 outline_color: hint_color; +uniform vec4 outline_color=vec4(1,0,0,0.33); + +void fragment() { + vec4 col = texture(TEXTURE, UV); + vec2 ps = TEXTURE_PIXEL_SIZE; + float a; + float maxa = col.a; + float mina = col.a; + + a = texture(TEXTURE, UV + vec2(0, -outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture(TEXTURE, UV + vec2(-outline_width, -outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture(TEXTURE, UV + vec2(0, outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture(TEXTURE, UV + vec2(outline_width, -outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture(TEXTURE, UV + vec2(-outline_width,0)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture(TEXTURE, UV + vec2(-outline_width, outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture(TEXTURE, UV + vec2(outline_width, 0)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture(TEXTURE, UV + vec2(outline_width, outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + COLOR = mix(col, outline_color, maxa-col.a); +} diff --git a/RobustToolbox b/RobustToolbox index 64112c556e..a3879b7bbd 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 64112c556eea1e89011c185248d533dc4a9a86b6 +Subproject commit a3879b7bbdef878a2c45722c7f7dda41a5a09e90