This commit is contained in:
2023-05-12 18:22:05 +00:00
parent eb3e576521
commit e0f3985b00
84 changed files with 49281 additions and 19388 deletions

View File

@@ -1,6 +0,0 @@
#version 330 core
void main()
{
// gl_FragDepth = gl_FragCoord.z;
}

View File

@@ -3,24 +3,27 @@ in vec2 coords;
out vec4 color;
uniform float radius;
uniform int thickness;
uniform vec3 dbgColor;
uniform bool fill;
uniform float zoom;
//in int thickness;
in float radius;
//in bool fill;
in vec3 fcolor;
in vec2 pos;
void main()
{
int thickness = 1;
bool fill = false;
// int tt = thickness + 1;
float R1 = 1.f;
float R2 = 1.f - (thickness*zoom / radius);
// float R2 = 1.f - (thickness*zoom / radius);
float R2 = 1.f - (thickness/radius);
float dist = sqrt(dot(coords, coords));
if (dist >= R2 && dist <= R1)
color = vec4(dbgColor, 1.f);
color = vec4(fcolor, 1.f);
else if (dist < R2)
color = vec4(dbgColor, 0.1f);
color = vec4(fcolor, 0.1f);
else
discard;
}

View File

@@ -1,12 +1,21 @@
#version 330 core
layout (location = 0) in vec4 vertex;
layout (location = 0) in vec2 vertex;
layout (location = 1) in vec3 acolor;
layout (location = 2) in vec2 apos;
layout (location = 3) in float aradius;
layout (location = 4) in float afill;
out vec2 coords;
out float radius;
out vec3 fcolor;
uniform mat4 proj;
uniform vec2 res;
void main()
{
gl_Position = proj * vec4(vertex.xy, 0.0, 1.0);
coords = vertex.zw;
gl_Position = proj * vec4((vertex * aradius) + apos, 0.0, 1.0);
coords = vertex.xy;
fcolor = acolor;
radius = aradius;
}

View File

@@ -0,0 +1,26 @@
#version 330 core
in vec2 TexCoords;
out vec4 frag_color;
uniform sampler2D diffuse_texture;
void main()
{
vec4 color = texture(diffuse_texture, TexCoords);
// float avg = 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
// frag_color = vec4(avg,avg,avg,1.0);
float lc = 720.0/2.0;
float line = TexCoords.y * lc;
float line_intensity = mod(float(line),2);
float off = line_intensity * 0.0005;
vec4 shift = vec4(off,0,0,0);
vec4 color_shift = vec4(0.001,0,0,0);
float r = color.r + color_shift.r + shift.r;
float g = color.g - color_shift.g + shift.g;
float b = color.b;
frag_color = vec4(r, g*0.99, b, 1.0) * clamp(line_intensity, 0.85, 1.0);
frag_color = texture(diffuse_texture, TexCoords);
}

View File

@@ -0,0 +1,104 @@
#version 330 core
in vec2 tex_coords;
in vec3 normal;
in vec3 frag_pos;
in vec4 frag_pos_light;
out vec4 frag_color;
uniform sampler2D diffuse;
uniform sampler2D normmap;
uniform sampler2D shadow_map;
uniform vec3 point_pos;
uniform vec3 dir_dir;
uniform vec3 view_pos;
uniform vec3 spot_pos;
uniform vec3 spot_dir;
/* Ambient light */
float amb_str = 0.3;
vec3 amb_color = vec3(1,1,1);
float spec_str = 0.5;
/* point */
float constant = 1;
float linear = 0.09;
float quad = 0.032;
/* spotlight */
float cutoff = 12.5; /* cutoff in radians */
float outer_cutoff = 17.5;
vec3 norm = vec3(0,0,0);
vec3 view = vec3(0,0,0);
float light_str(vec3 dir)
{
float d = max(dot(norm, dir), 0.0);
vec3 refl = reflect(-dir, norm);
float s = pow(max(dot(view,refl), 0.0), 32);
return s+d;
}
float shadow_calc(vec4 fg)
{
vec3 pc = fg.xyz / fg.w;
pc = pc * 0.5 + 0.5;
if (pc.z > 1.0)
return 0.0;
float closest_depth = texture(shadow_map, pc.xy).r;
float cur_depth = pc.z;
vec3 light_dir = normalize(vec3(4,100,20) - frag_pos); /* light pos */
float bias = max(0.05 * (1 - dot(norm, light_dir)), 0.005);
return cur_depth - bias > closest_depth ? 1.0 : 0.0;
float s;
vec2 texel_size = 1 / textureSize(shadow_map, 0);
for (int x = -1; x <= 1; ++x) {
for (int y = -1; y <= 1; ++y) {
float pcf_depth = texture(shadow_map, pc.xy + vec2(x,y) * texel_size).r;
s += cur_depth - bias > pcf_depth ? 1.0 : 0.0;
}
}
s /= 9.0;
return s;
}
void main() {
norm = normalize(normal);
view = normalize(view_pos - frag_pos);
float point_amt = light_str(normalize(point_pos-frag_pos));
float dist = length(point_pos - frag_pos);
float atten = 1.0 / (constant + linear * dist + quad * (dist*dist));
point_amt *= atten;
float dir_amt = light_str(normalize(-dir_dir));
vec3 spot_dir = normalize(spot_pos - frag_pos);
float theta = dot(spot_dir, normalize(-spot_dir));
float spot_amt = 0;
float epsilon = cutoff - outer_cutoff;
if (theta > cutoff) {
float intensity = clamp((theta - outer_cutoff)/epsilon,0.0,1.0);
spot_amt = light_str(spot_dir) * intensity;
}
vec4 mm = texture(diffuse,tex_coords);
float shadow = shadow_calc(frag_pos_light);
vec3 res = mm.rgb * (amb_str + (point_amt + dir_amt) * (1 - shadow));
frag_color = vec4(res, mm.a);
}

View File

@@ -0,0 +1,23 @@
#version 330 core
layout (location=0) in vec3 a_pos;
layout (location=1) in vec2 a_tex_coords;
layout (location=2) in vec3 a_norm;
out vec2 tex_coords;
out vec3 normal;
out vec3 frag_pos;
out vec4 frag_pos_light;
uniform mat4 vp;
uniform mat4 model;
uniform mat4 proj;
uniform mat4 lsm;
void main() {
frag_pos = vec3(model * vec4(a_pos, 1.0));
gl_Position = proj * vp * vec4(frag_pos, 1.0);
tex_coords = a_tex_coords;
normal = mat3(transpose(inverse(model))) * a_norm;
frag_pos_light = lsm * vec4(frag_pos, 1.0);
}

View File

@@ -1,19 +1,27 @@
#version 330
out vec4 color;
out vec4 frag_color;
in vec2 apos;
vec2 bpos;
uniform int thickness;
uniform int span;
uniform float thickness; /* thickness in pixels */
uniform float span;
uniform vec3 color;
void main(void)
{
float t = thickness / 2.f;
bpos.x = mod(apos.x, span);
bpos.y = mod(apos.y, span);
float t = thickness / span;
t /= 2.0;
bpos.x = mod(apos.x, span) / span;
bpos.y = mod(apos.y, span) / span;
bpos.x -= t;
bpos.y -= t;
if (!(bpos.x <= t || bpos.x >= (span - t) || bpos.y <= t || bpos.y >= (span - t)))
discard;
float comp = min(bpos.x, bpos.y);
color = vec4(0.4f, 0.7f, 0.2f, 0.3f);
}
if (comp > t)
discard;
comp += t;
frag_color = vec4(color, 1.0);
}

View File

@@ -1,17 +1,20 @@
#version 330
layout (location = 0) in vec2 pos;
out vec2 apos;
uniform vec2 offset;
out vec2 apos;
layout (std140) uniform Projection {
mat4 projection;
};
uniform vec2 offset;
void main()
{
vec4 ipos = inverse(projection) * vec4(pos, 0.f, 1.f);
apos = ipos.xy + offset;
// vec4 ipos = inverse(projection) * vec4(pos, 0.f, 1.f);
apos = pos * vec2(600, 360);
// apos = pos + offset;
gl_Position = vec4(pos, 0.f, 1.f);
}

View File

@@ -6,5 +6,5 @@ uniform float alpha;
void main()
{
color = vec4(linecolor, alpha);
}
color = vec4(1.f,1.f,1.f,1.f);
}

View File

@@ -1,11 +1,9 @@
#version 330
layout (location = 0) in vec2 pos;
layout (std140) uniform Projection {
mat4 projection;
};
uniform mat4 proj;
void main()
{
gl_Position = projection * vec4(pos, 0.f, 1.f);
}
gl_Position = proj * vec4(pos, 0.f, 1.f);
}

View File

@@ -0,0 +1,8 @@
#version 330 core
out float frag_color;
void main()
{
// frag_color = encode_depth(gl_FragCoord.z);
frag_color = gl_FragCoord.z;
}

View File

@@ -8,11 +8,8 @@ uniform sampler2D text;
void main()
{
// color = vec4(fColor.xyz, texture(text, TexCoords).r);
color = vec4(1.f,1.f,1.f, texture(text, TexCoords).r);
color = vec4(fColor.xyz, texture(text, TexCoords).r);
// color = vec4(1.f, 1.f, 1.f, texture(text, TexCoords).r);
if (color.a <= 0.1f)
discard;
}