Author Topic: Slight UV Nudging  (Read 2047 times)

apocriva

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Slight UV Nudging
« on: January 30, 2014, 11:17:28 PM »
In some situations when scaling up a UI (to make "fat pixels"), I've found that the triangles rendered by NGUI are resulting in ever-so-slightly-off textures. This manifests as funny-looking jaggies along the edge of what should be straight lines.


This is remedied by putting in a very small nudge when calculating texture UVs.


I've posted the small changes I made within NGUIText.cs and NGUIMath.cs for this. Thought it might be useful for others. :)
http://pastebin.com/C7cBW2d1

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Slight UV Nudging
« Reply #1 on: January 31, 2014, 11:58:24 AM »
That's a strange hack, I must admit.

apocriva

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Slight UV Nudging
« Reply #2 on: January 31, 2014, 05:46:50 PM »
Little tiny precision errors make things round off incorrectly sometimes... bit this I've found to be unpredictable -- if I scale things up one way it works, another way it doesn't! iunno. :)

Oh wait now, it has become clearer once I started having something at the edge of the screen. There is a half-pixel offset being applied to the widget meshes that I wasn't expecting. Anyway, these are self-inflicted issues due to the fact that I'm forcing NGUI into pseudo-pixel-perfection and not really letting it be pixel perfect. :)
« Last Edit: January 31, 2014, 06:09:23 PM by apocriva »

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: Slight UV Nudging
« Reply #3 on: February 03, 2014, 08:48:25 AM »
This fix messes up the new anchoring system for me.

raomuqi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Slight UV Nudging
« Reply #4 on: February 08, 2014, 04:07:09 AM »
I have similar problem :
a strange line appear when i scale down a sprite equiped with a triangle image