[PD] Gem / glsl_fragment

cyrille henry ch at chnry.net
Sat Jul 30 12:01:01 CEST 2011


Hello ub,

yes, some things are strange with shaders texture coordinate, specially with multi-texture.
in fact, only 1st texture coordinate is set to correct value, not the others.
so you have to compute texture coordinate according to the textures size.

That's why you need a pix_set : it will initialise texture size, if you don't have a pix_image after the shader.

I don't thing you really need to use rectangle texture with 4:3 input : non rectangle should work to. (if you scale accordingly the texture coordinate).
(you can have a look at how it's done in example 06).


if the example multitexture works for you, but not rectangle_multitexture, it's probably because you system did not allow you to create rectangle texture (this is strange).
or maybe because some function use to get the image size did not work for you. (what is your GPU?).
you can try to change shaders line :

ivec2 size1 = textureSize2DRect(Ttex1, 0);
ivec2 size2 = textureSize2DRect(Ttex2, 0);
ivec2 size0 = textureSize2DRect(tex0, 0);
vith :
ivec2 size1 = (256, 256);
ivec2 size2 = (234, 543);
ivec2 size0 = (512, 512);



I never tried to use a pix_object (contrast or add) when using a shader, because a shader can easilly do the same thing but lot's faster.

I'm quite familiar with the flashing your experimenting : it's usually a problem with texture coordinate.
You can experiment with adding a scale factor for the texture in order to understand a bit more how things work :

good luck
Cyrille



Le 30/07/2011 01:42, ub at xdv.org a écrit :
> hey there again,
>
> i basically got my shader running, it was a bit of a challenge, because i realized i had to use rectangle texunits, as the input is classic 4:3 video frames.
>
> so fine, i did this, but now the output of pix_progam is acting kind of weird.
> it seems to be a proper pix structure, when i attach a pix_info to it, it's the correct resolution and type.
> it is possible that it is still an bug in my shader, but for instance i see in the example patch 06.rectangle_multitexture that there is a pix_set right after the pix_program and also in my patch things dont work correctly when i don't put it there.
> i wonder what it's needed for.
>
> still with the thing in place, the texturing behaves strange. for example, if i put an object like pix_contrast or pix_add in it's way, i only see some blue flashing. the flashing seems like one pixel of the texture magnified to the whole surface.
> so i thought it's the texture coordinates and i tried pix_coordinates to correct them without success.
>
> then the texture won't display on pix_draw at all, which is fine, i can live without it.
>
> pix_flip doesn't do anything but it doesn't screw up the texture.
>
> when i use the output of the rectangle_multitexture example i have basically the same effects slightly different in some cases.
>
> maybe i'm missing something obvious, i have tried a lot and i will continue to look, but if someone knows more about this i'd be happy with some explanations.
>
> thanks+ciao,
> ub
>
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
>



More information about the Pd-list mailing list