Re: GLSL and multitexturing

Geoff Stahl <[email protected]>
Newsgroups gmane.games.devel.opengl
Organization Fat City Network Services, San Diego, California
Message-ID <[email protected]>
There is a bug in your shader but I am not sure this is the only  
issue...

The fragment shader should read:
> // fragment shader
> uniform sampler3D A;
> uniform sampler2D B;
> uniform sampler2D C;
> void main (void)
> {
>     // texture2D needs a vec2 coords and GLSL does not allow  
> implicit type conversion
>     gl_FragColor =  texture2D(C, gl_TexCoord[2].xy);
> }

In my test app I get the correct results if I use gl_MultiTexCoord0  
as the source for gl_TexCoord[2] in the vertex shader, this is due to  
limitations of my test app, but does not fully test your issue, so  
there still could be problems.  But I can definitely adjust multiple  
texture units and see no unexpected interaction between binds,  
uniform settings and shader results (this is on Apple's GLSL so your  
milage may vary on yours).  So your expectations are correct, the  
question is whether there is an issue in you implementation (which I  
of course can't answer).

BTW, remember that samplers are texture units not texture names (I  
suspect you know this but wanted to mentioned it to be sure).

Geoff Stahl
3D Software Engineer
Apple

On May 29, 2005, at 11:03 PM, Rhadamés Carmona wrote:

> I am getting serious problems with multitexturing under GLSL. By  
> example, in
> this test (I commented most of the instructions) I cannot sample  
> the 2nd and
> 3rd texture properly. The "equivalent" code works in CG.
>
> I am using all front-end supposed stuff I have to know:
>
> glGetUniformLocationARB, glUniform1iARB ...
>
> Only the first texture can be sampled properly. I installed nvidia  
> drivers
> 71.89, and I am testing over fx5200. I am using glew from this zip  
> file
> glew-1.3.3-win32.zip. I am developping under glut.
>
> I found some guys with a kind of same problem in another forum. I  
> would want
> to know what's going on.
>
> http://www.cgshaders.org/forums/viewtopic.php? 
> p=13527&sid=72be21d52b43f0f5f7f7224e2953dc94#13527
>
> If you know any solution, please, let me know it.
> Rix
>
>
>
> //vertex shader
> void main()
> {
>   gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
>   gl_TexCoord[1] = gl_TextureMatrix[0] * gl_MultiTexCoord1;
>   gl_TexCoord[2] = gl_MultiTexCoord2;
>   gl_Position = ftransform();
> }
>
>
> // fragment shader
> uniform sampler3D A;
> uniform sampler2D B;
> uniform sampler2D C;
> void main (void)
> {
>   gl_FragColor =  texture2D(C, gl_TexCoord[2]);
> // it sux... I think, it samples the "last 2D texture binded" in  
> texture
> unit0, even with GL_TEXTURE_2D disable in unit0...Oh my GOD!!!
> }

----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

-- 
Author: Geoff Stahl
  INET: [email protected]

Fat City Hosting, San Diego, California -- http://www.fatcity.com
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [email protected] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.