This commit is contained in:
Never Gude 2026-03-02 22:25:41 +01:00
parent 96f1792c09
commit 4fc1e20fdd
30 changed files with 1045 additions and 39 deletions

View file

@ -0,0 +1,16 @@
layout (location=0) in vec2 vertex_pos;
layout (location=1) in int type_index;
uniform vec2 offset;
uniform vec2 scale;
uniform vec3 type_colors[26];
out vec3 type_color;
void main(){
vec2 pos = vertex_pos * scale;
pos.y = -pos.y;
pos = pos + offset;
type_color = type_colors[type_index];
gl_Position = vec4(pos, 0.0, 1.0);
}

View file

@ -0,0 +1,8 @@
precision mediump float;
out vec4 color;
in vec3 type_color;
void main(){
color = vec4(type_color, 1);
}

View file

@ -0,0 +1,16 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
uniform mat4 transform_matrix;
uniform sampler2D pdf_texture;
void main(){
vec4 pdf_color = vec4(texture(pdf_texture, uvs).rgb, 1);
vec3 resulting_unclamped_color = (transform_matrix * pdf_color).rgb;
color = vec4(clamp(resulting_unclamped_color, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0)), 1.0);
}

View file

@ -0,0 +1,37 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
uniform sampler2D pdf_texture;
uniform float contrast;
//http://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness
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 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main(){
vec3 tempcolor = texture(pdf_texture, uvs).rgb;
vec3 inv = (0.5-tempcolor)*contrast+0.5; //Invert colors and shift colors from range 0.0 - 1.0 to -0.5 - 0.5, apply contrast and shift back to 0.0 - 1.0. This way contrast applies on both whites and blacks
vec3 hsvcolor = rgb2hsv(inv); //transform to hsv
float new_hue = mod(hsvcolor.r + 0.5, 1.0); // shift hue 180 degrees to compensate hue shift from inverting colors
vec3 newcolor = hsv2rgb(vec3(new_hue,hsvcolor.gb));
color = vec4(newcolor, 1.0);
}

View file

@ -0,0 +1,9 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
void main(){
color = vec4(1.0, 1.0, 0.0, 0.3);
}

View file

@ -0,0 +1,27 @@
#extension GL_OES_standard_derivatives : enable
precision mediump float;
in vec2 uv;
in vec4 type_color;
out vec4 color;
void main(){
float x = (uv.x - 0.5) * 2.0;
float y = (uv.y - 0.5) * 2.0;
float r_squared = x * x + y * y;
float alpha = 1.0;
#ifdef GL_OES_standard_derivatives
float delta = fwidth(r_squared);
alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r_squared);
color = vec4(type_color.rgb, alpha);
#else
if (r_squared <= 1.0){
color = type_color;
}
else{
color = vec4(0.0, 0.0, 0.0, 0.0);
}
#endif
}

View file

@ -0,0 +1,20 @@
layout (location=0) in vec2 vertex_pos;
layout (location=1) in vec2 vertex_uv;
layout (location=2) in int type_index;
uniform vec2 offset;
uniform vec2 scale;
uniform vec3 type_colors[26];
out vec2 uv;
out vec4 type_color;
void main(){
uv = vertex_uv;
type_color = vec4(type_colors[type_index], 1.0);
vec2 pos = vertex_pos * scale;
pos.y = -pos.y;
pos = pos + offset;
gl_Position = vec4(pos, 0.0, 1.0);
}

View file

@ -0,0 +1,12 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
uniform vec3 highlight_color;
uniform float opacity;
void main(){
color = vec4(highlight_color, opacity);
}

View file

@ -0,0 +1,8 @@
precision mediump float;
out vec4 color;
uniform vec4 line_color;
void main(){
color = line_color;
}

View file

@ -0,0 +1,5 @@
layout (location=0) in vec2 vertex_pos;
void main(){
gl_Position = vec4(vertex_pos, 0.0, 1.0);
}

View file

@ -0,0 +1,11 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
uniform vec3 background_color;
void main(){
color = vec4(background_color, 1.0);
}

View file

@ -0,0 +1,10 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
uniform sampler2D pdf_texture;
void main(){
color = vec4(texture(pdf_texture, uvs).rgb, 1.0);
}

View file

@ -0,0 +1,10 @@
out vec2 screen_pos;
out vec2 uvs;
layout (location=0) in vec2 vertex_pos;
layout (location=1) in vec2 vertex_uvs;
void main(){
screen_pos = vertex_pos;
uvs = vertex_uvs;
gl_Position = vec4(vertex_pos, 0.0, 1.0);
}

View file

@ -0,0 +1,10 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
uniform sampler2D pdf_texture;
void main(){
color = texture(pdf_texture, uvs);
}

View file

@ -0,0 +1,8 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
void main(){
color = vec4(0, 0, 0, 0);
}

View file

@ -0,0 +1,7 @@
out vec2 screen_pos;
layout (location=0) in vec2 vertex_pos;
void main(){
screen_pos = vertex_pos;
gl_Position = vec4(vertex_pos, 0.0, 1.0);
}

View file

@ -0,0 +1,16 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
void main(){
int x = (int)(uvs.x / 0.1);
int y = (int)(uvs.y / 0.1);
if ((x+y)% 2 == 0){
color = vec4(1.0, 0.0, 0.0, 1.0);
}
else{
color = vec4(0.0, 0.0, 1.0, 1.0);
}
}

View file

@ -0,0 +1,16 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
void main(){
int x = int(uvs.x / 0.1);
int y = int(uvs.y / 0.1);
if ((x+y)% 2 == 0){
color = vec4(1.0, 1.0, 1.0, 1.0);
}
else{
color = vec4(0.1, 0.1, 0.1, 1.0);
}
}

View file

@ -0,0 +1,31 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
uniform vec4 line_color;
uniform float time;
void main(){
color = line_color;
//color = vec4(0, 0, 0, 0.1);
//int x = int(gl_FragCoord.y / 1);
//int y = int(gl_FragCoord.x / 1);
//if ((x+y) % 2 == 0){
// color = vec4(0, 0, 0, 0.2);
//}
//else{
// color = vec4(0, 0, 0, 0.1);
//}
//color = vec4(0, 0, 0, abs(sin(gl_FragCoord.y / 10 + gl_FragCoord.x / 10)));
//if (abs(uvs.x - fract(time * freq)) < 0.05){
//color = vec4(line_color, 0.1);
//}
//else{
//color = vec4(0, 0, 0, 0.1);
//}
//color = vec4(line_color * pow(abs(sin(uvs.x - time * freq)), 128), 0.3);
//color = vec4(line_color * abs(sin(time)), 0.3);
//color = vec4(line_color, 0.3);
}

View file

@ -0,0 +1,12 @@
precision mediump float;
out vec4 color;
in vec2 screen_pos;
in vec2 uvs;
uniform vec4 line_color;
uniform float time;
void main(){
color = vec4((1-line_color.rgb), line_color.a);
}