Author Topic: Backward geometry  (Read 7088 times)

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Backward geometry
« on: January 25, 2017, 11:59:30 AM »
Hi !

I updated NGUI to latest version and I'm surprised to see my geometry now is backward.
Looking at git logs, I see commit 4bed6d8 (5th November 2016) does this on purpose.
I may be wrong but I think its wrong, and I'll try to demonstrate here...

You'll find attached a simple project which displays :
 - Sprites facing camera on left column
 - Sprites not facing the camera on right column (which, when you press start, rotates).
 - Top line uses a shader with CullMode Back, so should only be visible on faces facing the camera (left column)
 - Middle uses a shader with CullMode Off, so should be visible on all faces (both columns)
 - Bottom uses a shader with CullMode Front, so should only be visible on faces not facing the camera (right column)

Using revisions before 4bed6d8, that's what happens.
Starting from that commit behaviour is inverted as expected by the code, but IMHO it's wrong.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Backward geometry
« Reply #1 on: January 25, 2017, 02:18:39 PM »
Most of the time UI geometry shouldn't have any culling at all, so the whole question of where the front is only applies to custom shaders that you create and explicitly choose the culling on setting it to something other than "off".

I'm still torn about that change tbh...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Backward geometry
« Reply #2 on: January 25, 2017, 02:34:46 PM »
Having another look at it I can't remember the original reason why I made this change... it had something to do with decals in my current game, Sightseer -- but changing it back I see no issues. I'll change it back and see if I find any problems, if not, I'll have it changed back in the next update. You can change it back locally by inverting the indices around line 689 of UIDrawCall.cs:
  1.                         rv[index++] = i;
  2.                         rv[index++] = i + 1;
  3.                         rv[index++] = i + 2;
  4.  
  5.                         rv[index++] = i + 2;
  6.                         rv[index++] = i + 3;
  7.                         rv[index++] = i;
  8.  

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: Backward geometry
« Reply #3 on: January 26, 2017, 06:12:21 AM »
Ok, thanks !