您的位置:首页 > 其它

使用Render To Texture的AA问题

2012-06-07 16:49 471 查看
在项目中使用RTT,渲染场景到Texture时出现了锯齿严重的情况,创建设备时打开D3D的抗锯齿设置:

m_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE;
m_d3dpp.MultiSampleQuality = D3DMULTISAMPLE_2_SAMPLES;


锯齿没有改善而且模型的纹理贴图出现了错误:



跟踪代码发现,由于使用
HRESULT CreateTexture(
UINT Width,
UINT Height,
UINT Levels,
DWORD Usage,
D3DFORMAT Format,
D3DPOOL Pool,
IDirect3DTexture9** ppTexture,
HANDLE* pSharedHandle
);

创建纹理,再使用 调用Device->GetSurfaceLevel(0, &SurfacePtr );获得Surface指针来创建RenderTarget。这样创建的纹理不能实现硬件AA。因此,改用

HRESULT CreateRenderTarget(
UINT Width,
UINT Height,
D3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality,
BOOL Lockable,
IDirect3DSurface9** ppSurface,
HANDLE* pSharedHandle
);
来创建RenderTarget,创建时MultiSample和MultisampleQuality参数来设置抗锯齿系数。RTT后,再StretchRect将surface拷贝到需要的纹理。操作时,CreateRenderTarget总是失败。最后查阅DXSDK发现:
The creation of lockable, multisampled render targets is not supported.,关闭Lockable。AA成功。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐