XML Feeds

.

[jitter] pixelate in openGL

Andrew Benson andrewb at cycling74.com
Mon Jan 14 12:51:57 MST 2008


Ha,
Agreed.  That's what happens when you start a shader with copy-paste.
:)

Feel free to remove any reference to tex1 or texcoord1 in the code, 
unless you want to use a second texture input for pixelation amount (or 
something).  Hmmm.

-ab
Wesley Smith wrote:
> Looks good, but I don't think you need any of the tex(coord)1 variables.
> wes
>
> On Jan 14, 2008 10:50 AM, Andrew Benson <andrewb at cycling74.com> wrote:
>   
>> 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>
>>
>> _______________________________________________
>> jitter mailing list
>> jitter at cycling74.com
>> http://www.cycling74.com/mailman/listinfo/jitter
>>
>>     
> _______________________________________________
> jitter mailing list
> jitter at cycling74.com
> http://www.cycling74.com/mailman/listinfo/jitter
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cycling74.com/pipermail/jitter/attachments/20080114/012a6cff/attachment.htm


More information about the jitter mailing list