Best RGBA colour format?

Hi,

I was wondering if there is an RGBA format that is most widely optimised by OpenGL drivers; for instance, is it usually better to specify RGBA values as bytes rather than floats?

Thanks for any insights!
Iain

… I should mention that this is in relation to glColor calls and materials definitions.

Iain

Heard (I mean read) on this forum earlier, that a GeForce, for example, won’t use hardware T&L if you pass vertices as other types that float, if you do, it will fall back on software T&L.

And (almost) everything is used as floats, so if you stick to floats, no unessecary type casts will occur. And floats are quite fast too.

Thanks for replying Bob. You refer to vertices here, but I was really wanting to know about RGBA values - does this advice hold for those as well? It’s really for things like glColor that I need to know, but I guess it’s also important when uploading textures.

I was under the impression that using byte triples/quadruples was the preferred method for RGB/RGBA values, but maybe I’m wrong.

Hi there !

Well Bob, you are right : for vertices/normals/texcoords, one should use floats to have the best acceleration…

On the other hand, for colors, one should use bytes !

There is a paper at nvidia.com about which types to use…

Regards.

Eric

Thanks Eric, I should have guessed that NVidia has info on it!

Well, yeah, I was talking about vertices, but as an example that types DO matter in some cases.

Anyways, didn’t know you should use bytes in colors though. Though it was floats, because keeping the colors in the range [0.0, 1.0] will make all calculations easy since no normalization is needed. I guess I have to read the paper too

Hi again !

Bob, I agree with you : I started doing everything with floats before discovering that nVidia advised to use bytes for colors…

Regards.

Eric

Yes, I’m currently using floats, but I suspect that bytes are more widely supported.

I must see if there’s any documentation on other graphics cards manufacturer’s websites.

… and I still haven’t read the document

Well, I can see a reason to use a specified type for vertices, since it’s used in HWT&L. But, I can’t see any major reason (I don’t consider float->byte-converion as major reason) to use a specific type for colors. Is there any reason for this, I mean something like the above mentioned hardware or software acceleration for two different types?

Well, if you do your own lighting and pass OpenGL a colour for each vertex, then it’s presumably better to send the colours in its ‘native’ format to save a little time.

Apart from that, I can’t really think of a place where you’d send lots of colour information (apart from when you upload a texture, in which case it’s almost certainly best to use the ‘native’ format if possible, to save time).