Initial commit

This commit is contained in:
2025-01-18 16:52:43 +01:00
commit b572205b85
7 changed files with 366 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
#version 430
#extension GL_KHR_vulkan_glsl : enable
layout(set = 0, binding = 0, rgba32f) uniform image2D texture0;
uniform vec2 start;
uniform vec2 stop;
float distance_to_line(vec2 p1, vec2 p2, vec2 p3){
vec2 bvec = normalize(p2-p1);
vec2 avec = p3-p1;
float linear_projected = clamp(dot(avec, bvec), 0.0, distance(p1, p2));
vec2 projected = (linear_projected * bvec)+p1;
return length(p3-projected);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
float dist;
if(distance(start, stop)<1){
dist = length(texel-stop);
} else {
dist = distance_to_line(start, stop, texel);
}
if(dist<16){
imageStore(texture0, texel, vec4(1.0, 0.0, 0.0, 1.0));
}
}
+22
View File
@@ -0,0 +1,22 @@
#version 430
#if defined VERTEX_SHADER
in vec3 in_position;
void main() {
gl_Position = vec4(in_position, 1);
}
#elif defined FRAGMENT_SHADER
uniform sampler2D texture0;
out vec4 fragColor;
void main() {
vec2 texel = gl_FragCoord.xy / textureSize(texture0, 0);
texel.y = textureSize(texture0, 0).y-texel.y;
fragColor = texture(texture0, texel);
}
#endif