Working radial distortion

This commit is contained in:
2021-07-09 20:41:34 +02:00
parent fd388e1fdf
commit 1c519259a1
5 changed files with 44 additions and 34 deletions
+15 -8
View File
@@ -1,18 +1,25 @@
#version 430 core
in vec2 cenPos;
in vec2 texPos;
in vec2 texDist;
in float factor;
in float gfactor;
in vec2 vcpos;
out vec4 fColor;
layout (binding = 1) uniform sampler2D screenTexture;
float f ( float x) {
return max (1, 1 / (2 * x + 0.5)) ;
// return min (1, x) ;
//return max (1, 1 / (2 * x + 0.5)) ;
//return min (1, x) ;
if (x>1) {return 1;} else {return (1-gfactor)*x + gfactor;}
//if (x>1) {return 1;} else {return 0.5;}
}
void main()
{
vec4 tColor = vec4(texture(screenTexture , texPos) );
float t = distance(cenPos,texDist);
fColor = vec4(tColor.xy,t,tColor.w);
//, cenPos + f(distance(cenPos,texDist)) * (texPos - cenPos))) ;
float t = f(length(texDist));
fColor = vec4(texture(screenTexture
, 0.5+0.5 *( vcpos + t * (texPos - vcpos))
)
);
//vec4 tColor = vec4(texture(screenTexture , cpos + (texPos - cpos)) );
//float t = distance(cenPos,texPos);
//fColor = vec4(tColor.xy,t,tColor.w);
//fColor = tColor;
}