Author Topic: [UIPanel] Circular clipping view  (Read 3618 times)

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
[UIPanel] Circular clipping view
« on: January 18, 2013, 01:16:47 PM »
Hi everybody,
I was wondering if it could be possible to create a circular clipping view (only by Hard/Alpha clipping, not soft) rather than a rectangle one.
This could be great !!

Thanks,
Loic.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [UIPanel] Circular clipping view
« Reply #1 on: January 19, 2013, 01:38:47 AM »
You could do this by using a texture instead of specifying a matrix like NGUI does. It involves writing your own shaders, however.

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
Re: [UIPanel] Circular clipping view
« Reply #2 on: January 21, 2013, 04:54:34 PM »
I managed to solve this using depthmask and circular mesh, kinda dirty but it works...
Thank you anyway !

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: [UIPanel] Circular clipping view
« Reply #3 on: January 23, 2013, 07:17:51 AM »
could you share your solution?
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
Re: [UIPanel] Circular clipping view
« Reply #4 on: January 23, 2013, 10:48:58 AM »
I'm using this shader:
http://wiki.unity3d.com/index.php/DepthMask

And I apply it to a circle mesh. This mesh is a square place with an circular hole on it. It could be any different shape, like a star for example.
If you combine it with a UIPanel hard clipping (same size as the mesh square), it will give you the illusion of circular hard clipping.

Of course it doen't work with soft clipping, cause of the shader (display pixel or not, 0 or 1).