简体   繁体   English

OpenGL:渲染具有很多纹理透明度的模型,而无需绘制顺序?

[英]OpenGL: Rendering a model with a lot of texture transparency, without draw ordering?

I have low-poly character models that make heavy use of textures to define shape using the alpha channel. 我有低多边形字符模型,这些模型大量使用纹理来定义使用Alpha通道的形状。 (An example would be glasses, which are only 3 solid large quads, but the alpha channel of the texture defines the shape of the glasses) (一个例子是眼镜,它只有3个大的四边形,但是纹理的Alpha通道定义了眼镜的形状)

So there's a tonne of transparency/translucency goin' on, I estimate that one quarter of every tri drawn, will have at least a little transparency in it's texture needing blending. 因此,有大量的透明度/半透明性,我估计每绘制三次,就有四分之一需要混合的纹理至少具有一点透明性。
Most of the transparency occurs in the hair, which layers up geometry very close and intersects itself sometimes. 大部分透明度发生在头发中,头发非常紧密地分层,有时与自身相交。

My question, is there any way to get reasonable alpha blending behavior, without ordering which tris are drawn according to depth? 我的问题是,有什么方法可以得到合理的alpha混合行为,而无需根据深度绘制哪些Tris? Most (old) opengl documentation I've read says ordering is required to blend any kind of transparency, but I feel ordering every tri every frame, in this case, would be too costly. 我读过的大多数(旧)opengl文档都说,需要排序才能混合任何类型的透明度,但是在这种情况下,我觉得每帧都必须排序,这太昂贵了。 (or at least, beyond my ability to code without spending weeks on it) (或至少超出我的能力而无需花费数周的时间)

There is no lighting or vertex coloring, if it's important. 如果重要,则没有照明或顶点着色。 The results don't have to be accurate , but I would like them to be visually pleasing and consistant, if possible. 结果不一定是准确的 ,但如果可能的话,我希望它们在视觉上令人愉悦且一致。

  1. you could reorder your tri's by the distance from sub-axises 您可以按照与子轴的距离重新排列三轴

    轴系

    so as first are rendered layers closer to the axis and as last the most outer layers. 因此,首先渲染层靠近轴,最后是最外层。

  2. On top of this you put the transparent tri's 在此之上,您将透明的三

    unless you have whole parts transparent it should be OK. 除非您的整个零件都透明,否则应该没问题。 The order problems will cause glitches like sometimes you will not see transparent object behind transparent object correctly (from some angles) and also this can be corrected by multi pass rendering and proper CULL_FACE front switching. 顺序问题将导致故障,例如有时您无法(从某些角度)正确地看到透明物体后面的透明物体,而且可以通过多遍渲染和正确的CULL_FACE正面切换来纠正。 Beware that this will not solve 100% of the artifacts ... The more complex shapes you have the more glitches there will be. 请注意,这不能解决100%的伪影...形状越复杂,毛刺就会越多。

    For example I render transparent glass with solid machine around and inside like this: 例如,我用左右两边的固体机器渲染透明玻璃,如下所示:

    1. render solid part ( CW+CCW ) 渲染实体零件( CW+CCW
    2. render back-side transparent part ( CCW ) 渲染背面透明部分( CCW
    3. render solid part ( CW+CCW ) 渲染实体零件( CW+CCW
    4. render front-side transparent part ( CW ) 渲染正面透明部分( CW

(my models are defined with CW winding rule) (我的模型是用CW缠绕规则定义的)

Here OpenGL example: 这里以OpenGL为例:

When working with alphas before I have found that one way around this problem is to render the alphas in whichever order, but simply displacing them slightly in a recursive fashion towards the camera. 在使用Alpha之前,我发现解决此问题的一种方法是按任意顺序渲染Alpha,但只需以递归方式将它们稍微移向相机即可。 ie each successive triangle is rendered slightly translated towards the camera with respect to the previous one (very slightly such that objects still look like they are in the same place). 也就是说,每个连续的三角形都相对于前一个三角形稍微朝着摄影机移动(非常微小,以使对象看起来仍然像在同一位置)。 Although this might not be sufficient for your needs depending on setup, It certainly got rid of alpha overlap problems rendering leaves and stuff for me and it isn't very resource intensive as you don't need to order anything at all. 尽管根据设置,这可能不足以满足您的需求,但是它肯定消除了Alpha重叠问题,为我渲染了叶子和东西,并且它不需要太多资源,因为您根本不需要订购任何东西。 It might not work in your specific situation but it might be worth a try, good luck! 它可能无法在您的特定情况下起作用,但是可能值得尝试,祝您好运!

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

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