Terrain Texturing

Started by
9 comments, last by rollinr33 22 years, 2 months ago
Hello, I am having some trouble texturing my terrain, is there any way i can stretch a bmp over the whole terrain? I have been messing around with opengl for a little bit, and with this particular problem and i have not had any luck. If anyone could point me to some resources on this topic i would appreciate it or if they have any ideas i would appreciate that too, thanks and later- what we do in life... echoes in eternity...
Advertisement
Ok, stay with me on this one, I''ll try to explain it:

While you''re rendering the terrain vertices, to get the current texture coordinate get the current vertex''s ''x'' number (in the row), and divide it by the max number of vertices per row... That will get you the ''s'' (''x'') texture coordinate, do the same thing, for the ''t'' (''y'') coordinate.

Hopefully I did a decent enough job explaining this...

Trent (ShiningKnight)
THE Engine
ShiningKnight7@hotmail.com
Unfortunately, that has the side effect of mapping a small amount of texture onto a large polygon for steep gradients.
If at first you don't succeed, redefine success.
thanks, i understand ya, but as to the side effect? What do you mean, do you mean the texture map not looking good? (i havent tried it yet) and if so do you have any other suggestions? later-
-forget it i see what you mean about the side effect. my terrain tiles are just big ugly blocks, i am gonna try and mess with it some more thanks guys

what we do in life... echoes in eternity...


Edited by - rollinr33 on February 22, 2002 4:17:39 PM
I''ll draw a diagram to show what i mean in the morning. I''ve just got back from the pub, so I''m not in the mood at the moment...
If at first you don't succeed, redefine success.
the problem that python is describing is that while the polygon won''t be very wide or deep, it will end up having being really tall if the height difference between connecting vertices is great. This results in a abnormally large polygon. If you just use the normal texture mapping technique, the texture on that polygon will end up looking strechted because while the percentage of the texture remains the same as that used on all of the other polygons, this polygon is a lot bigger and thus needs more of the texture to look "normal."

To visually see what would happen, take the picture you use as your signature and enlarge it only vertically.

Hope this helps some.
Yeah i think i understand what you are guys are saying, and i dont blame you for not wanting to draw a diagram, the pub can get you sometimes. Anyway, is there a way to correct this side effect? I have the texture coordinates implemented just like shining knight suggested(i should of been able to figure that one out). And i am generating the texture based on the height, little article over at flipcode helped me out there, I am just having problems with getting the texture genrator to work right. But anyway, thanks guys later-



what we do in life... echoes in eternity...
quote:Original post by ShiningKnight
Ok, stay with me on this one, I'll try to explain it:

While you're rendering the terrain vertices, to get the current texture coordinate get the current vertex's 'x' number (in the row), and divide it by the max number of vertices per row... That will get you the 's' ('x') texture coordinate, do the same thing, for the 't' ('y') coordinate.

Hopefully I did a decent enough job explaining this...



Thanks! I did't know that and i was wondering how to figure it out....

As for the distortion effect. This can be fixed by making the bitmap larger than the terrain... ( i think? )

Edited by - Spikeles on February 22, 2002 8:34:55 PM
Spikeless, that could reduce the effect slightly, but will not eliminate it. Here are a couple of diagrams that should explain this easier...



Here you can see what you are doing at the moment. You can see that on the steep gradients, when there is a large variation between adjecent vertices, a small amount of texture is mapped onto a large area polygon. This has the effect of stretching the texture alot.



With this one however, it maps the texture not based on the x distance into the terrain, but the actual distance on the terrain travelled. You can see, that this eliminates the stretching, and will look better. So based upon the terrains variation you map a different amount of texture onto it.

The second method is alot harder to actually impliment though, and it will not look much better at all with flat-ish terrains.
If at first you don't succeed, redefine success.
Beware that on the first diagram the vertices are not equally spaced... But the effect would still be the same...

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.

This topic is closed to new replies.

Advertisement