Three.js Transparency Errors With Multiple Particle Systems Sorting

北慕城南 提交于 2020-01-06 06:59:09

问题


I have two THREE.ParticleSystem systems with particles that have textures with alpha transparency, one is using AdditiveBlending (fire texture), the other uses NormalBlending (smoke texture) and they use simple custom vertex and fragment shaders.

Each ParticleSystem has "sortParticles = true" and independently they work perfectly, however when both types of particles overlap the first particle system (fire texture) has a similar transparency depth error that is normally associated with "sortParticles = false" (see image).

It seems that the first particle system is not rendering properly, likely because those particles are all being drawn before the others even when particles from the other system are behind them, resulting in transparency artifacts.

Perhaps one possible solution is for sortParticles to somehow sort both systems. Is this a possibility? Is there a "global particle sort flag" of some sort or a way to force sortParticles to span both systems?

Another somewhat more involved solution could be to use a single sorted ParticleSystem but somehow vary both texture and blending mode per-particle. Is this possible? I have a clue of how this could be done in the shader but I'm concerned about adding a conditional for performance reasons.

Open to any and all solutions. Thanks for any advice, ideas or help!

来源:https://stackoverflow.com/questions/22901015/three-js-transparency-errors-with-multiple-particle-systems-sorting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!