Le 08/04/2013 17:47, Patrice Colet a écrit :
> I've implemented all the stuff for flipping horizontaly and verticaly, 
> there is an attached example, but it's not very elegant, there is warning 
> messages even if it works good, maybe there is a better way to do it?
>
>
> Colet Patrice
>
> ----- Mail original -----
>> De: "Patrice Colet" <colet.patr...@free.fr>
>> À: "pd-list" <pd-list@iem.at>
>> Cc: "Cyrille Henry" <c...@chnry.net>
>> Envoyé: Lundi 8 Avril 2013 16:37:29
>> Objet: Re: [PD] flip image in glsl
>>
>> Got it, thanks a lot!
>>
>> Colet Patrice
>>
>> ----- Mail original -----
>>> De: "Cyrille Henry" <c...@chnry.net>
>>> À: "Patrice Colet" <colet.patr...@free.fr>
>>> Cc: "pd-list" <pd-list@iem.at>
>>> Envoyé: Lundi 8 Avril 2013 10:05:22
>>> Objet: Re: [PD] flip image in glsl
>>>
>>> hello,
>>>
>>> when using rectangular texturing, coordinate goes from 0 to image
>>> pixel size.
>>> when using "rectangle 0" mode, pixel coordinate goes from 0 to 1.
>>> (sometimes 1 is for the power of 2 bigger than the image pixel
>>> size)
>>>
>>> so, in rectangular mode, use pixetl_size - image coordinate to flip
>>> the image.
>>> and 1 - image coordinate in non rectangle mode.
>>>
>>> Image can be fliped because the "fliped" flag is not used on the
>>> shader.
>>>
>>> cheers
>>> c
>>>
>>>
>>>
>>> Le 08/04/2013 09:24, Patrice Colet a écrit :
>>>> Hello,
>>>>
>>>>   how is it possible to flip upside down an image in glsl example
>>>>   05.multitexture
>>>>
>>>> I tried to implement this in fragment program:
>>>>
>>>> http://stackoverflow.com/questions/9857089/flip-upside-down-vertex-shader-gles
>>>>
>>>> but it doesn't work. The only thing I can do is changing texture
>>>> scale and position, but I couldn't do it with negative values
>>>> like it would be done in pix_coordinates.
>>>>
>>>> In fact when I use pix_multiimage before pix_texture, the image
>>>> gets flipped, I don't know why...
>>>>
>>>> Colet Patrice
>>>>
>>>>
>>>> _______________________________________________
>>>> Pd-list@iem.at mailing list
>>>> UNSUBSCRIBE and account-management ->
>>>> http://lists.puredata.info/listinfo/pd-list
>>>>
>> _______________________________________________
>> Pd-list@iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> http://lists.puredata.info/listinfo/pd-list
>>
>>
>>
>> _______________________________________________
>> Pd-list@iem.at mailing list
>> UNSUBSCRIBE and account-management -> 
>> http://lists.puredata.info/listinfo/pd-list
Hello Patrice,

You can do operations directly on vec2 instead of two floats in your
fragment shader.
You can also avoid condition (could be slow).
See patch and glsl vertex and fragment attached for flip.
++

Jack


Attachment: 06.rectangle_multitexture_flip.pd
Description: application/puredata

//jack/RYBN 2010
#extension GL_EXT_gpu_shader4 : enable
#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect Ttex1;
uniform sampler2DRect Ttex2;
uniform sampler2DRect tex0;
uniform float style;
uniform float mix_factor;
uniform vec2 flip1, flip2;
uniform vec2 dimen;

varying vec2 texcoord0;
ivec2 size1 = textureSize2DRect(Ttex1, 0);
ivec2 size2 = textureSize2DRect(Ttex2, 0);
ivec2 size0 = textureSize2DRect(tex0, 0);

void main (void)
{
        vec2 sizeF1 = vec2(size1)/vec2(size0);
        vec2 sizeF2 = vec2(size2)/vec2(size0);
        vec4 color1 = texture2DRect(Ttex1, abs(flip1*dimen-texcoord0)*sizeF1);
        vec4 color2 = texture2DRect(Ttex2, abs(flip2*dimen-texcoord0)*sizeF2);

        if (style == 0.) {
                gl_FragColor = (color1 + color2);
        } else if (style == 1.) {
                gl_FragColor = (color1 - color2);
        } else if (style == 2.) {
                gl_FragColor = abs(color1 - color2);
        } else if (style == 3.) {
                gl_FragColor = (color1 * color2);
        } else if (style == 4.) {
                gl_FragColor = mix(color1,color2,mix_factor);
        }

}

//jack/RYBN 2010
varying vec2 texcoord0;

void main()
{
        texcoord0 = (gl_TextureMatrix[0]*gl_MultiTexCoord0).st;
        gl_Position = ftransform();

}
_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to