mirror of
https://github.com/IllusionMan1212/cudoku.git
synced 2026-10-24 02:12:25 +00:00
border radius for quads
This commit is contained in:
+2
-2
@@ -1,11 +1,11 @@
|
||||
#version 330 core
|
||||
in vec2 TexCoords;
|
||||
in vec2 v_TexCoords;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D text;
|
||||
uniform vec4 textColor;
|
||||
|
||||
void main() {
|
||||
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
|
||||
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, v_TexCoords).r);
|
||||
FragColor = textColor * sampled;
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec4 vertex;
|
||||
|
||||
out vec2 TexCoords;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 model;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection * model * vec4(vertex.xy, 0.0, 1.0);
|
||||
TexCoords = vertex.zw;
|
||||
}
|
||||
+26
-2
@@ -1,9 +1,33 @@
|
||||
#version 330 core
|
||||
|
||||
in vec2 texCoords;
|
||||
in vec2 v_TexCoords;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 aColor;
|
||||
uniform float borderRadius;
|
||||
uniform float uiWidth;
|
||||
uniform float uiHeight;
|
||||
|
||||
const float smoothness = 1.0;
|
||||
|
||||
void main() {
|
||||
FragColor = vec4(aColor);
|
||||
float alpha = aColor.a;
|
||||
|
||||
if (borderRadius > 0.0) {
|
||||
vec2 dimensions = v_TexCoords * vec2(uiWidth, uiHeight);
|
||||
float xMax = uiWidth - borderRadius;
|
||||
float yMax = uiHeight - borderRadius;
|
||||
|
||||
if (dimensions.x < borderRadius && dimensions.y < borderRadius) {
|
||||
alpha *= 1.0 - smoothstep(borderRadius - smoothness, borderRadius + smoothness, length(dimensions - vec2(borderRadius)));
|
||||
} else if (dimensions.x < borderRadius && dimensions.y > yMax) {
|
||||
alpha *= 1.0 - smoothstep(borderRadius - smoothness, borderRadius + smoothness, length(dimensions - vec2(borderRadius, yMax)));
|
||||
} else if (dimensions.x > xMax && dimensions.y < borderRadius) {
|
||||
alpha *= 1.0 - smoothstep(borderRadius - smoothness, borderRadius + smoothness, length(dimensions - vec2(xMax, borderRadius)));
|
||||
} else if (dimensions.x > xMax && dimensions.y > yMax) {
|
||||
alpha *= 1.0 - smoothstep(borderRadius - smoothness, borderRadius + smoothness, length(dimensions - vec2(xMax, yMax)));
|
||||
}
|
||||
}
|
||||
|
||||
FragColor = vec4(aColor.rgb, alpha);
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 1) in vec2 aTexCoords;
|
||||
out vec2 texCoords;
|
||||
layout (location = 0) in vec4 vertex;
|
||||
|
||||
out vec2 v_TexCoords;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 model;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection * vec4(aPos, 1.0f);
|
||||
texCoords = aTexCoords;
|
||||
gl_Position = projection * model * vec4(vertex.xy, 0.0, 1.0);
|
||||
v_TexCoords = vertex.zw;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user