Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: rain on May 22, 2014, 08:29:46 AM

Title: Getting 3D objects with custom shaders clipped
Post by: rain on May 22, 2014, 08:29:46 AM
Hi!

I'm making a store screen menu for the game I'm working on and got stuck with this:
I have a scrollview in which the purchasable items will be displayed via their in-game 3D models and the scrollview obviously doesn't soft clip the 3D objects when it's expected to.

How could i make them get clipped?

Ps: I've never worked with shaders before
Title: Re: Getting 3D objects with custom shaders clipped
Post by: ArenMook on May 22, 2014, 04:03:10 PM
Set up an off-screen camera to render your 3D objects into render textures, then display render textures using UITexture like normal widgets.
Title: Re: Getting 3D objects with custom shaders clipped
Post by: aholla on June 30, 2014, 10:52:54 AM
Hi is there a way to have the 3D objects clipped and animated. Would this mean constantly updating the UITexture. Is that something that should not be done?
Title: Re: Getting 3D objects with custom shaders clipped
Post by: Nicki on June 30, 2014, 07:17:45 PM
Set up a secondary camera with a smaller view rect that renders on top of your 2d UI camera. You can have the 3d track widgets in a list in update with math and then it will behave as you'd imagine.

Rendertextures are a little tricky to work with as they tend to need special shaders because they muck up alpha in textures otherwise.

I'm not sure if you need to update the UITexture contantly if you assign a rendertexture to it, but I*m not sure. I seem to recall that it makes an instance of the source texture, which might break the reference, but arenmook would know better than I do (I don't have the code in front of me).
Title: Re: Getting 3D objects with custom shaders clipped
Post by: ArenMook on July 01, 2014, 04:44:32 AM
You only have to assign UITexture's texture once, and you can make it a render texture if you want. Updating the render texture will automatically update what's visible, as NGUI only creates the geometry. Render textures are the best way to go, and assuming you render into the texture every frame (as it does by default with every camera), your textures will update with them.