View Full Version : TEX instruction in Fragment Shader

06-03-2005, 06:37 AM
I have to read a value, in the fragment shader, using texture coordinates.

They exist the following command: TEX (e.g TEX result.depth, fragment.texcoord[1], texture[0], 3D; )

Definitin of TEX:

TEX v,u,t v texture sample
"v" indicates a floating-point vector input or output
"u" indicates a texture image unit identifier, and "t" indicates a texture target.

It means, fragment.texcoord[1] is the position in the texture where I want to read.
3D means that I'm working with a 3D texture
But what is texture[0]? How can I use it? How can I load data in the texture?


Java Cool Dude
06-03-2005, 08:02 AM
texture[0] is the texture currently bound to the first texturing unit.
It is read only, therefore you can't possibly write anything to it. Having said that, a solution to write into your texture would be to normaly render your scene before copying it using one of the several available methods (FBO, glCopy etc..)

06-06-2005, 11:23 PM
I know that I can't write in the texture, in the fragment programm. But how can I define, in the code , what is texture[0]?

06-07-2005, 01:34 AM

06-07-2005, 02:29 AM
Originally posted by Overmind:
glBindTexture(...);No... BindTexture works in 1D and 2D. And here, I don't really have a texture. I simply use a 3D texture to pass information to the Fragment program. And I have no idea how I can "fill" the 3D texture with data.

06-07-2005, 04:11 AM
Why shouldn't glBindTexture work with 3D textures?
And you upload 3D texture data like 1D and 2D textures, just use glTexture3D instead of 1D or 2D ;)

06-08-2005, 04:12 AM
The probleme is simply that this texture is not a real texture, that I want to display. It's simply data (a 3D structure, containing values) that I want to read in the fragment program. The problem is I have no idea of how to load my, e.g, 3D arrays, in a 3D structure (as if it was an image).