Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Weird behavior of shaders with variable index  (Read 841 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 9
    • View Profile
Weird behavior of shaders with variable index
« on: December 03, 2016, 06:20:45 pm »
I am learning GLSL shaders and i wrote very simply light system.
When I want add all lights by using variable like this:
int var = 10;
gl_FragColor = light[0];
for(int i = 1; i<var; i++)
   gl_FragColor *= light[i]
I see graphics artifacts:

But when I  write indexes manually (i use vars because i want add lights in loop, not manually) like this:
gl_FragColor = light[0] * light[1];
Everything works fine:

Why I have artifacts?
« Last Edit: December 03, 2016, 06:25:25 pm by ifinox »