0

Apple suggests using the GLubyte data type for color data on iOS, so I am trying to get this to work. The result I get is that all color components <255 are completely black, and only components of colors set to 255 really are that color.

What I am doing: -Save the color of a single object in my own Color class in GLubytes (range 0-255) -Pass the colors to the shader in a vertex attribute array with type GLubyte (still range 0-255) -In the fragment shader, use the color directly or divide components by 255, both do not work.

EDIT: this does work, the problem was somewhere else in my code.

Jonesy
  • 83
  • 4
  • If using generic attributes, make sure you set the normalized flag in `glVertexAttribPointer`, so your values get transformed to [0,1] automatically. – Christian Rau Jun 10 '11 at 21:52
  • Passing colors as GLubytes in the range [0-255] and setting the normalized parameter to true yields the same results: still does not work? – Jonesy Jun 11 '11 at 09:31

2 Answers2

0

Where does Apple recommend using GLubyte for vertex attributes? I think you have misinterpreted that hint. What you actually want to do is store those values in a 256x1 grayscale (GL_LUMINANCE) texture and pass it as a uniform to the shader. This would be indeed faster than using arrays.

Alex Chugunov
  • 728
  • 5
  • 10
0

This does just work fine, the problem was somewhere else in my code.

Jonesy
  • 83
  • 4