Warning, /frameworks/kirigami/src/scenegraph/shaders6/shadowedbordertexture_lowpower.frag is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
0003 *
0004 * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 #version 440
0008
0009 #extension GL_GOOGLE_include_directive: enable
0010 #include "sdf_lowpower.glsl"
0011 // See sdf.glsl for the SDF related functions.
0012
0013 // This shader renders a rectangle with rounded corners and a shadow below it.
0014 // In addition it renders a border around it.
0015
0016 #include "uniforms.glsl"
0017 layout(binding = 1) uniform sampler2D textureSource;
0018
0019 layout(location = 0) in lowp vec2 uv;
0020 layout(location = 0) out lowp vec4 out_color;
0021
0022 const lowp float minimum_shadow_radius = 0.05;
0023
0024 void main()
0025 {
0026 lowp vec4 col = vec4(0.0);
0027
0028 // Calculate the outer rectangle distance field.
0029 lowp float outer_rect = sdf_rounded_rectangle(uv, ubuf.aspect, ubuf.radius);
0030
0031 // Render it
0032 col = sdf_render(outer_rect, col, ubuf.borderColor);
0033
0034 // Inner rectangle distance field equals outer reduced by twice the border width
0035 lowp float inner_rect = outer_rect + ubuf.borderWidth * 2.0;
0036
0037 // Render it so we have a background for the image.
0038 col = sdf_render(inner_rect, col, ubuf.color);
0039
0040 // Sample the texture, then render it, blending with the background color.
0041 lowp vec2 texture_uv = ((uv / ubuf.aspect) + 1.0) / 2.0;
0042 lowp vec4 texture_color = texture(textureSource, texture_uv);
0043 col = sdf_render(inner_rect, col, texture_color, texture_color.a, sdf_default_smoothing);
0044
0045 out_color = col * ubuf.opacity;
0046 }