DX11中的顶点卷绕顺序 [英] Vertex Winding Order in DX11

查看:395
本文介绍了DX11中的顶点卷绕顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用dx11绘制一个简单的正方形,但每个三角形的索引的顺序决定了它是否显示。我设置cull模式为none在光栅器状态,但它似乎没有改变任何东西。

I'm trying to draw a simple square with dx11, but the order of the indices of each triangle determines whether or not it shows up. I set the cull mode to none in the rasterizer state, but it doesn't seem to change anything.

如果我指定第一个三角形的顶点为0,1,2而不是2,1,0,那么三角形不会显示。所以我的问题是,我需要以特定的方式排序三角形的顶点,而不考虑剔除模式?

If I specify the vertices of the first triangle to be 0, 1, 2 instead of 2, 1, 0 then the triangle doesn't show up. So my question is, do I need to order the vertices of a triangle in a specific way regardless of the cull mode?

P.S。

UINT indices[] = {2, 1, 0, 
                  1, 3, 0};


MeshVertex vertices[] = 
{
    { Vector3(1.0f, 1.0f, 0.0f)}, //Top Right
    { Vector3(-1.0f, -1.0f, 0.0f)}, //Bottom Left
    { Vector3(1.0f, -1.0f, 0.0f)}, //Bottom Right
    { Vector3(-1.0f, 1.0f, 0.0f)} //Top Left
};

mesh = new Mesh(vertices, indices, 4, 6, shader);


推荐答案


,我需要以一个
的特定方式排序三角形的顶点,而不考虑剔除模式?

So my question is, do I need to order the vertices of a triangle in a specific way regardless of the cull mode?

**定义/按顺时针顺序绘制顶点,并且不改变默认的
cull模式。**

** Define/Draw your vertices in clockwise order, and don't change the default the cull mode.**

要确定是否可以显示三角形,你必须考虑两个因素:

To determine whether a triangle can be displayed, you have to considering 2 factors


  1. 前面,或称为卷绕顺序,默认情况下,Direct3D处理按顺时针顺序定义的顶点

  2. 默认情况下,剔除模式Direct3D将剔除背面(以逆时针顺序定义的顶点的面) )

您可以在 D3D11_RASTERIZER_DESC 结构

当您将剔除模式更改为NONE时,您没有看到差别的原因是因为两个三角形的顺序都相同,而D3D11_CULL_NONE表示没有剔除任何面孔。

The reason why you didn't see difference when you change the culling mode to NONE is because both triangle were in the same order and D3D11_CULL_NONE means didn't cull any faces.

如果三角形1是顺时针顺序,三角形2是逆时针顺序,那么当您将剔除模式设置为D3D11_CULL_FRONT或D3D11_CULL_BACK时,您将只能看到一个三角形,并且在将其设置为D3D11_CULL_NONE时都会看到。

If triangle 1 is in clockwise order and triangle 2 is in counter clockwise order, you will only see one triangle when you set the cull mode to D3D11_CULL_FRONT or D3D11_CULL_BACK, and see both when you set it to D3D11_CULL_NONE.

这篇关于DX11中的顶点卷绕顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆