I would like to use a shader for the particle system and meshes. The problem is that the meshes are always drawn in front of the particles. Can someone tell me, how to avoid that? Code (csharp): Shader "TransparentIssue" { Properties { _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} } Category { Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} Alphatest Greater 0 Lighting Off ColorMask RGB Cull Off ZWrite Off Fog {Mode off} SubShader { Pass { Lighting Off BindChannels { Bind "Vertex", vertex Bind "Texcoord", texcoord Bind "Color", color } Blend SrcAlpha OneMinusSrcAlpha SetTexture [_MainTex] { combine primary * texture } } } } }
If both your particle system and your mesh are using that shader, then they will be drawn back to front. This order is imposed by virtue of being in the Transparent queue. If you want to force draw order, you'll have to put the mesh's or the particle system's material in a different Render Queue.
I also expected that behaviour. Unfortunately the particle system is always drawn behind the mesh, even if it is closer to the camera. I was looking in the reference, if something is mentioned, that the particle renderer is handled differently. But I found nothing.
Perhaps the bounding volume of your mesh is larger than you think, placing it's center nearer to the camera than the particles. If that is the problem, you can force the correct ordering by placing the particle material in the transparent+1 queue (note that that may mess things up if you have other transparent objects besides the particles and the mesh).
No, that's not the case. I just checked all the values and calculated the distance of the camera to the (transformed) bounding volume centers. Everything is okay. The centers of the bounding volumes of the particle and mesh renderers are correct, too.
I reproduced the issue in a very simple example package. The scene contains two cameras. One should show the mesh in front of the particles, the other one should show the opposite. But both show draw the mesh in front of the particles. If someone confirms, that there is a problem, I would fill a bug report. Thanks.
This is a general problem with overlaying semi-transparent geometry, not a bug. Is it necessary that your mesh uses alpha also? With solid geometry there would be no problem. What is the effect you are trying to achieve? Maybe there is a solution...
This one was just for demonstration purposes. I am using it for a custom particle system. If the situation is like that, it can not be mixed with Unity's particle system at all, which is not really good. So there is no solution unfortunately. And it is not a semi-transparent geometry problem, as those objects are intended to be rendered from back to front, exactly as Daniel Brauer described it. So it actually is a bug from my point of view, as there is nothing written (or at least I could not find it), that the particle system has a special role in the rendering queue.
The problem appears to be the "Receive Shadows" option. Try to deactivate it. Also, you should use sorted billboards.
Deactivating "Receive Shadows" has no impact. Same for sorted billboards. The mesh is still rendered in front of the particle system, even if it is behind it.
That's by far the coolest bug I ever found in Unity ! If the box has a scale of (1, 1, 1), the rendering issue happens. For any other scale, no problem! Edit: You may also change the scale of the particle system to avoid the problem. Edit: Bug always occures, if both have the same scale Edit: Bug reported (Case 414572)
Martin Kraus, maybe it has the same effect as changing a scale. I expect you own Unity Pro, such that it has an effect for you. I only have Unity. Both make no sense. Edit: I added it to the bug report.
After seeing the project, I agree this is a bug. Deactivating receive shadows fixed it for me as well (Unity pro), but I do not see how that would make it less of a bug .
I agree, it doesn't. BTW I'm using the free version of Unity. (Maybe one needs to restart the particle system (by starting the game mode) to see that it has an effect.)
Martin Kraus, you are right. I disabled it for both, the mesh and the particle system. In that case the same issue occures again. You only mentioned one. If both have the same settings it doesn't seem to work properly.
It is even stranger, if you modify the distance to the camera, there is a certain point at which it may switch between correct and incorrect. To the Unity employee who has to fix this bug: I am going to offer you a drink if we ever meet us!
Got same issue. Tried everything from this thread. Nothing helped. Update: The only thing that helps a bit is setting Soft Particles factor to 3
@Gua, since this is a very old report, it might be worth to submit another bug report, because I can also not find it in the issue tracker.
Unity's soft particle settings don't work well for small scale stuff. The ranges it allows for is mainly good for third person scales like Angry Bots. It's kind of useless for larger or smaller scales. I would suggest turning off soft particles or write your own particle shaders that don't use it.
@bgolus Thanks! Turning off soft particles (by using the Mobile/Particles/Alpha Blended rather than Particles/Alpha Blended) brought all my particles back that had disappeared when they went behind alphatest translucent geometry!