1
0
avidemux_shaders/unfish_gopro_8-7_wide_hypersmooth-off.glsl

34 lines
1.0 KiB
Plaintext
Raw Normal View History

// Adapted from https://github.com/duducosmos/defisheye
// (then resize to 1568x1080)
#extension GL_ARB_texture_rectangle: enable
uniform sampler2DRect myTextureY;
uniform sampler2DRect myTextureU;
uniform sampler2DRect myTextureV;
uniform vec2 myResolution;
uniform float pts;
const vec2 half_pixel = vec2(0.5, 0.5);
const float pi = 3.1415927;
const float input_fov = 150.0 * pi / 720.0;
const float output_fov = 116.0 * pi / 360.0;
vec2 unfish(vec2 coord) {
vec2 center = myResolution * 0.5;
vec2 pos = coord - center;
float rd = length(pos);
float diameter = sqrt(dot(myResolution, myResolution));
return center + pos * ((diameter / (2.0 * sin(input_fov))) * sin(atan(rd / (diameter / (2.0 * tan(output_fov)))) * 0.5) / rd);
}
void main() {
vec2 y_coord = unfish(gl_TexCoord[0].xy + half_pixel);
vec2 uv_coord = y_coord * 0.5;
vec4 y = texture2DRect(myTextureY, y_coord);
vec4 u = texture2DRect(myTextureU, uv_coord);
vec4 v = texture2DRect(myTextureV, uv_coord);
gl_FragColor = vec4(y.r, u.r, v.r, 1.0);
}