粒子系统中的BufferGeometry的Z缓冲问题 [英] Z-buffer issue with BufferGeometry in ParticleSystem

查看:117
本文介绍了粒子系统中的BufferGeometry的Z缓冲问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我遇到了z-buffer的麻烦。我有一个粒子系统,其中点的纹理看起来像球体。但是有两个问题我无法同时解决....

In my application I'm having troubles with the z-buffer. I have a ParticleSystem in which the dots have a texture to look like spheres. But there are two problems which I can't solve at the same time....

要么球体在z缓冲区中排序,要么不透明或者它们是透明的,但没有正确排序!

Either the spheres were sorted right in z-buffer but aren't transparent or they are transparent but not right sorted!

请看看我的的jsfiddle 。 (基于来自mrdoob的此示例

Please have a look at my JSfiddle. (based on this example from mrdoob)

在最初的例子中,一切看起来都很好。但正如你可以在我的小提琴中看到的那样,纹理不是透明的,所以隐藏了粒子的一部分。我只是从 Geometry 改为 BufferGeometry ,因为在我的应用程序中我必须使用它来避免性能问题。你可以通过改变我在小提琴中的评论来切换这两者。通过在 Geometry BufferGeometry 之间切换,您可以看到z缓冲区正在崩溃。

In the original example all looks well. But as you can see in my fiddle, the texture is not transparent, so hiding parts of the particles behind it. I only changed from Geometry to BufferGeometry, because in my application I have to use this to avoid perfomance issues. You can switch between these two by changing my comments in the fiddle. And by switching between Geometry and BufferGeometry you can see that the z-buffer is breaking.

在互联网的某个地方,我发现了这个解决方案:

Somewhere in the internet I found this "solution":

depthWrite : false

我添加到资料中。然后粒子看起来很棒但是z缓冲区不正确。
这让我发疯了......无论如何我发现我的几何类型就是问题。

which I added to the material. Then the particles look great but the z-buffer is not correct. This is driving me crazy... anyway I found out that my type of Geometry is the problem.

那么为什么mrdoob的例子不适用于 BufferGeometry ?我该怎么做才能在我的系统中获得正确排序的透明粒子?

So why is mrdoob's example not working with BufferGeometry? What can I do to get right sorted AND transparent particles in my system?

推荐答案

你很困惑。纹理是透明的,并在切换到 BufferGeometry 时保持不变。

You are confused. The texture is transparent, and remains so when switching to BufferGeometry.

发生了什么,是 BufferGeometry ,粒子不按排序顺序呈现 - 它们按照您在缓冲区中指定的顺序呈现。

What is happening, is that with BufferGeometry, the particles are not rendered in sorted order -- they are rendered in the order you specify in the buffer.

如果你想使用 BufferGeometry ,你可以设置

If you want to use BufferGeometry, you can set

material.alphaTest = 0.5.

然后,在你的情况下,事情应该看起来不错。

Then, in your case, things should look fine.

three.js r.60

three.js r.60

这篇关于粒子系统中的BufferGeometry的Z缓冲问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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