Archived

This topic is now archived and is closed to further replies.

duck17

16bit surface with no alpha?

Recommended Posts

I''m using directx8.0.... I have a question regarding drawing primitives that have an alpha value, to a surface that has no alpha value (such as r5g6b5). What does the blending function use for the "destination alpha" when there is no alpha information in my destination? thanks, - duck17

Share this post


Link to post
Share on other sites
I would have to assume that the only sensible answer would be 1.0. But don''t the pixel formats have to match anyway, in which case, there''d be no source alpha either...?

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites
well it seems that you specify the vertex colors in a 32 bit argb format regardless of the primary surface format.. and directx converts it for you.... but anyways 1.0 sounds reasonable. I guess ill just have to assume that and see what happens. ;D

-duck17

Share this post


Link to post
Share on other sites
Lesson 98451b for 3D hardware: Never assume defaults for non-obvious things...

Even if it IS documented anywhere (albeit obscurely - I don''t think I''ve ever noticed it), I would definately never trust all drivers/hardware to honour a "default" value for using destination alpha blends on a surface without umm destination alpha.

If one is what you want, explicitly specify ONE as the blend factor.

duck17: you didn''t make it too clear what you wanted - if it''s simply alpha blending stuff with what is already on the render surface then destination alpha never comes into it, the mode you''d use would be SRCALPHA:INVSRC ALPHA

i.e. The operation the hardware will peform with SRCALPHA:INVSRCALPHA is:

FINAL_red = (SRC_a * SRC_red) + ((1.0-SRC_a) * DEST_red)
FINAL_green = (SRC_a * SRC_green) + ((1.0-SRC_a) * DEST_green)
FINAL_blue = (SRC_a * SRC_blue) + ((1.0-SRC_a) * DEST_blue)

Where FINAL is the rendered result, SRC is what is being rendered in the current Draw*Primitive* call and DEST is what was rendered in previous Draw* calls (i.e. what is already in the frame buffer BEFORE this blend). Assuming all colour components are in the range of 0 to 1 (actually they''re 0-255 but the h/w behaves as if they''re 0-1)

The INV in INVSRCALPHA simply means "inverse", look at the operation performed, as the SRC alpha gets higher, the inverse gets lower and vice versa.

500x1

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites