Merge branches '19-11-12-outline-shader-submodule-update' and 'outline-shader-removal'
This commit is contained in:
7
Resources/Prototypes/Shaders/outline.yml
Normal file
7
Resources/Prototypes/Shaders/outline.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
- type: shader
|
||||||
|
id: selection_outline
|
||||||
|
kind: source
|
||||||
|
path: "/Shaders/outline.swsl"
|
||||||
|
params:
|
||||||
|
outline_width: 1
|
||||||
|
outline_color: "#FF000055"
|
||||||
77
Resources/Shaders/outline.swsl
Normal file
77
Resources/Shaders/outline.swsl
Normal file
@@ -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);
|
||||||
|
}
|
||||||
Submodule RobustToolbox updated: 64112c556e...a3879b7bbd
Reference in New Issue
Block a user