XML Feeds

.

[jitter] pixelate in openGL

Andrew Benson andrewb at cycling74.com
Mon Jan 14 11:50:08 MST 2008


I haven't looked at Vade's shader, but this one should do the job.

-ab

<jittershader name="repos">
    <description>
    distortion based on position map in second inlet
    </description>
    <param name="amount" type="vec2" default="0. 0." />
    <param name="tex0" type="int" default="0" />
    <param name="tex1" type="int" default="1" />
    <language name="glsl" version="1.0">
        <bind param="amount" program="fp" />
        <bind param="tex0" program="fp" />
        <bind param="tex1" program="fp" />
        <program name="vp" type="vertex" source="sh.passthrudim.vp.glsl" />
        <program name="fp" type="fragment">
<![CDATA[

// Andrew Benson - andrewb at cycling74.com
//spatial downsampling

//setup for 2 texture
varying vec2 texcoord0;
varying vec2 texcoord1;
varying vec2 texdim0;
uniform vec2 amount;
uniform sampler2DRect tex0;
uniform sampler2DRect tex1;


void main()
{
    vec2 pix = (vec2(1.)-amount)*texdim0;
    vec2 pixcoord = (texcoord0/texdim0);
    pixcoord = floor(pixcoord*pix+vec2(0.5))/pix;
    pixcoord *= texdim0;
    vec4 pixelated = texture2DRect(tex0, pixcoord);
   
    // output texture
    gl_FragColor = pixelated;
}
]]>
        </program>
    </language>
</jittershader>


More information about the jitter mailing list