[PD] gem/GLSL: how to compute correct coordinates for rectangular textures
Matteo Sisti Sette
matteosistisette at gmail.com
Sun Jan 3 21:17:29 CET 2010
Hi,
I guess if I had a deep understanding of openGL I could find the answer,
but I am obviously looking for a shortcut (at the moment) to solve the
specific problem I'm facing which should be pretty simple.
In the attached patch I try to use a trivial shader to texture a
rectangle with an image; the uniform variable "curtex" tells the shader
which texture to use.
It works fine if all images have the same size; however, if the textures
have different sizes, no matter the value of "curtex", the texture
coords that are computed are correct for the image loaded by the
[pix_image] that immediately follows the [glsl_program], but are not
correct for other images.
So the question is: how should I change the vertex and/or fragment
shader code (or the patch maybe) so that the texture coordinates are
computed according to the dimensions of the texture that is actually
sampled?
It is important to NOT assume that the textures come from [pix_image]
objects, or at least, that they are loaded from image files: actually,
in real life, textures may be the video input generated by a [pix_film]
or an image captured by a [pix_snap].
Thanks a lot in advance
--
Matteo Sisti Sette
matteosistisette at gmail.com
http://www.matteosistisette.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: trivialshader.frag
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20100103/3a92282d/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_trivial_shader.pd
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20100103/3a92282d/attachment.asc>
More information about the Pd-list
mailing list