Author Topic: Depth issue with multiple atlases  (Read 8730 times)

gooms9

  • Guest
Depth issue with multiple atlases
« on: November 06, 2012, 07:57:34 PM »
Hey, I'm having a bit of trouble getting my sprites to render correctly when they are in multiple atlases. Here's an outline of how the scene is set up though.

- I have 2 different sprites, the card sprite, and a large semi transparent sprite used to grey out the entire screen.
- I have 2 copies of the same card sprite in the scene. One is positioned in front of the giant screen block texture, and the other is positioned behind it.
- The card sprite is in an atlas, and the giant screen block texture is added as a simple texture.
- The panel that these objects are in has depth sorting enabled, otherwise both of the textures draw either behind the screen block, or in front of it.

Is there any way of getting this set up to work properly without putting my screen block texture into the same atlas that my cards are in? I notice this same problem with fonts. I have some large fonts in the game and I can't possibly hope to have everything combined in the same atlas due to the single texture dimension limitations.

I created a demo scene to highlight this problem, but I wasn't sure on how to attach it due to the fact that it contains the full version of NGUI and I shouldn't be posting that where anyone can access it. Let me know if you need a demo scene though and we can figure out some way of getting it to you.

Thanks for your help!

lime-green.at

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 60
    • View Profile
Re: Depth issue with multiple atlases
« Reply #1 on: November 07, 2012, 03:27:40 AM »
I guess you just have to adjust the z axis of the sprite in the front. If you upload a demo scene, i maybe could get you rid of that problem.

loverains

  • Guest
Re: Depth issue with multiple atlases
« Reply #2 on: November 07, 2012, 03:54:12 AM »
same problem as mine,i use 2 atlas and the label work not correct with sprite using different atlas,even i set the sprite z to 0.5 and label 0,in editor view it's corret,but in game view,lable can't seen

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Depth issue with multiple atlases
« Reply #3 on: November 07, 2012, 04:31:07 AM »
Adjusting Z of multiple atlases will only work correctly with orthographic cameras (2D UI). 3D UI uses a perspective camera, so it won't work properly.

That said, your problem is caused by the fact that you have sandwiched one atlas in between of another one. Everything using the same atlas will be drawn in the same draw call -- so your sprites will be either in front, or behind. What you're trying to achieve can only be done by splitting up the draw process into 3 steps by adding an extra panel for background (or foreground) objects. Read the explanation in the FAQ for more information.

gooms9

  • Guest
Re: Depth issue with multiple atlases
« Reply #4 on: November 07, 2012, 02:39:39 PM »
Awesome. This worked great. Thanks!