opengL:glsl 着色器中的镜像对象
是否可以仅在顶点着色器中沿某个轴镜像对象?
如果我只是将投影矩阵中的一个轴缩放 -1,则会得到糟糕的剔除效果,并且需要在应用程序中将剔除从背面更改为正面。有没有办法在不改变剔除的情况下做到这一点?
谢谢!
is it possible to mirror an object along some axis, just in the vertex shader?
if i simply scale one axis by -1 in the projection matrix, i get bad culling and would need to change the culling from backface to frontface in the application. is there a way to do it without changing the culling?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
剔除是基于所谓的面的手性(即绘制顶点的旋转方向)来完成的。反射的核心属性是改变手性。因此,您将不可避免地必须切换剔除行为,因为背面/正面剔除纯粹发生在屏幕空间中的手性上。
您可以使用几何着色器来交换每个三角形的两个顶点,这也会切换手性。但坦率地说:反射需要一些额外的预防措施,例如模板遮蔽等;那么切换剔除功能也没什么大不了的。
Culling is done based on the so called chirality of the face, i.e. the turning direction in which the vertices are drawn. It is the core property of a reflection that it changes the chirality. So you'll inevitably have to switch the culling behaviour, since back-/frontface culling happens purely on the chirality in screen space.
You could use a geometry shader to exchange two vertices of each triangle which will also switch the chirality. But frankly: Reflections require some additional precautions like stencil masking and such; switching the culling function is no big deal then, too.