Considering render results of the attached project (screen-shots included in the zip file), it seems Unity is sorting objects using their distance to the camera, where it should sort them using their Z depth.
This causes a lot of render artifacts when rendering bill-boards lying near the camera.
Mathieu: Is this primarily for the UI? Or some other issue. You are correct that, afaik, Unity sorts based on distance to the center point of the bounding box from the camera. I find that for UI solutions, this is not an issue with orthographic cameras, but certainly can cause issues with perspective cameras.
Little Angel : No this is not used for the UI but to simulate trees in a 3D view (we really have lot of trees). As for the orthographic projection, I think this works because in this case Z depth and distance to the camera is the same thing.
“Opaque” isn’t a queue. “Geometry” is probably what you were looking for, but you don’t have to specify a queue for that. (This does not make Unity sort better.)
transparent would be a queue and would be sorted by the game objects 0,0,0 point (so don’t play smarty pant and don’t use the combine children script for transparent just in case you do or consider doing it or hell will break lose as the sorting against opaque will simply fail more or less completely)
Now, is there a chance to see this bug fixed in upcoming versions ?
I sent a bug report using the dedicated application but have no feedback at all… I don’t even know if it has been taken into account. Given the amount of money we put into pro licenses, I find it quite annoying.
I am sure that the bug report has been logged. It is true that there is no feedback, except for the automated response on many items, which can be off-putting, to say the least.
Merely out of curiosity, why are you finding the built-in trees inadequate? I’m sure you have good reason, but I’m still curious.
Our product is a rewrite of another one that used billboards for trees, and we don’t want to change the look feel too much right now (still, we are actually using meshes for hi-end phones)
Our product is supposed to run with high FPS on Android phones, and there are hundreds of trees on each map, sometimes more than 50 on an unique frame
Our product uses a fully generated world, Unity is only here for multi-platform purposes
Unity’s trees do not allow us to have the cartoonish style we tend to achieve
Just a suggestion, I found that using anything built into unity with trees gave me far to much of a fps drop. But, creating a large group of trees I combined in 3ds max, was far more efficient. In fact, it was a difference of 100 draw calls vs 2000 or so draw calls if I remember correctly. and there was still a lot of room for optimization. If your not generating things on the fly, I’d definitely recommend creating scatter meshes and optimize them down to the right vert count for import.
I still have absolutely no feedback concerning this issue, so I’m going to explain it a bit more in the hope that it will be understood, if that is the problem :
Putting objects in the transparent queue should have the effect of sorting them (using their 0,0,0 point to quote dreamora) back to front relative to their distance to the camera, projected on camera’s z axis.
But, looking at what happens in the project attached to my first post, it seems they are sorted back to front relative to their distance to the camera, period.
One solution I found to circumvent this is to use AlphaTest = 0 in transparent objects’ material shader (as in my case they are all billboards with transparent textures), but this is does not eliminate all artifacts, and has the side effect of slowing render on PowerVR devices, which don’t like the discard operation at all.
It looks like Graham Dunnett, our Support Director, asked you to submit a bug on July 14th in the UnityAnswers thread. Did you ever follow up on that or try to contact support@unity3d.com directly?
I’ve been thinking for a long time that alpha blended objects were ordered based on their pivot position but (in certain cases at least) it is not. In fact, it’s the center of the bounding box of the mesh which is used. You can alter the z-ordering without moving the objects by just tampering manually with their bounds property.
Now concerning the fact that objects should be ordered as you expect… well the 2 options have valid interest. z ordering on the z axis of the camera is best for billboards aligned with the screen plane and z ordering based on distance only is best for billboards with ‘look at camera’ controllers or other non planar objects.
Following Graham Dunnett’s advice, I posted several ideas in the given website (splitting the problem in several parts) but did not receive any feedback from here. (Note I also asked him an open question and did not receive an answer).
I then used Unity’s report tool to submit a bug using the project attached to this thread, but did not receive any feedback either (it is fair anyway, since it is clearly stated in the tools’ UI : feedback is next release’s fixed bug list).
Then I came to this forum in the hope to find useful help from the community, and it was the case to some extents.
Finally, I have to admit I don’t remember if I tried to mail something at support@unity3d.com. I think I did not since looking again at a bunch of Unity3D’s web pages, I cannot find this address (admittedly, I could have inferred it). As a side note, a Google search on it only find pages related to licensing issues…
Please note that I understand there’s a lot of work being done on the engine, and my problem is far from being of interest to a lot of people. What frustrate me here is that I don’t know at all if my request has been taken into account, I even don’t know if I’m right or wrong (now Krobill’s answer tells me I’m not exactly right), not to speak about a possible solution !
I don’t know if I can cheat on a billboard’s bounding box center, but if that’s the case your solution may work !
I also considered drawing all transparent objects in immediate mode at the end of the render frame. This way I could sort them the way I like. But that’s quite a ugly hack !
Ok so I’m wrong here. My assumption was made on my experience on other projects and on documentation found on different web pages (OpenGL’s wiki to name one, I don’t remember of my other references).
The good news is, “both options are valid” : it means some of the ideas I suggested on feedback.unity3d.com are valid too : be able to configure sorting of transparent objects, or be able to reserve render queue ids to custom render queue implementations (which would in particular allow to sort objects the way one want).
Thanks for your answer, now I know it’s not really a bug, and I can ask for new features instead of bug fixes !
Yeah, I understand the frustration of not knowing whether or not this is a bug, user error, etc and given the extended time frame that this issue has been a problem for you I think you’re being pretty civil here
Can you give me the bug report case number? I’ve looked at your repro project posted here twice now (once months ago and again today) and I can’t exactly repro the problem you’re having. No matter how I try to screw up the sorting order with multiple instances at different distances from the camera it still sorts properly for me with the default unlit/transparent shader. Admittedly, I might not be understanding the issue 100% so if you can give me the bug report case number I’ll pass it on to our GFX team and they’ll have a look at it.
Edit - ok, so no bug, but a feature request… still give me the bug number so I can pass it on.
Thanks ! I always try to, but not always succeed in since I’m far from being fluent in English, and cannot always tell if a sentence could hurt someone or not !
Yes for sure : 429662
As a reference, here is the description I entered for the bug, maybe it could help you see my problem :
What happened
I have two transparent planes both rendered in the transparent queue, facing the camera.
The foremost plane (B) should then be rendered after the farthest one (A) but the opposite is what happens : objects in the transparent queue should be sorted using their Z depth, but they are sorted using there distance to the camera.
How can we reproduce it using the example you attached.
Just open the Scene view and / or and the Game view of the attached project, and see that the A plane overrides what was rendered for the B plane.