LumixEngine/data/pipelines/selection_outline.shd
2022-11-20 16:24:05 +01:00

40 lines
No EOL
898 B
Text

------------------
include "pipelines/common.glsl"
vertex_shader [[
layout(location = 0) out vec2 v_uv;
void main() {
gl_Position = fullscreenQuad(gl_VertexID, v_uv);
}
]]
---------------------
fragment_shader [[
layout (binding = 0) uniform sampler2D u_mask;
layout(location = 0) in vec2 v_uv;
layout(location = 0) out vec4 o_color;
void main() {
if(texture(u_mask, v_uv).r > 0) discard;
vec2 view_texel = 1.0 / Global.framebuffer_size;
vec4 color = vec4(0, 0, 0, 0);
int c = 0;
for(int i = 0; i < 3; ++i)
{
if(texture(u_mask, v_uv + vec2(view_texel.x * i, 0)).r == 0) ++c;
if(texture(u_mask, v_uv + vec2(-view_texel.x * i, 0)).r == 0) ++c;
if(texture(u_mask, v_uv + vec2(0, view_texel.y * i)).r == 0) ++c;
if(texture(u_mask, v_uv + vec2(0, -view_texel.y * i)).r == 0) ++c;
}
if(c == 12) discard;
o_color.rgba = vec4(1, 0.5, 0, 1.0f);
}
]]