I’ve got a small problem. I use a 3D noise texture now, but for some reason the application hangs when I do more than 3 lookups in the texture. I’m trying to do a cloudy sky and would like to use 4-5 octaves of this pregenerated noise. At first I thought that maybe there’s a limitation on number of lookups per texture unit, so I bound the texture object to texture units 0-3, but with the same result.
I have the same problem with doing a convolution (with a ATI 9800 pro):
when i try to lookup more than three times in my texture, my program crashs. I have the same problem with using a for loop.
uniform sampler2D BaseImage;
void main (void)
vec4 sum = texture2D(BaseImage, gl_TexCoord[0].st + vec2(0, 1));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(-1, 0));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(1, 0));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(0, -1));
I got a similar problem. When sampeling more than 3 textures glGetInfoLog returns me a warning, that the shader will run in software because of exceeding texture indirections…
I have no warning, my infolog is : “Link successful. The GLSL vertex shader will run in hardware. the GLSL fragment Shader will run in hardware.”, but i still have the problem
That’s a known flaw in ATI’s current glsl-implementation. I’ve noticed that (with 2D-texture lookups) some months ago, but ATI still haven’t fixed this.
This was btw. also the case with ARB_FP, where a similiar problem existed and took ATI some time to
fix.
It seems that ATI’s glsl-implementation takes normal lookups for dependant lookups, which isn’t correct. Hopefully they’ll fix that within one of their next drivers (instead of including such useless crap as those “smartshaders”).
Originally posted by pantxua:
[b]I have the same problem with doing a convolution (with a ATI 9800 pro):
when i try to lookup more than three times in my texture, my program crashs. I have the same problem with using a for loop.
uniform sampler2D BaseImage;
void main (void)
vec4 sum = texture2D(BaseImage, gl_TexCoord[0].st + vec2(0, 1));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(-1, 0));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(1, 0));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(0, -1));
gl_FragColor = sum * vec4(0.25);
}
But I have no solution[/b]
since you are storing the result of all texture lookups in the same temporary variable, it is technically a texture indirection.
one way to workaround would be to store the four lookups in four variables, and to add them to get your final sum.
thx but storing the four lookups in four variables has the same result than storing the result of four lookups in the same temporary variable. The hote that the next ATI driver will have a better compiler which will work with more than 3 texture lookups.
AFAIK there is a limit of 4 dependent texture reads on the Radeon cards. When you compute gl_TexCoord[0].st + vec2(0, 1), you’re computing a texture coordinate in the shader, thus it counts as a dependent read.
However, it looks like you’re using exactly 4 reads, so it should just work.
Alternatively, you can try computing the texture coordinates in a vertex shader and using them directly in the fragment shader. This will avoid the extra computations in the fragment program and turn dependent texture reads into independent ones.