OK, this works. There's a GLSL shader with 4x Sprite patches inside it.Each Sprite has a different value for the Red channel of it's Color input. The Red channel is read in the Vertex Shader from gl_Color. That value is used to offset the texture coordinates on the X-axis. I also had to scale the X-axis texture coordinates so that they only covered 1/4 of the width of the texture (since it was a strip of 4 different graphics in a horizontal row). The logic would be a bit more complex for a sheet of different textures arranged in a grid, rather than a strip, but the principle would be the same, except you'd need to scale and offset on both X and Y axes.
alx
tb GLSL TexOffset Demo.qtz
Description: application/quartzcomposer
On 17 Mar 2010, at 10:06, Chris Wood wrote:
Just to be clear, you can have one shader applied to multiple objects but it will apply the same texture/effect/whatever to every object. Fine if you want say lighting applied to everything, but not if you want separate textures. One solution: give each object a unique colour, and use the colour to select a texture from an array by index. ChrisOn 17 March 2010 09:51, thomas pachoud <[email protected]> wrote:Hi,not 100% sure, but I don't think you can use one single GLSL for multiple objects. You should use one GLSL applied to each objects. In this way, each objects will apply the same GLSL with his textures and 3D positionning and lighting information. And if you need to act on full scene, you should add one GLSL at the end of your pipeline, playing on your 2D final rendering. On Tue, Mar 16, 2010 at 9:35 AM, George Toledo <[email protected]> wrote:I may be wrong, but I don't believe that is possible in QC. What you would need to do is use a separate shader for each object. GLSL in QC does support multiple textures, but I don't think one can assign them to arbitraryobjects in the scene.I'm curious about this as well... I've successfully used GLSL in QC to send many different image sources to a shader, and to use the shader to crop, translate and dissolve, but that is in the context of a 2D surface. Is there a downside to putting each object in a separate GLSL macro, and using distinct textures for each in your scenario? You can always connectthe join the lighting of each (or any other parameter) with insertsplitters, so your multiple shaders can look cohesive in the scene when youmove a light source (or whatever). -George ToledoOn Mon, Mar 15, 2010 at 7:11 AM, luca palmili <[email protected]> wrote:Hi to all,my scene is composed by N objects (o1, o2..., oN), each of them has got one different texture (t1, t2, ..., tN). How can I render all the objects in a single GLSL shader? I mean: if I pass my N texture as uniform parameters to the GLSL shader, how can I tell to the GLSL shader to use texture_1 forobject_1, texture_2 for object_2, etc...? Thank you! _______________________________________________ Do not post admin requests to the list. They will be ignored.Quartzcomposer-dev mailing list (Quartzcomposer- [email protected])Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/quartzcomposer-dev/ gtoledo3%40gmail.comThis email sent to [email protected]_______________________________________________ Do not post admin requests to the list. They will be ignored.Quartzcomposer-dev mailing list (Quartzcomposer- [email protected])Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/quartzcomposer-dev/ thomas.pachoud%40gmail.comThis email sent to [email protected]-- Thomas Pachoud ingénieur multimédia IMAC www.creapach.fr _______________________________________________ Do not post admin requests to the list. They will be ignored.Quartzcomposer-dev mailing list (Quartzcomposer- [email protected])Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/quartzcomposer-dev/psonice% 40gmail.comThis email sent to [email protected]_______________________________________________ Do not post admin requests to the list. They will be ignored.Quartzcomposer-dev mailing list (Quartzcomposer- [email protected])Help/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/quartzcomposer-dev/the_voder% 40yahoo.co.ukThis email sent to [email protected]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com This email sent to [email protected]

