v2.0, better quality, less perspective deformation #1
@ -20,7 +20,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define color_conversion
 | 
					#define color_conversion
 | 
				
			||||||
#define texture_filtering
 | 
					#define texture_filtering
 | 
				
			||||||
//#define rotate_180
 | 
					#define rotate_180
 | 
				
			||||||
//#define debug_borders
 | 
					//#define debug_borders
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef highp // defined by Qt-OpenGl
 | 
					#undef highp // defined by Qt-OpenGl
 | 
				
			||||||
@ -67,7 +67,7 @@ vec2 equidistant_to_rectilinear(const in vec2 equidistant) {
 | 
				
			|||||||
    float rectilinear_radius = length(equidistant);
 | 
					    float rectilinear_radius = length(equidistant);
 | 
				
			||||||
    float rectilinear_angle = atan(rectilinear_radius / rectilinear_focal_length);
 | 
					    float rectilinear_angle = atan(rectilinear_radius / rectilinear_focal_length);
 | 
				
			||||||
    float equidistant_radius = rectilinear_angle * equidistant_focal_length;
 | 
					    float equidistant_radius = rectilinear_angle * equidistant_focal_length;
 | 
				
			||||||
    return equidistant * (equidistant_radius / rectilinear_radius);
 | 
					    return equidistant * (equidistant_radius / (rectilinear_radius > 0.0 ? rectilinear_radius : 1.0));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// color space (https://en.wikipedia.org/wiki/Rec._709)
 | 
					// color space (https://en.wikipedia.org/wiki/Rec._709)
 | 
				
			||||||
@ -136,7 +136,6 @@ vec2 bilinear_params(const in vec2 coord, out vec2 a, out vec2 b, out vec2 c, ou
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
vec3 texture_filter(const in vec2 y_coord) {
 | 
					vec3 texture_filter(const in vec2 y_coord) {
 | 
				
			||||||
    vec2 a, b, c, d, f = bilinear_params(y_coord, a, b, c, d);
 | 
					    vec2 a, b, c, d, f = bilinear_params(y_coord, a, b, c, d);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    float luminance = mix(
 | 
					    float luminance = mix(
 | 
				
			||||||
        mix(
 | 
					        mix(
 | 
				
			||||||
            decode_luminance(texture2DRect(myTextureY, a).x),
 | 
					            decode_luminance(texture2DRect(myTextureY, a).x),
 | 
				
			||||||
@ -147,9 +146,7 @@ vec3 texture_filter(const in vec2 y_coord) {
 | 
				
			|||||||
            decode_luminance(texture2DRect(myTextureY, d).x),
 | 
					            decode_luminance(texture2DRect(myTextureY, d).x),
 | 
				
			||||||
            f.x),
 | 
					            f.x),
 | 
				
			||||||
        f.y);
 | 
					        f.y);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    f = bilinear_params(y_coord * 0.5, a, b, c, d);
 | 
					    f = bilinear_params(y_coord * 0.5, a, b, c, d);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    vec2 chroma = mix(
 | 
					    vec2 chroma = mix(
 | 
				
			||||||
        mix(
 | 
					        mix(
 | 
				
			||||||
            decode_chroma(vec2(texture2DRect(myTextureU, a).x, texture2DRect(myTextureV, a).x)),
 | 
					            decode_chroma(vec2(texture2DRect(myTextureU, a).x, texture2DRect(myTextureV, a).x)),
 | 
				
			||||||
@ -160,7 +157,6 @@ vec3 texture_filter(const in vec2 y_coord) {
 | 
				
			|||||||
            decode_chroma(vec2(texture2DRect(myTextureU, d).x, texture2DRect(myTextureV, d).x)),
 | 
					            decode_chroma(vec2(texture2DRect(myTextureU, d).x, texture2DRect(myTextureV, d).x)),
 | 
				
			||||||
            f.x),
 | 
					            f.x),
 | 
				
			||||||
        f.y);
 | 
					        f.y);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    return vec3(luminance, chroma);
 | 
					    return vec3(luminance, chroma);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user