Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Binding textures

This topic is 6062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''m having problems understanding how to throw multiple textures in a scene. Uhh, that probably sounds wrong. Well what I''m trying to do is to put different textures depending on the height of a vertex. Yes, it is a terrain engine I''m working on. To give you a brief example; mountains with snow on the top, grass on the ground. So I would need three different textures: snow, rock and grass. I know how to load textures and how to glue them on triangles, but what I don''t understand is how to bind different textures on the terrain since it is basically just a one big mesh. If I''m not making any sense, kick me in the ass! Thank ye fer yer time. saeZ

Share this post

Link to post
Share on other sites
Thanks Null and Void!
That question was so stupid of me. I realized what I needed to do right after your
response. I had to do some re-writing; added vector, triangle, vertex and face classes. Can you
believe it: I didn''t have any of those before! What the hell was I thinking... I wasn''t
thinking I guess. Well, now things work almost the way I wanted: there''s snow on the
mountain peaks. But what I need to do next is to blend the textures together somehow..
umm..blur the edges or something. The edges of the textures look very icky. Plus the
framerate dropped dramatically! Previously it was about 130-160 and now it''s 40-60, and
I''m even using display lists! Ackh! I see I still have tons to learn about these

Could someone point me to some good tutorials on OpenGL texturing? Octree/quadtree/what
ever tree things would also be nice, so that I could limit the amount of faces to render
to what one can actually see on the screen. Right now I''m just rendering the whole damn
terrain every frame. What a waste of speed.. tee hee. And what are these vertexarrays
I have heard about? Damn, information overload. My head explodes!


Share this post

Link to post
Share on other sites
One technique for blending all the textures together is to make one big texture out of the small ones. Your terainmust be heightmap bassed though... You define a scale 0-256 assuming your heightmap is indexed color. 0 being darkest 256 being lghtest.

So lets say you define your scale that all pixel on the heightmap between 0 (black) to 10 (drak gray) use the dirt texture for 11 to 20 use grass texture.

You go pixel by pixel on the hight map you get it''s color value so if pixel 0,0 is black you take the dirt texture, then you test the surounding pixels. The surounding pixels are 15 so you would blend a bit of the gras texure onto your dirt texture and keep going.... Of course you dont directly modify the dirt, grass, snow etc.. texture directly you blend them in memmory somehow using an algorithim them you save the processed block. Once you have the whole height map done you store the data to file and you have the new texture. The good thign aboutthis is that the texture will match perfectly the terrain because you generated from the height map...

I personally have never done this before, but what I have blurted out sounds about right....

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!