RBG values are 0-255 integers, so why was float4 chosen as the vector data type?
Seems to me that byte would be the ideal data type for a color in Fuse.
RBG values are 0-255 integers, so why was float4 chosen as the vector data type?
Seems to me that byte would be the ideal data type for a color in Fuse.
RGB values are only 1-byte (0-255) values in some contexts. There are numerous color spaces in common use which use more or less than 1 byte to repesent colors (such as compact 8bit and 16bit colorspaces, or HDR colorspaces using 16 or even 32 bits per channel). These aren't just theoretical uses, when dealing with images and GL textures they are used.
What's important is that each of these represent a range of values, from 0, no intensity, to 1, full intensity, for that channel. This is why float
is used: it's the correct semantic type to represent a normalized range. It's also happens to be what OpenGL, the default graphic backend for Fuse, uses to represent colors.
float
has the advantage of being a continuous value, unlike a byte
which has discrete increments. This is important for interpolation. Consider animation between two colors, having a linear gradient, changing the opacity, or decreasing saturation; all of these need to be done on a continuous value range, such as float.
float
also allows values to go about 1, and below 0. While these cannot be reflected in the final display they play a role during calculations. If you're doing many color operations in sequence you don't want to prematurely clamp your values.
Don't worry about things like memory bandwidth or storage space. Actual stored color values are a miniscule fraction of what occupies memory.
Also, the common hex syntaxes for color notation are supported in Fuse. You can use a simple #FAA
for a light red, or #AB74FD80
for a more precise half-transparent color.
First I'm going to assume that by float you mean a 4-byte value.
I could probably keep going but you get the idea.