半透明对象渲染的顺序 [英] Order of translucent object rendering

查看:67
本文介绍了半透明对象渲染的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

渲染半透明对象(使用glBlend)时,建议按从前到后的z顺序对对象进行排序.

When rendering a translucent object (using glBlend), it is advised to sort objects from back to front z order.

来自 opengl文档: 在应用程序中使用深度缓冲时,需要注意渲染基元的顺序.首先需要渲染完全不透明的图元,然后以从后到前的顺序渲染部分不透明的图元.如果不按此顺序渲染图元,则这些图元可能会完全失去深度测试.否则,这些图元将通过部分不透明的图元可见.

From opengl docs: When using depth buffering in an application, you need to be careful about the order in which you render primitives. Fully opaque primitives need to be rendered first, followed by partially opaque primitives in back-to-front order. If you don't render primitives in this order, the primitives, which would otherwise be visible through a partially opaque primitive, might lose the depth test entirely.

因此,每当渲染不透明三角形之后再渲染半透明对象时,如果我相对于视图方向"从后到前渲染半透明三角形,这是正确的吗?从头到尾到底是什么意思?我想了解一下,如果我有一个经过mvp转换的场景对象,我是否需要专门查看世界坐标​​中的顺序以及相对于相机中心的顺序?

So, whenever I'm rendering translucent objects after rendering opaque triangles, if I render translucent triangles from back to front in relation to the "view direction", is this correct? What exactly does back to front mean here? I'm trying to understand, if I have a scene objects that go through a mvp transformation, do I need to specifically look at the order in world coordinates, and in relation to the camera center?

此外,这还会根据混合类型发生变化吗?

Also, additionally does this change depending on the blend type?

推荐答案

每当渲染半透明三角形时,都必须将它们绘制成从前到后.从后到前是指您必须首先绘制距离屏幕更远(深度值更高)的三角形.

Whenever you render translucent triangles, you have to draw them back-to-front. Back-to-front here means, that you have to draw triangles first that are further away from the screen (that have a higher depth value).

之所以需要这样做,是因为大多数混合方程会根据顺序产生不同的结果.在OpenGL中实现的方程式通常使得它们从背面渲染时给出正确"的结果.

The reason why this is necessary is that most blending equations yield different results depending on the order. The equations as implemented in OpenGL are usually such that they give "correct" results when rendering back-to-front.

这篇关于半透明对象渲染的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆