简体   繁体   English

opengL:glsl着色器中的镜像对象

[英]opengL: mirror object in glsl shader

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. 如果我只是在投影矩阵中将一个轴缩放-1,我会得到不好的剔除,并且需要在应用程序中将剔除从背面更改为前面。 is there a way to do it without changing the culling? 有没有办法在不改变剔除的情况下做到这一点?

thanks! 谢谢!

Culling is done based on the so called chirality of the face, ie 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. 切换剔除功能也没什么大不了的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM