Jump to content

UV coordinates to a generated mesh


Alex_on_the_web
 Share

Recommended Posts

Hey folks!

 

I've been screwing around with this damn mountain side covering mesh all day. 

The last few (4+) hours were about getting it a bump mapped texture. I'm having problems with making up UV coordinates I assume.

 

I'm going around each side, and I'm pushing two vertices for each original vertex on the edge of the mountain, one for the top, and one for a bottom to cover the side, like so:

xLeft.push(x, y, z, x, -70, z);

Then I join them to a single array of positions like so, and try to make 2*UV coordinates for each pair of vertices (pair as in a top and a bottom one, like inserted before):

var wrappingPoints = xRight.concat(zTop, xLeft, zBottom);var wrappingUvs = [];var increment = 1 / wrappingPoints.length / 3 * 2;for (var i = 0; i < wrappingPoints.length / 3; i += 2) { wrappingUvs.push(  increment * i, wrappingPoints[3 * i + 1] / yMax, // x , y  increment * i,0  // x , y );}

I've been mixing up the orders of the Us and Vs, and trying to do all sorts of experiments, but for the sake of it, I cannot find what's wrong with this.

 

The thing that's visible on the image is that every second triangle of the mesh (1 tri / quad) has it's texture upside down.

 
So the coordinates I wanted to add for each pair of vertex were - (increment * i, wrappingPoints[3 * i + 1] / yMax) for the top and (increment * i,0) for the bottom one. 
 
What am I doing wrong here?
 

post-5699-0-48291500-1417654160_thumb.pn

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...