Author Topic: NGUI VR Best practices?  (Read 4645 times)

sfj

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 14
    • View Profile
NGUI VR Best practices?
« on: February 06, 2017, 03:00:57 AM »
Hi,
  I'm wondering what the recommend way is for implementing ngui in VR. So far I just made a hack that parents the whole GUI on the player camera so it gets rendered with the rest of the scene, to place indicators for level objects I trace a line intersecting the GUI plane.

So it sort of works...but there are issues with the GUI becoming smaller/scaled..there are of course many ways to deal with this...but I'm was wondering if there is an "official" recommend way of working with VR gui.

My game is sort of FPS game with some stats on the hud and gui elements/indicators overlaying world space objects.

/stefan

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI VR Best practices?
« Reply #1 on: February 08, 2017, 08:31:36 AM »
The best way is to indeed use the game camera. I also suggest using shaders that don't do Z-testing at all (ZTest Always). NGUI already draws everything in the correct order for you, so Z testing is not necessary. This way you can have everything drawn by one camera without clearing the screen (thus boosting performance).

sfj

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: NGUI VR Best practices?
« Reply #2 on: February 13, 2017, 03:45:53 AM »
Thanks for the reply,
  So I'll continue on my path with he GUI attached to the camera.

I can see that making the modifications to the shader breaks clipping, are there further modifications that can be made to make it work or is it a matter of splitting the gui by material/shader?

Cheers

Stefan

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI VR Best practices?
« Reply #3 on: February 13, 2017, 11:36:51 AM »
NGUI's clipping is done by simply finding a similarly named shader -- for example "Unlit/Transparent Colored" will get "Unlit/Transparent Colored 1" when clipping is needed. It's actually an old way of getting shaders, and I've been meaning to change it into a single multi-compiled shader, but never seem to get around to actually doing it (mainly because of the "it works, so why mess with it?" excuse).

If you create a custom shader, make sure to also create the clipped versions of that shader that will follow the NGUI's expected naming convention.