Hi all,
1.Why wouldn’t it work ? (i made bold text of where I`m causing the problem)
2.There is any performance benefit to save TD_NUM_COLOR_BUFFERS into int variable if used more than one ?
[code]int bufferNum = TD_NUM_COLOR_BUFFERS;
out vec4 fragColor[bufferNum];
void main(){
fragColor[0] = vec4(vVertex.color);
for (int i = 1; i < bufferNum ;i++)
{
//fragColor[i] = vec4 (1.0);
if (i == 1 )
{
fragColor[i] = vec4(vVertex.camSpaceVert,1.0);
}
if (i == 2 )
{
fragColor[i] = vec4(vVertex.normal,1.0);
}
}
}[/code]
In the past I’ve done it this way
out vec4 fragColor[3];
void main(){
fragColor[0] = vec4(vVertex.color);
fragColor[1] = vec4(vVertex.camSpaceVert,1.0);
fragColor[2] = vec4(vVertex.normal,1.0);
}
As long as the number of color buffers is set to 3 on the Render TOP I think it’ll be ok.
Hi David thanks for the reply,
It works for me without the variable assignment,I just not sure why its not working
once I do
int bufferNum = TD_NUM_COLOR_BUFFERS;
Does declaring it as constant work?
const int bufferNum = TD_NUM_COLOR_BUFFERS;
Yes!
thank you,but why ?
maybe fragColor is kind of function that behave like this ?
fragColor[const variable]
Ideally you’d use TD_NUM_COLOR_BUFFERS directly. This is a define and would be faster than assigning it to a variable.