简体   繁体   English

GL_POINTS在粒子模拟中相互模糊

[英]GL_POINTS obscuring each other in particle simulation

I have a fire simulation, containing a large number of textured GL_POINTS . 我有一个火灾模拟,包含大量纹理GL_POINTS Each particle has a transparent background, and when facing the fire from certain angles, the blending works correctly. 每个粒子都有一个透明的背景,当从某个角度面向火焰时,混合工作正常。 However, viewing it from other angles shows the backgrounds, which should be transparent, obscuring particles rendered behind others. 但是,从其他角度查看它会显示背景,这些背景应该是透明的,遮挡在其他背后渲染的粒子。 See picture below. 见下图。

在此输入图像描述

As you can see, there appears to be a lot of black boxes in the way of the particle. 如您所见,粒子的方式似乎有很多黑盒子。 How can I avoid this? 我怎么能避免这个? The blend function I am using is GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA . 我使用的混合函数是GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA Using GL_ONE as the second argument to glBlendFunc gives very similar results. 使用GL_ONE作为glBlendFunc的第二个参数可以得到非常相似的结果。

http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/particles-instancing/#The_main_simulation_loop http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/particles-instancing/#The_main_simulation_loop

There you can find the exact same problem and its solution. 在那里你可以找到完全相同的问题及其解决方案。 You indeed have to sort the particles as Gigo suggested. 你确实必须像Gigo建议的那样对粒子进行排序。 The reason is that alpha blending only looks right if the colors are mixed from back to front. 原因是如果颜色从后到前混合,alpha混合只能看起来正确。

You can, however avoid sorting if you really want to. 但是,如果你真的想要,你可以避免排序。 There are algorithms for 3d transparency that are a bit more efficient. 有三维透明度的算法效率更高一些。 See: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-10-transparency/#Order_Independent_Transparency 请参阅: http//www.opengl-tutorial.org/intermediate-tutorials/tutorial-10-transparency/#Order_Independent_Transparency

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

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