From 1f8cb47a111340cf47e9e456975c248d757afac2 Mon Sep 17 00:00:00 2001 From: Roz K Date: Sat, 7 Jun 2025 19:02:17 +0200 Subject: [PATCH] un-fisheye filter for gopro 8:7 ratio, wide fov, without hypersmooth --- README.md | 7 +++-- unfish_gopro_8-7_wide_hypersmooth-off.glsl | 33 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 unfish_gopro_8-7_wide_hypersmooth-off.glsl diff --git a/README.md b/README.md index 3c74400..fcd709c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ -# avidemux_shaders +# Avidemux Shaders -Shaders for avidemux \ No newline at end of file +Shaders for Avidemux with OpenGL support + +```unfish_gopro_8-7_wide_hypersmooth-off.glsl``` +Fisheye removal for GoPro, 8:7 aspect ratio, wide FOV, HyperSmooth off diff --git a/unfish_gopro_8-7_wide_hypersmooth-off.glsl b/unfish_gopro_8-7_wide_hypersmooth-off.glsl new file mode 100644 index 0000000..a89ddb0 --- /dev/null +++ b/unfish_gopro_8-7_wide_hypersmooth-off.glsl @@ -0,0 +1,33 @@ +// 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); +}