Hello Guest

Author Topic: Using uiMask/depthmask for custom components/objects  (Read 6565 times)

Seirie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Using uiMask/depthmask for custom components/objects
« on: July 01, 2013, 07:32:48 pm »
Hey! So I'm trying to utilize the ui mask to create a sort of slot machine effect for a very ui-heavy game. I've been toying around with it for a little bit but I'm running into a problem where the masking effect is working in the editor but doesn't work in play mode.

I took the depthmask prefab from the prefab controls that come with tk2dUI and threw it in the scene. Tossed a test sprite in the scene, gave them both the same transform.position.z value and set the depth of the uimask to 1. Again, looks great in editor, no in play. Perhaps there is something I'm missing?

It's worth pointing out that I am not actually using anything else from tk2dUI in this project, I dont have a UI manager in my scene or any other UI components. I only want to borrow this masking technique because it seems really handy.

Any insight is appreciated.
« Last Edit: July 01, 2013, 07:40:16 pm by Seirie »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using uiMask/depthmask for custom components/objects
« Reply #1 on: July 01, 2013, 10:53:49 pm »
Push the sprite forward a bit. i.e. try having it "inside" the mask volume to get better sort predictability. Should work better.
Also fi you're using a perspective camera, don't forget to set transparencySortMode to orthographic.

Seirie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Using uiMask/depthmask for custom components/objects
« Reply #2 on: July 02, 2013, 12:19:24 am »
Hey, thanks for getting back! Unfortunately I still can't seem to shake the issue.

The camera in the scene is a pretty standard orthographic tk2d camera and I verified that the transparency sort mode is indeed ortho.

Putting the sprite "inside" the mask of the volume doesn't seem to have any better effect. I gave the depth mask a depth of 20 and positioned the sprite 10 units away from the position of the depth mask.

I've attached an image that shows what I'm dealing with.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using uiMask/depthmask for custom components/objects
« Reply #3 on: July 02, 2013, 10:17:34 am »
Try moving both the sprite and the clip region back away from the camera. If the clip volume is intersecting the camera, it will not draw into game view...

Seirie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Using uiMask/depthmask for custom components/objects
« Reply #4 on: July 02, 2013, 05:35:09 pm »
Ahhh, you know what, the camera was far enough away but I believe in all my testing the volume of the mask was bleeding outside the edges of the camera's clipping planes. Wow, can't believe I managed to miss that for so long.

Thank you so much for your help! Appears to be working now :)
« Last Edit: July 02, 2013, 05:55:55 pm by Seirie »