unfish: switch to linear method
This commit is contained in:
		@ -1,5 +1,6 @@
 | 
				
			|||||||
// Adapted from https://github.com/duducosmos/defisheye
 | 
					// RozK
 | 
				
			||||||
// (then resize to 1568x1080)
 | 
					// Adapted from https://github.com/duducosmos/defisheye,
 | 
				
			||||||
 | 
					// itself based on http://www.fmwconcepts.com/imagemagick/defisheye/index.php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#extension GL_ARB_texture_rectangle: enable
 | 
					#extension GL_ARB_texture_rectangle: enable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -12,15 +13,17 @@ uniform float pts;
 | 
				
			|||||||
const vec2 half_pixel = vec2(0.5, 0.5);
 | 
					const vec2 half_pixel = vec2(0.5, 0.5);
 | 
				
			||||||
const float pi = 3.1415927;
 | 
					const float pi = 3.1415927;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const float input_fov = 150.0 * pi / 720.0;
 | 
					const float input_fov = 156.0;
 | 
				
			||||||
const float output_fov = 116.0 * pi / 360.0;
 | 
					const float output_fov = 120.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vec2 unfish(vec2 coord) {
 | 
					vec2 unfish(vec2 coord) {
 | 
				
			||||||
    vec2 center = myResolution * 0.5;
 | 
					 | 
				
			||||||
    vec2 pos = coord - center;
 | 
					 | 
				
			||||||
    float rd = length(pos);
 | 
					 | 
				
			||||||
    float diameter = sqrt(dot(myResolution, myResolution));
 | 
					    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() {
 | 
					void main() {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user