"Reprint" D3D depth test and alpha blending

Source: Internet
Author: User

Original:D3D depth test and alpha blending

1. Depth test a) depth buffer: A piece of memory buffer for depth information of each pixel point on the screen. D3D determines whether the current pixel is drawn by comparing the depth of the currently drawn pixel point and the depth of the point corresponding to the depth buffer. b) d3dpresent_parameters. Autodepthstencilformat = D3dfmt_d16 indicates that the depth value is opened by a 16-bit binary representation of the depth test: pdevice->setrenderstate (d3drs_zenable, TRUE); depth test function: D 3drs_zfunc: tr> TD valign= "Top" width= "192" >d3dcmp_always
d3dcmp_never
d3dcmp_less (Common)
d3dcmp_equal
d3dcmp_lessequal is less than or equal to
d3dcmp_greater greater than
d3dcmp_notequal Not equal to
d3dcmp_greaterequal greater than or equal to
always returns true
Update buffer: Keep the depth buffer intact or update pdevice->setrenderstate ( D3DRS_ZWRITEENABLE, TRUE ) with the depth value of the current pixel;2.        alpha mix a)           principle: Color = ( rgbsrc * ksrc) OP (rgbdst * kdst) The most common method: Color = (rgbsrc * alphasrc) + (rgbdst * (1–ALPHASRC)  b)          Application Enabled: Pdevice->setrenderstate (d3drs_alphablendenable, TRUE);
Blend mode factor Description
D3dblend_zero (0, 0, 0, 0)
D3dblend_one (1, 1, 1, 1)
D3dblend_srccolor (Rs, Gs, Bs, as)
D3dblend_invsrccolor (1-rs, 1-gs, 1-bs, 1-as)
D3dblend_srcalpha (as, as, as, as)
D3dblend_invsrcalpha (1-as, 1-as, 1-as, 1-as)
D3dblend_destalpha (AD, ad, ad, AD)
D3dblend_invdestalpha (1-ad, 1-ad, 1-ad, 1-ad)
D3dblend_destcolor (Rd, Gd, Bd, Ad)
D3dblend_invdestcolor (1-rd, 1-GD, 1-BD, 1-ad)
D3dblend_srcalphasat (F, F, f, 1); f = min (as, 1-ad)
Alpha Blending method
d3dblendop_add source calculation results and color buffer calculation results are added
d3dblendop_subtract source calculation result minus color buffer calculation result
d3dblendop_revsubtract color buffer calculation results minus source calculation results
d3dblendop_min min (source calculation result, color buffer calculation result
d3dblendop_max max (source calculation result, color buffer Calculation result)
Example of settings for Color = (RGBSRC * alphasrc) + (RGBDST * (1–ALPHASRC)): Pdevice->setrenderstate (D3drs_srcblend, D3dblend_srcalph A);pD evice->setrenderstate (D3drs_destblend, D3dblend_invsrcalpha);pD evice->setrenderstate (D3DBLENDOP,       D3DBLENDOP_ADD);(default value, optional) 3. Alpha Test A) principle determines whether the current pixel is drawn based on the alpha test condition and does not need to manipulate the color buffer, so the speed is faster than alpha blending. b) Application enablement: Pdevice->setrenderstate (d3drs_a Lphatestenable, TRUE); The Alpha test function D3dcmp_func enumeration, which defaults to the D3dcmp_always reference value: Pdevice->setrenderstate (D3drs_alpharef, 0x00000081);

"Reprint" D3D depth test and alpha blending

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.