
You can use the AlphaToCoverageEnable member of D3D11_BLEND_DESC1 or D3D11_BLEND_DESC to toggle whether the runtime converts the. Advanced Blending TopicsĪlpha-to-coverage is a multisampling technique that is most useful for situations such as dense foliage where there are several overlapping polygons that use alpha transparency to define edges within the surface. However, depending on the needs of your application, any of the other comparison functions may be used to do the depth test. Normally, you would want DepthFunc to be D3D11_COMPARISON_LESS, so that the pixels closest to the camera will overwrite the pixels behind them. When setting up the depth stencil state, the DepthFunc member of D3D11_DEPTH_STENCIL_DESC can be any D3D11_COMPARISON_FUNC. In most depth buffering schemes, the pixel closest to the camera is the one that gets drawn. The default sampling mask is 0xffffffff which designates point sampling.

Edge blending math how to#
The sample mask is a user-defined mask that determines how to sample the existing render target before updating it. Bind the Blend StateĪfter you create the blend-state object, bind the blend-state object to the output-merger stage by calling ID3D11DeviceContext::OMSetBlendState. This example is similar to the HLSLWithoutFX10 Sample.

Pd3dDevice->CreateBlendState1(&BlendState, &g_pBlendStateNoBlend) ZeroMemory(&BlendState, sizeof(D3D11_BLEND_DESC1)) ī = FALSE ī = D3D11_COLOR_WRITE_ENABLE_ALL ID3D11BlendState1* g_pBlendStateNoBlend = NULL These states (defined in D3D11_BLEND_DESC1) are used to create the blend state object by calling ID3D11Device1::CreateBlendState1.įor instance, here is a very simple example of blend-state creation that disables alpha blending and uses no per-component pixel masking. The blend state is a collection of states used to control blending. If multisampling is enabled, blending is done on each multisample otherwise, blending is performed on each pixel.

Blending operations are performed on every pixel shader output (RGBA value) before the output value is written to a render target.
