Jump to content
  • Advertisement
Sign in to follow this  
Daishim

Color Conversion

This topic is 4854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to figure out how pixel values from textures are converted into floating point values from [0..1]. Especially when working with GPU level languages (Cg specifically) and whether this conversion is something API does internally or something the GPU does independantly of the graphics API. I'm also quite curious as to how it is done. For example, in a 32bit RGBA image, does the API/GPU split out 8 bits for each color and just divide by 255? Or is there some other algorithm that is performed?

Share this post


Link to post
Share on other sites
Advertisement
I can't say for Cg or HLSL or any of these, I've never worked with neither of them and I don't know how they represent color values. Nor this HDR new trend. I don't know how these represent color data.

The classic way -as far I know- is the one you mention:
i.e. in 32bit ARGB the color is stored in memory as (these are bits)
AAAAAAAA RRRRRRRR GGGGGGGG BBBBBBBB
the correct index is read and naturally, if you want to represent it with a normalized float per channel, you should divide by its max value. API extensions that provide color functions to facilitate the definition of color, do the same thing.

At shader level, I'm sure this normalization is done internally by the hardware in order to provide you with color samples in the predefined range nomatter what the format is.

Share this post


Link to post
Share on other sites
Yes, it simply divides each component by its maximum value. So for 32-bit color (8 bits per component), each component is divided by 255.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!