Texture Access in Vertex Shaders

Hi,

I’m using in my fragment shader a loop to compute a certain numerical value. However, the quality of the result depends on the number of iterations that has been done. Due to the fact that loops are unrolled in fragment shaders, I am limited in term of iterations so I thought about doing the computation in the vertex shader(branching is possible, so no unrolling is needed) and the result will be passed as a varying variable to the fragment shader.

The problem is that my vertex shader compiles and links fine, but the result is rubish. I am sure that my algorithm functions well (it has been tested over and over), so I was wondering if the texture access that is used in the loop (1D Texture) wasn’t faulty here.

Has anyone had any issues while accessing textures in a vertex shader?

I would appreciate some help,
Thanks in advance.

Jeff.

First of all, describe “rubbish”?

Only a few texture formats are supported in vertex shaders. From the OpenGL 2.0 release notes at developer.nvidia.com:

GL_RGBA_FLOAT32_ARB,
GL_RGB_FLOAT32_ARB,
GL_ALPHA_FLOAT32_ARB,
GL_LUMINANCE32_ARB,
GL_INTENSITY32_ARB,
GL_FLOAT_RGBA32_NV,
GL_FLOAT_RGB32_NV,
GL_FLOAT_RG32_NV,
GL_FLOAT_R32_NV
Are you using one of these formats? Also, what are you using as the LOD parameter for texture1DLod(), and do you have mipmapping on?

I wasn’t using one of these format. I checked some papers from Nvidia, only 2D textures are supported and no linear filtering can be achieved…

I’ve disassembled my code with NvShaderPerf and there is something bugging me : In fact with 128 iterations in my fragment shader, I only have 900 instructions. The limit being 65535 instructions, I don’t understand why my code fails (in terms of execution, not compilation) with 256 or even 1024 iterations. Even disassembling the shader with more thant 128 iterations fails…

Someone had any GLSL / Driver77.77 issues?

Due to the fact that loops are unrolled in fragment shaders
Suspicious.

What hareware are you using, by chance?

I ask because I am aware of no hardware that is both incapable of looping in fragment shaders and capable of vertex texturing. Only NV40/50 hardware can do vertex texturing, and both of them can branch in fragment shaders. No ATi hardware is capable of vertex texturing.

I have a GeForce6600 and whatever the driver I use (actually 77.77), the code compiles but I only get a black screen when I exceed approximatively 130 iterations. I’ve read in the forum that the 80.40 were good concerning GLSL compiler but they sucks, older code that was perfectly running doesn’t even compile.
Are the 77.72 better ?

For the loops in the fragment shader, the end condition is static so that the compiler unrolls everything (you’re right, no branching in fragment shaders on NV4x). So my code should compile and work as there isn’t a real constraint on the size of the shaders (technically 65535 instructions is the max, but if you exceed it, the compiler should split the code in multiple fragment shaders). But I cannot go over 900 instructions…

I would appreciate some feed back, I am sure some people have encountered this kind of loop problem before.

Thanks in advance,
Jeff.

Originally posted by funkeejeffou:
I wasn’t using one of these format.
You SHOULD use those format only for texture fetch in vertex shader.

I’m also having problems in accessing textures in the vertex program. I I use a texture format of GL_RGB I get about 0.5 fps. When I change the format to GL_FLOAT_RGB32_NV I just get a black texture.

gluBuild2DMipmaps(GL_TEXTURE_2D, GL_FLOAT_RGB32_NV ,w,h, GL_RGB, GL_UNSIGNED_BYTE, pixels);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);

Is this code correct to chage the texture format?
Can anyone give me some help? I’m using an NVidia 6600GT.
Thank you.

First of all, you cant use NV_float_buffer extension with GL_TEXTURE_2D target, but you can use GL_RGBA32F_ARB as a internal format of texture.
Second current HW doesnt support filtering with 32bit float textures.

Only floating point vertex texture formats are hardware accelerated on GF6.
Read this http://developer.nvidia.com/object/using_vertex_textures.html

Not sure if gluBuild2DMipmaps supports float targets correctly. The GLU lib on Windows is stuck at an old release. Try downloading float textures directly with mipmap generation enabled.

I read the paper Relic pointed me. After reading I think my problem is with the GLSL language and the ARB vertex program “language??”. Can please just take a look at my last post in 31/09/2005.
Thank you.

All right!! I’ve used the format GL_RGB32F_ARB and it worked.
Thank you guys. I’m sorry if these seem to be rookie questions but I’m just in the begining.

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