mirror of
https://github.com/IllusionMan1212/O2048.git
synced 2026-10-24 10:12:37 +00:00
initial
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#version 330 core
|
||||
|
||||
in vec2 v_TexCoords;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform bool isSlider;
|
||||
uniform float sliderPercentage;
|
||||
|
||||
//vec3 rgb2hsv(vec3 c){
|
||||
// vec4 K = vec4(0.0,-1.0 / 3.0,2.0 / 3.0,-1.0);
|
||||
// vec4 p = mix(vec4(c.bg,K.wz),vec4(c.gb,K.xy),step(c.b,c.g));
|
||||
// vec4 q = mix(vec4(p.xyw,c.r),vec4(c.r,p.yzx),step(p.x,c.r));
|
||||
// float d = q.x - min(q.w,q.y);
|
||||
// float e = 1.0e-10;
|
||||
// return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)),d / (q.x + e),q.x);
|
||||
//}
|
||||
|
||||
vec3 hsv2rgb(vec3 color){
|
||||
vec3 rgb = clamp(abs(mod(color.r * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
|
||||
rgb = rgb * rgb * (3.0 - 2.0 * rgb);
|
||||
return color.b * mix(vec3(1.0), rgb, color.g);
|
||||
}
|
||||
|
||||
void main() {
|
||||
if (isSlider) {
|
||||
vec3 color = hsv2rgb(vec3(v_TexCoords.y, 1.0, 1.0));
|
||||
FragColor = vec4(color, 1.0);
|
||||
} else {
|
||||
vec3 color = hsv2rgb(vec3(sliderPercentage, v_TexCoords.x, 1.0 - v_TexCoords.y));
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#version 330 core
|
||||
in vec2 v_TexCoords;
|
||||
in vec4 textColor;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D text;
|
||||
|
||||
const float smoothness = 0.05;
|
||||
const float outlineDistance = 0.50;
|
||||
const vec4 outlineColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
void main() {
|
||||
//float distance = texture(text, v_TexCoords).r;
|
||||
//float outlineFactor = smoothstep(0.5 - smoothness, 0.5 + smoothness, distance);
|
||||
//vec4 color = mix(outlineColor, textColor, outlineFactor);
|
||||
//float alpha = smoothstep(outlineDistance - smoothness, outlineDistance + smoothness, distance);
|
||||
|
||||
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, v_TexCoords).r);
|
||||
FragColor = textColor * sampled;
|
||||
//FragColor = vec4(color.rgb, textColor.a * alpha);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec2 vertex;
|
||||
|
||||
// per instance
|
||||
layout (location = 1) in vec4 offset;
|
||||
layout (location = 2) in int tex_index;
|
||||
layout (location = 3) in vec4 color;
|
||||
layout (location = 4) in mat4 model; // this takes locations 4,5,6,7
|
||||
|
||||
out vec2 v_TexCoords;
|
||||
out vec4 textColor;
|
||||
uniform mat4 projection;
|
||||
// buffer for all the 96 ascii characters' texcoords
|
||||
uniform vec2 texcoords[96 * 4];
|
||||
|
||||
void main() {
|
||||
vec2 pos = vec2((vertex.x) * offset.z, (vertex.y) * offset.w);
|
||||
gl_Position = projection * model * vec4(pos + offset.xy, 0.0, 1.0);
|
||||
v_TexCoords = texcoords[tex_index * 4 + gl_VertexID];
|
||||
textColor = color;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#version 330 core
|
||||
|
||||
in vec2 v_TexCoords;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 aColor;
|
||||
uniform float borderRadius;
|
||||
uniform float uiWidth;
|
||||
uniform float uiHeight;
|
||||
uniform bool hasTexture;
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
const float smoothness = 1.0;
|
||||
|
||||
void main() {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
if (hasTexture) {
|
||||
FragColor = texture(tex, v_TexCoords) * vec4(aColor.rgb, alpha);
|
||||
} else {
|
||||
FragColor = vec4(aColor.rgb, alpha);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec4 vertex;
|
||||
|
||||
out vec2 v_TexCoords;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 model;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection * model * vec4(vertex.xy, 0.0, 1.0);
|
||||
v_TexCoords = vertex.zw;
|
||||
}
|
||||
Reference in New Issue
Block a user