1.5 ? mod(float(rubyFrameCount),2.0) : 0.0); vec2 ratio_scale = (xy * rubyTextureSize - vec2(0.5) + ilvec)/ilfac; #ifdef OVERSAMPLE float filter = fwidth(ratio_scale.y); #endif vec2 uv_ratio = fract(ratio_scale); // Snap to the center of the underlying texel. xy = (floor(ratio_scale)*ilfac + vec2(0.5) - ilvec) / rubyTextureSize; // Calculate Lanczos scaling coefficients describing the effect // of various neighbour texels in a scanline on the current // pixel. vec4 coeffs = PI * vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x); // Prevent division by zero. coeffs = FIX(coeffs); // Lanczos2 kernel. coeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs); // Normalize. coeffs /= dot(coeffs, vec4(1.0)); // Calculate the effective colour of the current and next // scanlines at the horizontal location of the current pixel, // using the Lanczos coefficients above. vec4 col = clamp(mat4( TEX2D(xy + vec2(-one.x, 0.0)), TEX2D(xy), TEX2D(xy + vec2(one.x, 0.0)), TEX2D(xy + vec2(2.0 * one.x, 0.0))) * coeffs, 0.0, 1.0); vec4 col2 = clamp(mat4( TEX2D(xy + vec2(-one.x, one.y)), TEX2D(xy + vec2(0.0, one.y)), TEX2D(xy + one), TEX2D(xy + vec2(2.0 * one.x, one.y))) * coeffs, 0.0, 1.0); #ifndef LINEAR_PROCESSING col = pow(col , vec4(CRTgamma)); col2 = pow(col2, vec4(CRTgamma)); #endif // Calculate the influence of the current and next scanlines on // the current pixel. vec4 weights = scanlineWeights(uv_ratio.y, col); vec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2); #ifdef OVERSAMPLE uv_ratio.y =uv_ratio.y+1.0/3.0*filter; weights = (weights+scanlineWeights(uv_ratio.y, col))/3.0; weights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0; uv_ratio.y =uv_ratio.y-2.0/3.0*filter; weights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0; weights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0; #endif vec3 mul_res = (col * weights + col2 * weights2).rgb * vec3(cval); // dot-mask emulation: // Output pixels are alternately tinted green and magenta. vec3 dotMaskWeights = mix( vec3(1.0, 0.7, 1.0), vec3(0.7, 1.0, 0.7), floor(mod(mod_factor, 2.0)) ); mul_res *= dotMaskWeights; // Convert the image gamma for display on our output device. mul_res = pow(mul_res, vec3(1.0 / monitorgamma)); // Color the texel. gl_FragColor = vec4(mul_res, 1.0); } ]]>