切换视图和投影矩阵后 DirectX 网格无法正确显示

发布于 2024-09-06 09:41:48 字数 520 浏览 6 评论 0原文

在我的程序中,网格显示正确,但是当我将 device.transform.view 和 device.transform.projection 矩阵从左手系统更改为右手系统时,网格不再正确显示,即背面脸部被照亮,正面是透明的! 有谁知道还需要更改什么才能正确显示

原始矩阵:

device.Transform.View = Matrix.LookAtLH(vFrom, vAt, vUp);
device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, fAspect, 0f, 100f);

修改:

device.Transform.View = Matrix.LookAtRH(vFrom, vAt, vUp);
device.Transform.Projection = Matrix.PerspectiveFovRH((float)Math.PI / 4, fAspect, 0f, 100f);

In my program, the meshes were being displayed properly, but when I change the device.transform.view and the device.transform.projection matrices from the left handed to the right handed system, the meshes are not displayed properly anymore, i.e the back faces are being illuminated and the front faces are transparent!
Does anyone have an idea what more needs to be changed to have a proper display

Original matrices:

device.Transform.View = Matrix.LookAtLH(vFrom, vAt, vUp);
device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, fAspect, 0f, 100f);

modification:

device.Transform.View = Matrix.LookAtRH(vFrom, vAt, vUp);
device.Transform.Projection = Matrix.PerspectiveFovRH((float)Math.PI / 4, fAspect, 0f, 100f);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

も让我眼熟你 2024-09-13 09:41:48

好吧,我预计这两个矩阵都会严重失败,因为您将近平面设置为 0。它确实应该是一些小的 epsilon,如 0.0001f。

另一件要记住的事情是,通过交换系统的旋向性,您很可能会颠倒三角形的缠绕顺序。

您需要将剔除渲染状态设置为顺时针而不是逆时针/逆时针。

IE

dxDevice.SetRenderState( RenderState.CullMode, Cull.Clockwise );

Well I'd expect both of those matrices to fail terribly on the basis that you set the near plane to 0. It really ought to be some small epsilon like 0.0001f.

The other thing to bear in mind is that by swapping the handedness of the system you are most likely inverting the winding order of the tris.

You need to set the culling render state to clockwise instead of anti/counter-clockwise.

ie

dxDevice.SetRenderState( RenderState.CullMode, Cull.Clockwise );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文