Hi, all
I had a fragment shader like this:
void main(void)
{
if(A)
{
}
}
Hi, all
I had a fragment shader like this:
void main(void)
{
if(A)
{
}
}
So what? What is the question? Normally you should write to gl_FragColor!
[ www.trenki.net | vector_math (3d math library) | software renderer ]
Nice one. Maybe you should submit it to nVidia, they might want to include it in their shader-library.
Jan.
looks something is wrong when I post!
Hi, all
I had a fragment shader like this:
…
void main(void)
{
vec4 color(0.0);
if(A)
{
// convolution to texture_0
…
color = …
}
else
{
// convolution to texture_1 & texture_0
…
color =…
}
gl_FragColor = color;
}
It works OK.
the interesting thing is: the performance is decreased a lot( at least half) with above if /else branch. following are my testing results (for else part):
comment out the code in if branch( just have color = vec4(1.0, 0.0, 0.0, 1.0)
the performance is improved
separate the if /else into two functions, then call these two function in main() like "
void main(void)
{
vec4 color = vec4(0.0);
if(A)
color = caltexture_0(texture_0);
else
color = caltexture_1(texture_1);
}
"
the performance is improved too.
separate the if/else into two shaders. the performance is improved even better.
this only happens for complicated convolution, for simple convolution, there are no noticeable difference between above testing.
------------------thought it is related to the compiler ( I am working on linux, NV Quadro graphic card)-------------- anybody has a proven explanation for it?
many many thanks
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.