Add barrel distortion shader

This commit is contained in:
jgk
2021-07-09 14:36:49 +02:00
parent 5301b6d0bd
commit fd388e1fdf
12 changed files with 192 additions and 8 deletions
+27 -6
View File
@@ -1,15 +1,36 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
void main()
{
gl_Position = vec4 (1,1,0.9,1);
in vec2 vRad1;
in vec2 vRad2;
in float vFactor;
out vec2 cenPos;
out vec2 texPos;
out vec2 texDist;
out float factor;
const float root = 1 / sqrt(2) ;
void main() {
factor = vFactor[0];
rad1 = vRad1[0];
rad2 = vRad2[0];
cenPos = gl_in[0].gl_Position;
vec2 g (vec2 p) { return vec2(dot(rad1,p), dot(rad2,p)); }
texPos = vec2(1,1);
texDist = g(root,root);
gl_Position = vec4 (1,1,0,1);
EmitVertex();
gl_Position = vec4 (1,-1,0.9,1);
texPos = vec2(1,0);
texDist = g(root,-root);
gl_Position = vec4 (1,-1,0,1);
EmitVertex();
gl_Position = vec4 (-1,1,0.9,1);
texPos = vec2(0,1);
texDist = g(-root,root);
gl_Position = vec4 (-1,1,0,1);
EmitVertex();
gl_Position = vec4 (-1,-1,0.9,1);
texPos = vec2(0,0);
texDist = g(-root,-root);
gl_Position = vec4 (-1,-1,0,1);
EmitVertex();
EndPrimitive();
}