simple shader -- how to use unsigned chars for colors?
Hi, I am just learning OpenGLES 2.0, and I am trying to use an array of color values for my vertex colors. Rather than use floats I wanted to use unsigned chars for the RGB values, to save memory.
It seems to work but the shader compile is producing this warning:
WARNING: 0:25: Overflow in implicit constant conversion, minimum range for lowp float is (-2,2)
Here is the shader code I am using. I assume that the divide by 255 is producing the warning? What is the correct way to do this? Surely passing floats for colors is not a better option?
attribute vec4 position;
attribute vec3 normal;
attribute lowp vec4 color;
varying lowp vec4 colorVarying;
uniform mat4 modelViewProjectionMatrix;
uniform mat3 normalMatrix;
vec3 eyeNormal = normalize(normalMatrix * normal);
vec3 lightPosition = vec3(0.0, 0.0, 1.0);
float nDotVP = max(0.0, dot(eyeNormal, normalize(lightPosition)));
colorVarying = (color/255.0) * nDotVP;
gl_Position = modelViewProjectionMatrix * position;
Tags for this Thread