使用 VertexPositionNormalTexture 和 VertexPositionTexture 之间的区别
在 XNA 中使用 VertexPositionNormalTexture 和 VertexPositionTexture 有什么区别?如果法线远离相机,GPU 是否会应用剔除,还是会自动执行此操作?只是发送更多数据到 GPU 吗?
各有哪些优点和缺点?每种方法适用于什么情况?
What are the differences between using VertexPositionNormalTexture and VertexPositionTexture in XNA? Does the GPU apply culling if the normal points away from the camera, or does it do that automatically? Is it just more data to send to GPU?
What are the advantages and disadvantages, and in what situations would each one be applicable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
优点是您可以将计算出的顶点法线传递给着色器,并且着色器可以在渲染中使用该信息,例如,您可以通过在每个三角形上插值法线并使用此插值法线来实现更平滑的照明,更接近曲面用于照明而不是三角形的法线。
我想您可以使用此信息进行剔除,但这通常不是它的用途。您不需要顶点法线来剔除,因为通常只需计算三角形法线的方向而不是每个顶点即可轻松完成。
当您说“GPU 是否应用剔除...”时,请记住固定管道处理的时代已经一去不复返了,GPU 会执行您在着色器代码中告诉它执行的操作。最终,您可以将任何您想要的信息放入顶点流中,并在着色器中以您想要的方式使用该信息,可能性是无限的。
The advantage is that you can pass a calculated vertex normal to your shader and the shader can use that information in the render, for example you can implement smoother lighting that more closely approximates curved surfaces by interpolating the normal across each triangle and using this interpolated normal for lighting rather than the normal of the triangle.
I suppose you could use this information for culling, but it's not generally what it's used for. You don't need vertex normals to cull because generally it's easily done just by calculating the direction of the normal of the triangle, rather than each vertex.
When you say 'does the GPU apply culling...' remember that the days of fixed pipeline processing are gone, the GPU does what you tell it to do in your shader code. At the end of the day you can put whatever information you want in to your vertex stream, and use that information however you want in your shader, the possibilities are endless.