View Full Version : Texture bug?

02-10-2004, 01:00 PM
Following is my fragment program for hatching effect rendering:

varying vec3 HatchWeights0;
varying vec3 HatchWeights1;

uniform sampler2D Hatch0;
uniform sampler2D Hatch1;
uniform sampler2D Hatch2;
uniform sampler2D Hatch3;
uniform sampler2D Hatch4;
uniform sampler2D Hatch5;

void main (void)
vec4 hatchTex0 = texture2D(Hatch0, vec2(gl_TexCoord[0])) * HatchWeights0.x;
vec4 hatchTex1 = texture2D(Hatch1, vec2(gl_TexCoord[0])) * HatchWeights0.y;
vec4 hatchTex2 = texture2D(Hatch2, vec2(gl_TexCoord[0])) * HatchWeights0.z;
vec4 hatchTex3 = texture2D(Hatch3, vec2(gl_TexCoord[0])) * HatchWeights1.x;
vec4 hatchTex4 = texture2D(Hatch4, vec2(gl_TexCoord[0])) * HatchWeights1.y;
vec4 hatchTex5 = texture2D(Hatch5, vec2(gl_TexCoord[0])) * HatchWeights1.z;

vec4 hatchColor1 = hatchTex0+hatchTex2+hatchTex4;
vec4 hatchColor2 = hatchTex1+hatchTex3+hatchTex5;

gl_FragColor = hatchColor1;

It is work, but what I want is

gl_FragColor = hatchColor1+hatchColor2;

This will have error when call glUseProgramObjectARB(0);

It will be ok, if in this way,
gl_FragColor = hatchColor1;
gl_FragColor = hatchColor2;
gl_FragColor = sum of any three color item.

I have tried use clamp(?, 0.0, 1.0), or
gl_FragColor = hatchColor1*0.5+hatchColor2*0.5, but all can't pass it?

Could anyone give me some hints?

By the way, I am using ATI 9800XT and lastest driver.

02-10-2004, 01:12 PM
Take a look at this thread : http://www.opengl.org/discussion_boards/ubb/Forum11/HTML/000014.html

It seems that ATI's glSlang-Implementation has problems with texture-reads and moreover mistakes some normale reads as dependant reads. This has (if I'm not mistaken) also been a problem in ARB_FP, but seems to have been fixed there.
Hope that this also gets fixed in a comming driver release, since it's sad that you can't do more than 5 texturereads even with some tricks and workarounds.

02-10-2004, 01:36 PM
Thanks for the information.

It seems I have to wait for ATI guys fix the bug. http://www.opengl.org/discussion_boards/ubb/frown.gif

[This message has been edited by tang_m (edited 02-10-2004).]