[osg-users] Problem with shaders
Guy Lifchitz
prometheus.the.great at gmail.com
Tue Jul 24 03:07:49 PDT 2007
It is a sampler variable, I'm sorry I wasn't accurate with the code snipest.
The problem is not with the syntax. Iit compiles and runs, but as I
mentioned before, it acts differently if the loop termination parameter is
constant that can be decided at compilation time, or run-time variable.
Now I want the shader to be able to deal with varying number of textures and
not constant, (basicly I want to do something similar to OpenGL
multitexturing and therefore each rendered object might have different
number of textures).
I tried to pass the number of texture in the uniform unf_nTextures.
Now in a given scene I know for sure that unf_nTexture equals 1 and then the
code
a.
for(int iTexture = 0; iTexture < unf_nTextures; ++iTexture)
{
Color = texture2D(texUnit0, gl_TexCoord[iTexture].st);
}
equivalent to
b.
for(int iTexture = 0; iTexture < unf_nTextures; ++iTexture)
{
Color = texture2D(texUnit0, gl_TexCoord[0].st);
}
which also equivalent to
c.
for(int iTexture = 0; iTexture < unf_nTextures; ++iTexture)
{
if(iTexture == 0)
Color = texture2D(texUnit0, gl_TexCoord[iTexture].st);
}
where texUnit0 is sampler2D
and to
d. for(int iTexture = 0; iTexture < 1 ++iTexture)
{
Color = texture2D(texUnit0, gl_TexCoord[iTexture].st);
}
but a. and c. result in color = 0,0,0,0 while b. and d. result with the
correct color from the texture (but they don't work on varying number of
textures)
I know that currently also if the varying number of textures would have
worked, I'm accessing in the loop the same texture (texUnit0), but after
I'll get this to work I want to replace the texUnit0 by an array of
sampler2D.
so, any ideas why it doesn't work with the varying number of textures?
thanks,
Guy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070724/f8b1101b/attachment.html
More information about the osg-users
mailing list