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;
or
gl_FragColor = hatchColor2;
or
gl_FragColor = sum of any three color item.
I have tried use clamp(?, 0.0, 1.0), or
gl_FragColor = hatchColor10.5+hatchColor20.5, but all can’t pass it?
Could anyone give me some hints?
By the way, I am using ATI 9800XT and lastest driver.