opengl - What is the most efficient way to store/pass color values (vertex attribute)? -
is there way store color values on vram other float per color component ?
since color can represented byte per component, how can force fragment shader range color component [0-255] instead of default range [0.0-1.0]
if use type gl_unsigned_byte
, have set bool normalized gl_true
convert them 0.0-1.0 values can interpreted fragment shader?
the output of fragment shader independent of input of vertex shader. example storing colors in rgba 8 bit format somehting this.
//... glvertexattribpointer( 0,4,gl_unsigned_byte,false,4,0); //...
in vertex shader
//the unsigned bytes automatically converted floats in range [0,255] //if normalized have been set true range [0,1] layout(location = 0) in vec4 color; out vec4 c; //... c = color; //pass color fragment shader
fragment shader
in vec4 c; out vec4 out_color; //output (a texture framebuffer) //.... //the output of fragment shader must converted range [0,1] unless //you're writing integer textures (i'm asuming not here) out_color = c / 255.0f;
Comments
Post a Comment