Use same shader with different parameters ( uniform ) on several meshes

Hello,



I need your opinion on something,



I'm implementing the glsl bumpmapping, and at some point I need to apply this same shader to a large quad (actually it's  a bezier mesh, let's say 3x3). However the texture I want to apply is on this large quad, corresponds to a small quad (1x1) and so it's not properly scaled. So first I tried to use "setScale(new Vector3f(10f,10f,10f));" on each of my three texture (base, normal, height) however it didn't work, just like trying to redefine the UV coordinates working on the texture floatbuffer. I realize that very likely, this doesn't work because I apply the glsl render state (when I remove it, everything works for the re-scaling), so I came to the point where I have two possibilities:



-Whether I precompute with photoshop or the gimp my 3 textures (base/norm/height) so that they have the correct size (2x2, 3x3, … until let's say 20x20) so that everytime I want to use one (given that I know my mesh will be square) I just have to choose the appropriate one,



or



-I modify my shader so that it accepts a uniform "scale" parameter as an argument, but then (that's the name of the topic) how would I deal with using this same shader on different meshes where I want to use a different scale parameter (because I imagine that if I changed the parameter suddenly, all the meshes already rendered with the shader would also change). I think I have seen something like this on the forum before (I'm sure s.o. must have encountered the pb before me) but I couldn't find it through the search engine …



Or maybe should I just create several shaders, with different "scale" parameters, and apply them on the different meshes, but then, do you think it would be a waste of gpu time?



thanks for any comment,



Adrien

Look at "setShaderDataLogic(GLSLShaderDataLogic shaderDataLogic)" in "GLSLShaderObjectsState". It allows you to add code which will be executed for each geom which uses the shader. There you can add code to change the uniform.

thanks for the tip, I'll try that !!

Adrien