PDA

View Full Version : glsl count in fragment shader



borodadada
06-10-2015, 07:03 AM
Hello, i need color change of the rectangle for that I need to make a counter , how to do it ?
#version 430

out vec4 FragColor;

float counter = 0;

void main(){

counter++;
FragColor = vec4( 1,0,0,1 );
};

This count not work.

GClements
06-10-2015, 07:12 AM
You need to use an atomic counter (https://www.opengl.org/wiki/Atomic_Counter).