Archived

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

No Alpha in 16 bit?

This topic is 5676 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

Something tells me that I''m not understanding this right so will someone please correct me: It is my understanding that if i want to use Alpha blending, i have to first set the format of my render surface to a format that supports alpha... is that correct? OK so thinking that it is correct, the following from the SDK puzzles me: "Note that render target formats are restricted to D3DFMT_X1R5G5B5, D3DFMT_R5G6B5, D3DFMT_X8R8G8B8, and D3DFMT_A8R8G8B8." So if this is correct then if i want to use alpha i have to use D3DFMT_A8R8G8B8 which is 32 bit... so what happens if the user''s machine won''t let my program use 32 bit formats? There seriously must be something that im missing

Share this post


Link to post
Share on other sites
quote:
It is my understanding that if i want to use Alpha blending, i have to first set the format of my render surface to a format that supports alpha... is that correct?


No,

1. "Alpha Blending" (in D3D) is a general term for an something which performs an operation on the pixels in the current polygon being drawn (source), with the pixels drawn in previous render calls (destination).


2. The term "Alpha Blending" is a tad misleading. Not all blending modes actually use alpha channels - some (e.g. ONE:ONE) don''t require any at all in either source or destination.


3. The most common type of blending mode which uses an alpha channel is straight translucency/transparency. In this mode, the blend performed is a linear interpolation of RGB colours between the source (pixels in current primitive) and destination (pixels from previous primitives). The interpolation level is controlled by an alpha channel.


4. The form of translucency most commonly used is where the level of translucency is controlled by the alpha channel of the *source* (e.g. the current primitives'' texture, OR the current primitives'' vertex colour etc). In D3D, the setup for this is:

D3DRS_SRCBLEND = D3DBLEND_SRCALPHA
D3DRS_DESTBLEND = D3DBLEND_INVSRCALPHA

The operation the graphics chip performs when rendering a primitive with SRCALPHA:INVSRCALPHA is as follows:

renderedR = (srcR * srcA) + ((1-srcA) * destR)
renderedG = (srcG * srcA) + ((1-srcA) * destG)
renderedB = (srcB * srcA) + ((1-srcA) * destB)

srcR, srcG, srcB are the colour components of the current primitive being drawn.

srcA is the alpha component of the current primitive being drawn.

destR, destG, destB are the colour components of the pixels already rendered in the render target by previous draw calls.


5. As you can see from the above, destA isn''t used at all by SERCALPHA:INVSRCALPHA - so the destination (i.e. the render target) *does not* need an alpha channel to do plain translucency/transparency (what is commonly called "alpha blending")

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

Share this post


Link to post
Share on other sites