[GEM-dev] rectangle texture coords in GLSL shaders

chris clepper cgclepper at gmail.com
Wed Aug 29 17:07:04 CEST 2007


In order to make certain texture manipulations work using rectangle textures
(sampler2DRect) the shader needs to know the absolute pixel dimensions of
the image.  The only way to do this is to pass the shader those values from
an outside source.  The two methods I have figured out are as follows:

1) Create a reserved uniform variable like 'TextureUnit1Dimensions' and pass
the dimensions from the GemState to any shader with that uniform in the
shader.

2) Use pix_info to read the dimensions and pass them to the shader using a
message to glsl_program.  The shader just needs a uniform vec2 that matches
the message.

The first one is more automagic but it requires knowing the exact magic
variable name(s) to make working shaders.  The second follows the Pd
paradigm better and allows for the shader to use any name for the uniform.

I'm leaning to the second option as the most flexible and sensible even
though it probably presents a higher margin of user error and makes for
additional patch clutter.  It also requires no change to the existing code!

Thoughts?

cgc

PS- This came up while working with Anton to get the vade shader set fully
functional in GEM.  These changes will make that happen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/gem-dev/attachments/20070829/aecb301d/attachment.htm>


More information about the GEM-dev mailing list