1
0

unfish: switch to linear method

This commit is contained in:
Roz K 2025-06-15 10:57:43 +02:00
parent 09bb7fc502
commit a3b068c2dc
Signed by: roz
GPG Key ID: 51FBF4E483E1C822

View File

@ -1,5 +1,6 @@
// Adapted from https://github.com/duducosmos/defisheye
// (then resize to 1568x1080)
// RozK
// Adapted from https://github.com/duducosmos/defisheye,
// itself based on http://www.fmwconcepts.com/imagemagick/defisheye/index.php
#extension GL_ARB_texture_rectangle: enable
@ -12,15 +13,17 @@ 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;
const float input_fov = 156.0;
const float output_fov = 120.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);
vec2 center = myResolution * 0.5;
vec2 position = coord - center;
float input_distance = length(position);
float input_foc = diameter * 180.0 / (input_fov * pi);
float output_foc = diameter / (2.0 * tan(output_fov * pi / 360.0));
return center + position * (input_foc * atan(input_distance / output_foc) / input_distance);
}
void main() {