Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: cayou on January 18, 2013, 01:16:47 PM

Title: [UIPanel] Circular clipping view
Post by: cayou 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.
Title: Re: [UIPanel] Circular clipping view
Post by: ArenMook 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.
Title: Re: [UIPanel] Circular clipping view
Post by: cayou 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 !
Title: Re: [UIPanel] Circular clipping view
Post by: PoN on January 23, 2013, 07:17:51 AM
could you share your solution?
Title: Re: [UIPanel] Circular clipping view
Post by: cayou on January 23, 2013, 10:48:58 AM
I'm using this shader:
http://wiki.unity3d.com/index.php/DepthMask (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).