I’m attempting to do:

position[0]

to get position.x where

vec4 position

and I’m getting a “cannot index a non-array value”. I’m using GLSL 1.2.

The OpenGL Shading Language book states:

Vectors can also be indexed as a zero-based array to obtain components. For instant, position[2] returns the third component of position. Variable indices are allowed, making it possible to loop over the components of a vector.

What am I doing wrong?

Paul