Search Unity

procedurally generated uvs for a cylinder

Discussion in 'Scripting' started by iamseb, Apr 27, 2011.

  1. iamseb

    iamseb

    Joined:
    Mar 19, 2011
    Posts:
    4
    Hi, I've been working on a procedurally-generated cylinder for a tunnel racer.

    I have a generated mesh for the cylinder, but am struggling to generate UV coordinates for my mesh. All the examples for assigning uv coords I can find talk about manual assignment through mesh unwrapping (usually by cutting a seam in the cylinder).

    For example, I have a single circle of verts numbered 0 - 5. I want the text coords to be:

    uv x,y = vert
    ------------------
    0.00,0 = 0
    0.16,0 = 1
    0.33,0 = 2
    0.50,0 = 3
    0.66,0 = 4
    0.83,0 = 5
    1.00,0 = 0

    Do I need to assign a 7th column of vertices in my cylinder that share coordinates with the 1st, or is there something I'm missing about uv assignment?
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Hi, welcome to the forum!

    It is often the case with mesh generation that you need to add extra vertices purely for the purpose of allowing different UVs or normal along the two surfaces at an edge. If you double up the vertices at the first edge, you can arrange for the first surface to start with a U or V coordinate of 0 and the last surface to end with 1.
     
  3. iamseb

    iamseb

    Joined:
    Mar 19, 2011
    Posts:
    4
    Thanks andeeee, I figured that might be the case and implemented it anyway. :)