- Home /
Billboard Trees Overlapped
I have done plenty of research on this question, and it seems nobody has been able to find an answer thus far (or at least they haven't posted one).
My billboarded trees are being overlapped (covered up) by a particle system that's way off in the distance. Once the trees become 3D game objects, it works fine. I cannot seem to figure out how to prevent this overlap from happening! I assume there's a way to solve this probelem using layers, but I have NOT figured out a solution yet. If anybody could provide some suggestions, I would really really appreciate it!! Thank you!
Answer by aldonaletto · Jun 28, 2011 at 03:45 PM
Billboards don't take the depth buffer in account, they are drawn in the order defined by its renderQueue parameter. You can put the particles behind the trees assigning this script to the particle system object:
function Start(){
renderer.material.renderQueue=2800;
}
It seems tree billboards renderQueue is 2900, thus any value below it will be drawn first (which makes it appear after them).
You may still experience problems if the camera looks to this scene from BEHIND the particles: since they now are draw first, the tree billboards will cover them. The solution in this case is to set renderQueue in the Update function to different values depending on which billboards must appear in front of each other.
"Billboards don't take the depth buffer in account"
Not quite. Billboarding is just a geometry oriented to face the camera (in various ways). The orientation of geometry doesn't affect render order. Like you wrote "renderer.material.renderQueue=2800;" the render order is tied to the material.
Thank you Flav and Aldo!! I applied the script you provided to my particle system, and it works perfectly. I will have to apply an update funtion eventually, but this is exactly what I needed at this point. Thank you again for the help, I upvoted your answer!
@Tim $$anonymous$$ake sure to mark it as correct too.
@flaviusxvii, it was actually a simplification - maybe way too simplified. Trees and particle billboards shaders actually take the Z buffer into account, but not the same way as other opaque shaders. It seems the problem is exactly what you pointed out in your answer: they read the Z buffer info, but don't write to it, so the things they draw don't update the Z buffer - that's why the images drawn last cover the previous ones, no matter which one was in front of the other.
@Aldo Naletto Thank you, I thought I was gonna have to rewrite each particle shader I was using. I didn't know you could do the above with such a simple script.
Answer by flaviusxvii · Jun 28, 2011 at 02:17 PM
It sounds like your billboarded trees aren't writing anything to the depth buffer when they are being drawn.
Thank you Flav! You'll have to excuse my utter lack of program$$anonymous$$g knowledge but... how might I go about fixing this problem? The only trees I'm using at this point are the ScottsPineA and ScottsPineB from the Unity Terrain Assets. I have NOT modified them other than applying colliders to them.
http://answers.unity3d.com/questions/124403/tree-billboards-with-zwrite.html
This person had essentially the same problem and no one answered.. I'll have to google around to find out (you can google too).
I have in fact been scouring the net to find an answer to this problem. I have seen this question raised on multiple forums, yet nobody seems to have reached a finite answer. I will continue searching, and I do appreciate you taking time to help out!
Well, I'm pretty sure it's related to the material type. Particles are often rendered with materials that don't write depth, to avoid weird blending issues. This just doesn't often play nicely with other similar materials. ONE thing you could do is make sure you draw your trees AFTER you draw your other particles.
http://answers.unity3d.com/questions/8220/rendering-order.html
Your answer
Follow this Question
Related Questions
Particle billboard rotation? 2 Answers
Particles sized to screen, not scene? 1 Answer
Use local direction for particle billboard type 0 Answers
Is the trail emitted by the Trail Renderer "billboard"? 1 Answer
Particle rotation: supported yet? 1 Answer