Skip to main content
gamedev.net
🔒 Locked

weird texturing issue

Started by u235 Jun 2, 2006 at 12:24 PM 3 replies 500+ views
Original Post
u235
u235
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) * x v = (1 / height) * y And 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 = 0 Which are all correct values, so I was wondering if anyone had any suggesstions or ideas as to what might be going on. Thanks. -AJ
V/R,-AJThere are 10 kinds of people in the world: Those who understand binary and those who don't...
Moe
Moe
Just to double check, where are the vertices for the terrain? Is the center of the terrain at the terrain's origin?
don
don
Are width and height floats?

If they aren't, you'll be performing an integer divide and the result will most likely be zero.



u235
u235
Quote:
Original post by Moe
Just 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 don
Are 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
V/R,-AJThere are 10 kinds of people in the world: Those who understand binary and those who don't...
don
don
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.