Author Topic: [Feature Request] 2nd UV coordinate set support.  (Read 4520 times)

Irin1178

  • Guest
[Feature Request] 2nd UV coordinate set support.
« on: May 07, 2013, 10:02:56 AM »
I was wondering if we could get official support for a second set of uv coordinates to be passed into the mesh generation. Even if the second uv coords just mimiced the original uv coords by default.

I was just concerned with making such changes to the UIDrawCall and UIGeometry classes myself that I worry about merging those changes with future updates.

Irin1178

  • Guest
Re: [Feature Request] 2nd UV coordinate set support.
« Reply #1 on: May 07, 2013, 12:29:11 PM »
An example of where I would use this feature request in a perfect world, each font character's uv channels would be

mesh.uv1 = 0-1 per character (so you can slap a texture across each character)
mesh.uv2 = vertex x location/totalLabelWidth (so you can animate a texture across an entire sentence)

I think that would take care of just about every input a shader would need, that I can think of off hand.

keysosaurus

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: [Feature Request] 2nd UV coordinate set support.
« Reply #2 on: October 03, 2013, 11:47:07 AM »
Did you end up getting this working?

Trying to do something similar, adjust the texture offset of the second texture on a material at runtime.

Cheers

Irin1178

  • Guest
Re: [Feature Request] 2nd UV coordinate set support.
« Reply #3 on: October 03, 2013, 12:01:00 PM »
I did, but it was kind of a hack job I did. Not the cleanest implementation. I'd love to see this feature get some official support or see myself getting the time to clean up the impl i did myself.

Basically meshs already have a uv2 parameter, so I had to pass a 2nd set of UV that I wanted, in this case it was just 0-1 for each letter in a label, through to the render call. This involved adding uv2's, basically anywhere you see .uv, in UIGeometry, UIFont, UILabel, UISprite, and UITexture.

I had hard coded my uv2 coordinates in UIFont just after the uvs.Add call is made in the Print(). If you're looking to animate them, you will want to do more work there then I had.

Also as a side note, you might get more use out of making a mask shader and UV animating a texture across an alpha mask. Thats how we do things like gold glints across text.

keysosaurus

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: [Feature Request] 2nd UV coordinate set support.
« Reply #4 on: October 03, 2013, 02:19:45 PM »
That's exactly what I'm trying to do, but I can't get the UVs animating.

http://www.tasharen.com/forum/index.php?topic=6002.0

Can't get it working at runtime, but it updates whenever I enter or exit play mode.

I'm obviously missing something, how did you guys do it?

Irin1178

  • Guest
Re: [Feature Request] 2nd UV coordinate set support.
« Reply #5 on: October 03, 2013, 03:31:07 PM »
I should note, we have not made the jump to 3.0 yet.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [Feature Request] 2nd UV coordinate set support.
« Reply #6 on: October 04, 2013, 02:19:09 AM »
Secondary texture coordinates will be used in the future. I plan on using them to make it possible to add detail textures to UI elements.

keysosaurus

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: [Feature Request] 2nd UV coordinate set support.
« Reply #7 on: October 04, 2013, 04:27:03 AM »
Great to hear, hope you'll get to it soon!  :)

Tried my shader in an older version of NGUI (2.3.1) and it works perfectly. I can adjust the texture offsets in the material no problem!

What's changed in 3.0? Is it something small that I can roll back?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile

Irin1178

  • Guest
Re: [Feature Request] 2nd UV coordinate set support.
« Reply #9 on: October 07, 2013, 01:22:54 PM »
Aren,

You're answering a lot of my wishlist items for NGUI with these recent 3.0.x update bulletpoints lately..

Any estimate on when you plan to tackle the detail textures feature? I think that's the last feature I need to account for before I can make the upgrade to 3 and not break my game.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
« Last Edit: October 08, 2013, 02:02:21 AM by ArenMook »