Another heightmap engine-texture problem

Started by
4 comments, last by klutch 22 years ago
Hey. I''m working on a heightmap engine. So far what it does is loads the terrain data from a 64x64 greyscale bitmap file, just like any other heightmap engine. But when I render it, I bind the texture with glBindTexture(), then I map that texture to every individual triangle strip I make with glTexCoord2f(). This applys the entire texture to every little polygon that is made. What I''m wanting to do, is load the terrain data from a 64x64 image, like I''m doing, then texture the entire thing using a 256x256 or maybe even 512x512 texture image. I''m kinda new to OpenGL, so I''m not sure if there is a different texturing method I can use that does what I want. Is there one? Or am I going to have to find some algorithm that splits up the texture image and peices it back together on the matrice? I''d appreciate any help. PS: Here is a shot of my engine for clarity.
Advertisement
anyone atleast know where I can get some source code to look at?
You need to normalize the coordinates of the four corners of the quad you want to put the texture on so they are all between 0 and 1. Then use these as your texture coordinates. Look at NeHe''s Tutorial #6 on texture-mapping (nehe.gamedev.net)
On NeHe''s tutorial it takes one texture and puts it on each of the 6 sides. I want one big texture over the whole thing.
what you want to do is determine the number of steps between the edges of your height map (i.e if the map is 256x256 pixels, this would be 256).

then, when you are building your terrain, have the for loops assign texture coords of n/256, where n is the number of the vertex in the map (so for vertex {128, 32} it would calculate that the tex coord at that position to be {0.5, 0.25}.

by dividing each coord by the total number of steps, you''ll clamp the coords to 0-1.0.

if you need more help, let me know.

Yours might be bigger. Yours might be harder. BUT, mine is multi textured, bump-mapped, pixel shaded & fully user customizable!
Thank you, I was wondering this also. I had tried that exact same thing before, it hadnt worked and i had put it away. Looked at again cause of this post, i wasting casting the text coord as a float. lol, it was always either 0 or 1.

Thank you also.
something...

This topic is closed to new replies.

Advertisement