Author Topic: Clipping non-widget objects.  (Read 3468 times)

Pip Robbins

  • Guest
Clipping non-widget objects.
« on: March 05, 2013, 11:51:21 PM »
Hey,

I have a UIPanel with an alpha clip clipping bounds set up, (Although I have tried hard / soft clip). I am trying to clip objects which are not widgets for example a basic unity primitive cube.

I've done a search of these forums, followed suggestions such as using a shader that enables clipping etc. I just can't seem to get it to clip the object, the layer is correctly set to the 2D UI cameras layer. Its parented on the same transform as many other widgets which are getting correctly clipped.

I've tried all the NGUI shaders such as -

Unlit/Transparent Colored
Unlit/Transparent Colored (AlphaClip)
Unlit/Premultiplied Colored
Unlit/Premultiplied Colored (AlphaClip)

Any help would be greatly appreciated!
« Last Edit: March 06, 2013, 12:26:59 AM by Pip Robbins »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Clipping non-widget objects.
« Reply #1 on: March 06, 2013, 09:59:13 AM »
The short answer is: You can't.

The UIPanel does not handle drawing of the primitives or 3d elements outside of NGUI widgets, which means that the shader won't know how to clip it.

You could possibly modify a shader to use a referenced UIpanel to determine clipping, but it's bound to be dodgy.

Alternatively, you can put the 3d stuff into a different layer with its own assigned camera, which has a smaller viewRect corresponding with the area you want to clip. This is tricky, but possible.

Does that help you?

Pip Robbins

  • Guest
Re: Clipping non-widget objects.
« Reply #2 on: March 06, 2013, 05:33:12 PM »
Cheers - it helps and confirms my thoughts.

I need it to work in conjunction with vectrosity, currently I have made a script which just turns of points in a line out side of the UIPanels bounds, which works perfectly.

I'm working on making a shader (for the fun of it mostly) which will clip 3D objects outside of a vector4 input (UIPanels bounds) which if it goes well I can upload here for everyone else to use.

I might end up doing the camera way in the end though, as I am making a visual state machine, which players can add behaviour nodes and hook up their transitions, which mean I want to be able to scroll / pan / zoom indefinitely.  So a 2nd UI camera might be the most elegant.