ParticleSystem 中 BufferGeometry 的 Z 缓冲区问题 [英] Z-buffer issue with BufferGeometry in ParticleSystem

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

问题描述

在我的应用程序中,我遇到了 z 缓冲区的问题.我有一个 ParticleSystem,其中的点具有看起来像球体的纹理.但是有两个问题我不能同时解决....

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,因为在我的应用程序中,我必须使用它来避免性能问题.您可以通过更改我在小提琴中的评论在这两者之间切换.通过在 GeometryBufferGeometry 之间切换,您可以看到 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,可以设置

material.alphaTest = 0.5.

那么,就您而言,事情应该看起来不错.

Then, in your case, things should look fine.

three.js r.60

three.js r.60

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

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