Hello,
I'm having a very weird problem with my shader. The shader has two main goals : update the saturation of an image and mix 2 textures. The thing is I don't need to update the saturation if I have a zero value in an uniform.
When I comment the function to update the saturation, I only have texture blending, and then I have around 70 fps. But when I'm adding the function, even if I set a zero value in the uniform, I get around 30 fps. The weird part is that nothing about saturation is computed, but performances are the same if the saturation is computed or not.
I don't know if you understand my problem so I'll show you the fragment I developped :
uniform float alphaShadow;
uniform bool enableHSVAdjust;
uniform vec3 hsvAdjust;
uniform sampler2D normalTex;
uniform sampler2D shadowTex;
varying vec3 position;
varying vec3 lightDir;
varying vec3 normal;
(...)
void main()
{
vec4 color = texture2D(normalTex,gl_TexCoord[0].st);
vec4 shadowColor;// = texture2D(shadowTex,vec2(position.x,position.y));
vec3 hsv;
if (enableHSVAdjust)
{
color = adjustHSV(color,hsvAdjust);
}
//light
vec3 ct,cf;
float intensity,at,af;
intensity = max(dot(lightDir,normalize(normal)),0.0);
cf = intensity * (gl_FrontMaterial.diffuse).rgb +
gl_FrontMaterial.ambient.rgb;
af = gl_FrontMaterial.diffuse.a;
ct = color.rgb;
at = color.a;
shadowColor = texture2D(shadowTex,(vec2(position.x/position.z,position.y/position.z)+1.0)* 0.5);
if (alphaShadow <=1.0)
{
shadowColor=1.0-shadowColor;
shadowColor*=alphaShadow;
shadowColor=1.0-shadowColor;
}
gl_FragColor = vec4(shadowColor*cf*ct,at*af);
}
The part with a performance trouble is this one :
if (enableHSVAdjust)
{
color = adjustHSV(color,hsvAdjust);
}
If I set enableHSVAdjust to false, it computes 30fps, and if I set it to true, also 30fps. But if I comment this code, I'll get 70 fps!!! I thought it was a glsl compiler issue but even if the code is not executed it shouldn't divide the fps by 2.
I hope someone will know why I'm having this issue.
Thanks in advance for your help,
Boris