Author Topic: Getting 3D objects with custom shaders clipped  (Read 3212 times)

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Getting 3D objects with custom shaders clipped
« 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Getting 3D objects with custom shaders clipped
« Reply #1 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.

aholla

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 40
    • View Profile
Re: Getting 3D objects with custom shaders clipped
« Reply #2 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?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Getting 3D objects with custom shaders clipped
« Reply #3 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).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Getting 3D objects with custom shaders clipped
« Reply #4 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.