切换视图和投影矩阵后 DirectX 网格无法正确显示
在我的程序中,网格显示正确,但是当我将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我预计这两个矩阵都会严重失败,因为您将近平面设置为 0。它确实应该是一些小的 epsilon,如 0.0001f。
另一件要记住的事情是,通过交换系统的旋向性,您很可能会颠倒三角形的缠绕顺序。
您需要将剔除渲染状态设置为顺时针而不是逆时针/逆时针。
IE
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