I need to achieve the following:
我需要实现以下目标:
Two 2D quads appear as though they are stacked one on top of the other (like two halves of the same texture) but are in fact seperated on the z axis by n coordinates. So that if a 3D object passes between them one half appears in front of the object and the other behind.
两个2D四边形看起来好像是一个堆叠在另一个上面(就像相同纹理的两半),但实际上是在z轴上用n个坐标分开。因此,如果3D对象在它们之间穿过,则一半出现在对象前面而另一半出现在对象前面。
Could i achieve this by applying orthogonal projection to the two quads and then normal perspective to the rest of the 3d data? Will this lose depth data?
我可以通过将正交投影应用于两个四边形,然后将正常视角应用于其他三维数据来实现这一目的吗?这会丢失深度数据吗?
I hope my example isn't too misleading!
我希望我的榜样不会太误导!
1 个解决方案
#1
1
The simple answer is yes,if you have z write turned on while rendering your quads. Your z data is never discarded unless you do it explicitly.
简单的答案是肯定的,如果你在渲染你的四边形时打开z写。除非您明确地执行此操作,否则不会丢弃您的z数据。
Getting orthagonal depths to play nicely with projection depths may be tricky, however. (I've never tried, but I imagine it's not going to line up nicely.) In that case it would be best to do one of the following:
然而,获得orthagonal深度与投影深度很好地结合可能是棘手的。 (我从未尝试过,但我想它不会很好地排队。)在这种情况下,最好做以下其中一项:
- Render all geometry in a perspective view
- Render all geometry in an othogonal view
- Render orthogonal geometry in non-z-tested sorted layers (back to front), rendering you perspective geometry in between.
在透视视图中渲染所有几何体
在正交视图中渲染所有几何体
在非z测试的排序图层(从前到后)渲染正交几何图形,在两者之间渲染透视几何图形。
I'm assuming you will already know the downsides to the first two methods, so it's up to you if that's acceptable. I think the third method is the most traditional.
我假设你已经知道前两种方法的缺点,所以如果这是可以接受的,那取决于你。我认为第三种方法是最传统的方法。
#1
1
The simple answer is yes,if you have z write turned on while rendering your quads. Your z data is never discarded unless you do it explicitly.
简单的答案是肯定的,如果你在渲染你的四边形时打开z写。除非您明确地执行此操作,否则不会丢弃您的z数据。
Getting orthagonal depths to play nicely with projection depths may be tricky, however. (I've never tried, but I imagine it's not going to line up nicely.) In that case it would be best to do one of the following:
然而,获得orthagonal深度与投影深度很好地结合可能是棘手的。 (我从未尝试过,但我想它不会很好地排队。)在这种情况下,最好做以下其中一项:
- Render all geometry in a perspective view
- Render all geometry in an othogonal view
- Render orthogonal geometry in non-z-tested sorted layers (back to front), rendering you perspective geometry in between.
在透视视图中渲染所有几何体
在正交视图中渲染所有几何体
在非z测试的排序图层(从前到后)渲染正交几何图形,在两者之间渲染透视几何图形。
I'm assuming you will already know the downsides to the first two methods, so it's up to you if that's acceptable. I think the third method is the most traditional.
我假设你已经知道前两种方法的缺点,所以如果这是可以接受的,那取决于你。我认为第三种方法是最传统的方法。