- Home /
Unity drawing bug?
Pictures of the problem:
http://imgur.com/CZEW1 http://imgur.com/KqIHF
When I instantiate particle systems and some meshes, they sometimes are rendered mistakenly in front of the wrong object. Is this something I'm doing wrong, or is this a bug in Unity? How do I eliminate it? The objects in the scene are not static, and I've been building it out to iOS, but it's happening on the device, as well.
What say ye?
It is not clear what is wrong in the picture, and what it's supposed to look like, please explain.
Sorry! Yes. The shader I'm using for the particles is Particles/Additive. Sorry for the delay. It's also not just happening to particles, but to meshes, as well, again. I thought I'd fixed it. But I've uploaded a second picture of it happening with a laser beam built two planes with identical materials--the shader on this is set to a custom shader I have, Sprite/Vertex Colored(Fast), from the Sprite $$anonymous$$anager 2 library's package.
It's supposed to look like the particles from the effect are going in front of the background mesh--there's a cornfield backdrop matte there that's rendering in front of my particles--same with the laser beam. Does that make sense?
Thanks!
So the problem maybe lies with the cornfield backdrop. What shader does it use, what queue value does the shader have, what queue value does Sprite/Vertex Colored(Fast), and so on?
I'm assu$$anonymous$$g all the queues are "Transparent" (3000).
Answer by Jessy · Jun 18, 2012 at 12:13 AM
The AABB of the hills mesh is closer than that of the particles. (Is it a sky dome or box? That would do it.) Put additive particles in a later queue or split up the mesh. Maybe. Fixing this would require a look at your scene, but there are plenty of options. It's not Unity doing something wrong; it's you not grokking how things are rendered, yet.
Ah! Fantastic knowledge. It's a skybox that I'm using. I've updated the question--it's happening to a plane with a different shader, too.
As you've suggested, though changing the particles to unlit or something does seem to fix the problem. I might not end up using these particle systems anyway--but in case I do, and there's still a problem, would you consider this script reference an acceptable port of grok?
http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$aterial-renderQueue.html
I suspect that the error just involves making sure that the particles' render queue int is lower than that of the background...?
That's a helpful property. I think you've got it backwards, though; you'll want the particle to blend on top of the background, so the background has to be drawn in a lower (earlier) queue.