View Full Version : Texture Access in Vertex Shaders
08-23-2005, 04:25 AM
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.
08-23-2005, 06:04 AM
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_FLOAT_R32_NVAre you using one of these formats? Also, what are you using as the LOD parameter for texture1DLod(), and do you have mipmapping on?
08-23-2005, 08:00 AM
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?
08-23-2005, 10:56 PM
Due to the fact that loops are unrolled in fragment shadersSuspicious.
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.
08-23-2005, 11:38 PM
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,
Originally posted by funkeejeffou:
I wasn't using one of these format.You SHOULD use those format only for texture fetch in vertex shader.
09-01-2005, 03:20 AM
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);
Is this code correct to chage the texture format?
Can anyone give me some help? I'm using an NVidia 6600GT.
09-01-2005, 05:10 AM
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.
09-01-2005, 05:13 AM
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.
09-01-2005, 07:42 AM
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.
09-01-2005, 07:57 AM
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.