This commit is contained in:
Bartkk
2025-04-07 22:37:52 +02:00
commit 53b264e4d9
9 changed files with 2567 additions and 0 deletions

26
shaders/fragment.glsl Normal file
View File

@@ -0,0 +1,26 @@
#version 130
out mediump vec4 color;
in mediump vec2 texcoord;
uniform sampler2D tex;
uniform vec2 cursorPos;
uniform vec2 windowSize;
uniform vec2 screenshotSize;
uniform float flShadow;
uniform float flRadius;
uniform float cameraScale;
uniform bool gridEnabled;
void main()
{
vec4 cursor = vec4(cursorPos.x, windowSize.y - cursorPos.y, 0.0, 1.0);
color = mix(
texture(tex, texcoord), vec4(0.0, 0.0, 0.0, 0.0),
length(cursor - gl_FragCoord) < (flRadius * cameraScale) ? 0.0 : flShadow);
if(gridEnabled){
vec2 uv = texcoord * screenshotSize;
if(fract(uv.x) < 0.04f || fract(uv.y) < 0.04f)
color = vec4(0.0);
}
}

25
shaders/vertex.glsl Normal file
View File

@@ -0,0 +1,25 @@
#version 130
in vec3 aPos;
in vec2 aTexCoord;
out vec2 texcoord;
uniform vec2 cameraPos;
uniform float cameraScale;
uniform vec2 windowSize;
uniform vec2 screenshotSize;
uniform vec2 cursorPos;
vec3 to_world(vec3 v) {
vec2 ratio = vec2(
windowSize.x / screenshotSize.x / cameraScale,
windowSize.y / screenshotSize.y / cameraScale);
return vec3((v.x / screenshotSize.x * 2.0 - 1.0) / ratio.x,
(v.y / screenshotSize.y * 2.0 - 1.0) / ratio.y,
v.z);
}
void main()
{
gl_Position = vec4(to_world((aPos - vec3(cameraPos * vec2(1.0, -1.0), 0.0))), 1.0);
texcoord = aTexCoord;
}