GLSL Uniform!

Started by
5 comments, last by golgoth 18 years, 6 months ago
Hi all! for some mysterious reason i cant do this... uniform int Count; void main() { for (int i = 0; i < Count; i++) { ...... } } any work around for this?
Advertisement
Hardware support for dynamic looping isnt wide spread, as such that will fail to compile if it cant be done on the hardware.

Away around it, make it a static loop, however with this you have to be carefull not to blow the instruction limit if the hardware requires the loop to be unrolled.
the "Count" var is pass as the number of per pixel light in scene... i dont see any way out... thats a big problem... there is no way i can imagine hardcoding light count! if it s what u mean!
could we do something like this:

uniform int Count;

void main()
{
for (int i = 0; i < 100; i++)
{
if (i > Count)
{
break;
}

}
}

not sure how to translate the break:

any ideas?
not even working... like a slap in the face!

[Edited by - golgoth on September 22, 2005 9:55:01 PM]
What GPU are you using? It really shouldn't matter, because if the GLSL program is too complex to be executed in hardware, it should fall back to software rendering. But unfortunately, most implementations are not so compliant.
gforce 6800 on amd pcix architecture!

whenever i try to implement an uniform variable into a for or even a while condition-expression... it does not compile at all!

it doesnt make any sens...

i ve tried:

uniform int Count;

void main()
{
for (int i = 0; i < 100; i++)
{
if (i < Count)
{
....
}
}
}

im having a nigthmare... can anyone snap me out of it?

is that will means a uniform variables cannot be written in shaders?

Phantom can u be more precise on static loop pleaze?

thx

[Edited by - golgoth on September 22, 2005 11:17:37 PM]

This topic is closed to new replies.

Advertisement