TEX instruction in Fragment Shader

Hi
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?

Thanks

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…)

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]?

glActiveTexture(GL_TEXTURE0);
glBindTexture(…);

Originally posted by Overmind:
glActiveTexture(GL_TEXTURE0);
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.
Thanks

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 :wink:

Ok
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).
Thanks

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.