Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  
katsh

D3DFMT_R5G6B5 act like strange

This topic is 4670 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 dont know this is my vid card issue or direct3d issue. my video card is nvidia quadro fx500. when i create d3d device with D3DFMT_R5G6B5 format, everything looks a bit green.(especialy when doing alpha blending) same 16bit format like D3DFMT_X1A5G5B5 has no color problem..hmm does any1 have had same "green problem"? [Edited by - katsh on January 7, 2007 9:03:05 AM]

Share this post


Link to post
Share on other sites
Advertisement
Not a lot of people use 16 bit display buffers these days. 32 is standard. R5G6B5 does have a different number of bits for green, which could cause accuracy differences, which might lead to what you see.

Share this post


Link to post
Share on other sites
Quote:
Original post by katsh
i dont know this is my vid card issue or direct3d issue.
my video card is nvidia quadro fx500.

when i create d3d device with D3DFMT_R5G6B5 format,
everything looks a bit green.(especialy when doing alpha blending)
same 16bit format like D3DFMT_X1A5G5B5 has no color problem..hmm

does any1 have had same "green problem"?


It's a pretty well known problem, as you noticed R5G_6_B5, uses one extra bit to store the green value of your color.
So that means that the value instead of going from 0 to 31, it goes to 0 to 63.

If you trace those values onto the brightness axis, you can see that those two ranges never match except at 0 % brightness and 100% brightness.

Because of that, a "neutral" gray value doesn't exist. So if you want to represent 50% gray, you have to choose between 16/32/16 or 15/31/15 or 16/31/16 or 15/32/15. Does that look ok to you ? look again, 16 on red/blue maps to 16/31 = 51.6% brightness, 15 maps to 15/31 = 48.4% brightness. 32 on green maps to 32/63 = 50.7% brightness, 31 on green maps to 49.2% brightness.

If you chose 16/32/16, then the magenta value (red+blue) is higher than the green value, instead of neutral gray you will have a value that tends to pinkish/magenta. If you chose 15/31/15, the green value is higher than the magenta value and you will get a pale green instead of the neutral gray that you expected.

Then what happens when you alpha blend repeatedly the same gray value :
the 1% difference will grow to a 2%, then 3%, etc.. until it all looks green instead of gray or white.

R5G6B5 would be only fine, as long as it is used to display static unstretched images, that have been properly dithered : randomly select between 16/32/16 and 15/31/15 encoding of gray so that visually the adjacent colors looks neutral to you. For 3D rendering it is the plague, not suitable to texture from r5g6b5, not suitable to render directly to r5g6b5 and hardware that use dithering tends to make things look a lot worse than argb8. It's a lot less trouble to just render to argb8 which is sometimes faster on newer graphics cards.

If you want to save texture space use DXTn, if you want to render, use the fast (on modern hardware) and neutral argb8 space.

LeGreg

Share this post


Link to post
Share on other sites
oh my....you did perfect no beyond perfect answer and expanation!
yea,as ET3D said i dont want use 16bit format OF COURSE!
but i have to ,i think i have to ,now i dont know :)
cause i making middleware ,end user(game programmer) may use 16bit format to extreme speed their game up.
now LeGreg say ,more faster 32bit format than 16bit format.
so theres no reason i worry about 16bit.and support for 16bit.

Big thank you. especialy LeGreg.i rate you!

visit my web if you hve time. cya.

[Edit]
just right now,i test the both speed.
at least my vid card,16bit format is over 150% faster than 32bit.
well, i leave 16bit mode in my app unofficialy, and let them know it is unrecommended mode that may greenish render.
if end user use 16bit mode,they take its own risk.

[Edited by - katsh on January 7, 2007 10:53:57 PM]

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!