Files
loop/shader/texture/barrel.frag
T

48 lines
1.2 KiB
GLSL

#version 450 core
in vec2 texPos;
const int n1 = 15;
in vec2 distmask[n1];
in vec2 pinchr[n1];
in vec2 pinchg[n1];
in vec2 pinchb[n1];
out vec4 fColor;
layout (binding = 1) uniform sampler2D screenTexture;
layout (location = 0) uniform int n;
vec3 toYUV (vec3 rgb)
{ return rgb * mat3
( 0.299 , 0.587 , 0.114
,-0.14713,-0.28886, 0.436
, 0.615 ,-0.51499,-0.10001
) ;
}
vec3 toRGB (vec3 yuv)
{ return yuv * mat3
(1, 0 , 1.13983
,1,-0.39465,-0.58060
,1, 2.03211, 0
) ;
}
void main()
{
vec2 tposr = texPos;
vec2 tposb = texPos;
vec2 tposg = texPos;
for(int i = 0; i < n; ++i)
{
float x = 1 - min(1, sqrt(distance(distmask[i],vec2(0,0))));
tposr += x * pinchr[i];
tposg += x * pinchg[i];
tposb += x * pinchb[i];
}
fColor.r = texture(screenTexture, tposr).r;
fColor.g = texture(screenTexture, tposg).g;
fColor.b = texture(screenTexture, tposb).b;
}
// fColor = vec4
// ( toRGB(vec3( toYUV(texture(screenTexture, texPos).rgb).r
// , toYUV(texture(screenTexture, (texPos + x*pinch)).rgb).g
// , toYUV(texture(screenTexture, (texPos + x*(pinch))).rgb).b
// ) )
// , 1
// ) ;