DirectX11 Non-Solid wireframe

孤街醉人 提交于 2019-12-24 12:51:36

问题


I'm attempting to draw a 100x100 grid in DirectX11 using C++, but the following issue happens:

The image above shows a grid I am drawing in wireframe, using a rasterizer with its fillmode set to 'D3D11_FILL_WIREFRAME' and a 'D3D11_PRIMITIVE_TOPOLOGY_LINELIST' topology. The lines of the wireframe appear staggered rather than straight, with some parts of the wireframe missing.

As I'm not sure what this issue is referred to as, I'm not entirely sure what I should be looking for and as such, any help is appreciated.


回答1:


This is a classic problem of 'aliasing'.

With Direct3D 11, you can use either MSAA which is a general anti-aliasing option, or use a specific line algorithm if you are not using MSAA. See D3D11_RASTERIZER_DESC AntialiasedLineEnable and MultisampleEnable.

See Aliasing and Multisample anti-aliasing

UPDATE: I've added MSAA and the AA mode to the DirectX Tool Kit tutorial.




回答2:


I stumbled across the solution to this and it wasn't what I expected at all. Since the window I created had outline bars, the windows client area was being misrepresented. So when I was creating my graphics device, I was initializing it with the windows size, rather than the windows client size. Somehow, this caused the issue above.

I fixed this by implementing a 'GetClientSize' method for the window, using 'GetWindowRect'.



来源:https://stackoverflow.com/questions/33598243/directx11-non-solid-wireframe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!