在d3d9中开启抗锯齿功能?

时间:2012-12-17 10:37:11

标签: directx game-engine direct3d multisampling

我正在尝试在项目中启用抗锯齿功能。首先看看d3d9界面:

HRESULT CreateRenderTarget(
  [in]           UINT Width,
  [in]           UINT Height,
  [in]           D3DFORMAT Format,
  [in]           D3DMULTISAMPLE_TYPE MultiSample,
  [in]           DWORD MultisampleQuality,
  [in]           BOOL Lockable,
  [out, retval]  IDirect3DSurface9 **ppSurface,
  [in]           HANDLE *pSharedHandle
);

typedef enum D3DMULTISAMPLE_TYPE {
  D3DMULTISAMPLE_NONE           = 0,
  D3DMULTISAMPLE_NONMASKABLE    = 1,
  D3DMULTISAMPLE_2_SAMPLES      = 2,
  D3DMULTISAMPLE_3_SAMPLES      = 3,
  D3DMULTISAMPLE_4_SAMPLES      = 4,
  D3DMULTISAMPLE_5_SAMPLES      = 5,
  D3DMULTISAMPLE_6_SAMPLES      = 6,
  D3DMULTISAMPLE_7_SAMPLES      = 7,
  D3DMULTISAMPLE_8_SAMPLES      = 8,
  D3DMULTISAMPLE_9_SAMPLES      = 9,
  D3DMULTISAMPLE_10_SAMPLES     = 10,
  D3DMULTISAMPLE_11_SAMPLES     = 11,
  D3DMULTISAMPLE_12_SAMPLES     = 12,
  D3DMULTISAMPLE_13_SAMPLES     = 13,
  D3DMULTISAMPLE_14_SAMPLES     = 14,
  D3DMULTISAMPLE_15_SAMPLES     = 15,
  D3DMULTISAMPLE_16_SAMPLES     = 16,
  D3DMULTISAMPLE_FORCE_DWORD    = 0xffffffff 
} D3DMULTISAMPLE_TYPE, *LPD3DMULTISAMPLE_TYPE;

我不确定如何提供参数MultiSampleMultisampleQualitynon-maskable multisamplingmaskable之间有什么区别?
2x抗锯齿映射到什么?
4x抗锯齿映射到什么?
D3DMULTISAMPLE_2_SAMPLES + 2q == D3DMULTISAMPLE_4_SAMPLES + 1q?

1 个答案:

答案 0 :(得分:2)

MultisampleQuality仅在您将D3DMULTISAMPLE_NONMASKABLE作为多重采样类型(doc)时才可用。

D3DMULTISAMPLE_NONMASKABLE仅启用抗锯齿支持(这就是您所寻找的),质量由MultisampleQuality - 参数确定,其中1 => 2xAA和2 =>开启4xAA。

如果您使用其他类型D3DMULTISAMPLE_NONMASKABLE,例如'D3DMULTISAMPLE_2_SAMPLES'你启用了antialising支持写作掩码,你可以通过renderstate D3DRS_MULTISAMPLEMASKdoc)来设置。这使您可以渲染到多重采样rendertarget的特定样本集。最后,对所有样品进行平均和呈现。我认为此设置不适合您的问题。