Using a vertex component for color attenutation


I am using a float RGB fbo to vbo to set xy point sprite coordinates and a z component which holds a color attenuation value. This works ( point sprites are rendered in the desired location but the attenuation of color is not ).

Output of vbo:

row:0 . x:0.562707  y:0.501293  attenuation:0.000013
row:1 . x:0.561881  y:1.499482  attenuation:0.000003
row:2 . x:0.560692  y:2.497944  attenuation:0.000012
row:3 . x:0.558725  y:3.496814  attenuation:0.000045
row:4 . x:0.557186  y:4.496929  attenuation:0.000073

You can see that the attenuation value is set.

The following are the shaders I apply to the draw call for point sprites:

// Vertex shader
static NSString*    k_Shader_Vertex_Render    =
@"varying float shader_Brightness_Attenuation;\n"
"void main( void )\n"
"   shader_Brightness_Attenuation = gl_Vertex.z;\n"
"   gl_Position = gl_ModelViewProjectionMatrix * vec4( gl_Vertex.x, gl_Vertex.y, 0.0, 1.0 );\n"
// Fragment shader
static NSString*    k_Shader_Fragment_Render =
@"varying float shader_Brightness_Attenuation;\n"
"void main( void )\n"
"   gl_FragColor = vec4( shader_Brightness_Attenuation );\n"

The gl_FragColor works if I set it explicitly. When I use the shader_Brightness_Attenuation which is set to the gl_Vertex.z component it comes up zero or uses the glColor instead.

I want to attenuation the glColor with the gl_Vertex.z. This is not happening.

Any ideas?

thank you,


I know it will be said that my vertex indices are off in my use of the vbo and that would make sense except that all x and y coordinates are correct which means z has to be as well ( they are packed, none skipped ). Setting the .w coordinate the same as well as .z fixed the issue. If I do not set them both it does not work. It is odd, ATI only issue I have found.