fix: reduce shader usage
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#version 440
|
||||
|
||||
layout(location = 0) in vec2 qt_TexCoord0;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(std140, binding = 0) uniform buf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
vec2 size;
|
||||
vec4 radii;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
layout(binding = 1) uniform sampler2D source;
|
||||
|
||||
void main() {
|
||||
vec2 p = qt_TexCoord0 * size - size * 0.5;
|
||||
float radius = p.x < 0.0 ? (p.y < 0.0 ? radii.x : radii.w) : (p.y < 0.0 ? radii.y : radii.z);
|
||||
vec2 q = abs(p) - (size * 0.5 - radius);
|
||||
float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
|
||||
float mask = 1.0 - smoothstep(-0.5, 0.5, d);
|
||||
|
||||
vec4 content = texture(source, qt_TexCoord0);
|
||||
vec4 blended = content + color * (1.0 - content.a);
|
||||
fragColor = blended * mask * qt_Opacity;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#version 440
|
||||
|
||||
layout(location = 0) in vec4 qt_VertexPosition;
|
||||
layout(location = 1) in vec2 qt_VertexTexCoord;
|
||||
|
||||
layout(location = 0) out vec2 qt_TexCoord0;
|
||||
|
||||
layout(std140, binding = 0) uniform buf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
vec2 size;
|
||||
vec4 radii;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
void main() {
|
||||
gl_Position = qt_Matrix * qt_VertexPosition;
|
||||
qt_TexCoord0 = qt_VertexTexCoord;
|
||||
}
|
||||
Reference in New Issue
Block a user