Direct3D:使用单个 DrawIndexedPrimitives 调用绘制纹理立方体。可能的?
我正在尝试仅使用 8 个顶点和一个 DrawIndexedPrimitives
调用来绘制一个纹理立方体。这可能吗?
我的 UV 坐标有问题。我发现不可能提出适用于立方体所有面的合适 UV 值。
以以下编号为例:
UV 设置为 (0, 0 )对于顶点 A。对于与 A 对角相对的所有顶点(在共享 A 作为顶点的所有三个面上),我将 UV 设置为 (1, 1)。现在,没有 A 作为顶点的三个面最终有两个顶点,每个顶点的 UV 值为 (1, 1)。据我了解,情况不应该如此。
那么解决办法是什么呢?
I am trying to draw a textured cube using just 8 vertices and one DrawIndexedPrimitives
call. Is this even possible?
I am having problems with the UV co-ordinates. I am finding it impossible to come up with suitable UV values which will work for all faces of the cube.
Take the following numbering as an example:
UV is set to (0, 0) for vertex A. For all vertices diagonally opposite to A (on all three faces sharing A as a vertex), I am setting UV to (1, 1). Now the three faces which do not have A as a vertex end up having two vertices each which have a UV value of (1, 1). It is my understanding that this should not be the case.
What then is the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果单个顶点具有多个 UV 坐标,则这是不可能的。
要解决此问题,请复制顶点位置并为每个副本分配唯一的 UV 坐标。在最坏的情况下(每边四个),这会将立方体的顶点数量增加到 24 个。
顺便说一句,这是每个人都会做的事情,无论他使用的是 OpenGL 还是 DirectX。对于立方体来说,这可能看起来浪费了大量内存,但实际上 - 对于现实世界的模型 - 顶点重复量并没有那么高。
然后,您可以通过一次调用 DrawIndexedprimitive 来绘制立方体。
It is not possible if a single vertex has multiple UV coordinates.
To get around this problem duplicate the vertex position and assign each copy a unique UV coordinate. This will increase the number of vertices to 24 for a cube in the worst case (four per side).
This is btw what everyone does regardless if he's using OpenGL or DirectX. For a cube this may look like a lot of wasted memory, but in practice - with real world models - the amount of vertex duplication is not that high.
Afterwards you can draw the cube with a single call to DrawIndexedprimitive.