   weird texturing issue
  I've recently been trying my hand at some basic texturing of my terrains.  My initial approach for now is to just stretch a texture of equal dimensions as my terrain over it.  I'm using a generic grass texture and a simple little formula for determining the appropriate uv coords.  The formula is:u = (1 / width) * xv = (1 / height) * yAnd that forumla gets applied to the Tu and Tv properties of the vertices as I iterate through the terrain data.  Problem is, when I run the program, all I get is a solid vomit green color over the whole terrain, not the nice grass texture I expected.  I already verified the formula works, too.  Say for instance the texture and terrain are both 256 x 256.(1 / 256) * 256 = 1(1 / 256) * 128 = .5(1 / 256) * 64 = .25....(1 / 256) * 0 = 0Which are all correct values, so I was wondering if anyone had any suggesstions or ideas as to what might be going on.  Thanks.-AJ   
  Just to double check, where are the vertices for the terrain?  Is the center of the terrain at the terrain's origin?   ;  Are width and height floats?  If they aren't, you'll be performing an integer divide and the result will most likely be zero.;Quote:Original post by MoeJust to double check, where are the vertices for the terrain?  Is the center of the terrain at the terrain's origin?No, the terrain's origin is the top left corner of the heightmap (back left corner when rendered in 3D) so it seems to me that since texture coords are given in the same way, relative to the texture, it should be right.Quote:Original post by donAre width and height floats? If they aren't, you'll be performing an integer divide and the result will most likely be zero.Yes, they are floats, but thanks for the suggesstion.To both: I apologize for the delayed reply, I had duty the last couple days so I haven't been able to get on a computer.  Thanks again.-AJ   ;  Well if you're getting a solid color across the entire terrain, that tends to point a the texture sample grabbing the same texel for each vertex (usually (0, 0) - check your texture to see if the upper left pixel is "vomit green").  If that is happening, either your calculation isn't getting the correct result, or the correct result isn't making it into the vertex buffer in the expected place.   