[osg-users] Problem with shaders

Robert Osfield robert.osfield at gmail.com
Mon Jul 23 09:12:07 PDT 2007


Hi Guy,

To read a texture in GLSL you using texture2D rather than sampler2D,
is sampler2D a function you've provided?

Robert.

On 7/23/07, Guy Lifchitz <prometheus.the.great at gmail.com> wrote:
>
> Hi,
>  I have some code in the fragment program that acts really suspiciously it
> goes like this:
> at the end it suppose to be
> for(int iTexture = 0; iTexture < unf_nTextures; ++iTexture)
> {
>     Color += sampler2D(iTexture, gl_TexCoord[iTexture].st);
> }
>
> for debugging purpose I wrote
>
> for(int iTexture = 0; iTexture < unf_nTextures; ++iTexture)
> {
>     Color = sampler2D(iTexture, gl_TexCoord[iTexture].st);
> }
>
> now I checked by setting the Color in different code that unf_nTextures is
> 1.
> the code above results with Color = 0.0,0.0,0.0,?
> on the other hand
>
> for(int iTexture = 0; iTexture < unf_nTextures; ++iTexture)
> {
>     Color = sampler2D(0, gl_TexCoord[0].st);
> }
>
> results correctly (when there is only one texture of course).
>
> another strange phenomenon is that the code
>
> for(int iTexture = 0; iTexture < unf_nTextures; ++iTexture)
> {
>     if(iTexture == 0)
>         Color = sampler2D(0, gl_TexCoord[iTexture].st);
> }
> also results with Color = 0.0,0.0,0.0,?
>
> any ideas?
>
> thanks,
>  Guy.
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>


More information about the osg-users mailing list