here's a naive and simple line averaging deinterlacer in glsl. im sure one could implement something much smarter. note ive had issues with texcoords, so you may have to pass in the texure dims as a uniform from the outside world.

---- vp
varying vec2 texcoord0;
varying vec2 texdim0;

void main()
{
    // perform standard transform on vertex
    gl_Position = ftransform();

    // transform texcoords
    texcoord0 = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);
texdim0 = vec2 (abs(gl_TextureMatrix[0][0] [0]),abs(gl_TextureMatrix[0][1][1]));
}

---- fp

// define our rectangular texture samplers
uniform sampler2DRect tex0;

// define our varying texture coordinates
varying vec2 texcoord0;
varying vec2 texdim0;

void main (void)
{
        // we have to average like so:  
        // scanline 0 and 1 are (0 + 1) / 2.
        // scanline 2 and 3 are (2 + 3) / 2.
        
        // we need to not do
        // scanline 0 and 1 are (0 + 1) / 2.
        // scanline 1 and 2 are (1 + 2) / 2.
                
        float isodd = mod(texcoord0.y, 2.0); // returns 0 or 1.

        vec4 result;

        if(bool(isodd))
        {
vec4 evenfield = texture2DRect(tex0, vec2(texcoord0.x, texcoord0.y + 1.0));
                vec4 oddfield = texture2DRect(tex0, texcoord0);

                result = mix(evenfield, oddfield, 0.5);
        }
        
        else
        {       
                vec4 evenfield = texture2DRect(tex0, texcoord0);
vec4 oddfield = texture2DRect(tex0, vec2(texcoord0.x, texcoord0.y - 1.0));

                result = mix(evenfield, oddfield, 0.5);
        }
        
        gl_FragColor = result;
        
        // moo : short cow !
}




On Aug 21, 2008, at 9:41 AM, Chris Wood wrote:

I guess you could add some extra QC goodness to de-interlace? I'd imagine the various de-interlacing methods are possible using sample- and-hold and a CI filter to merge fields. Not ideal, but better than nothing. If it's workable like that I think a plugin to de-interlace would be worthwhile.

Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to