Jump to content
  • Advertisement
Sign in to follow this  
gatofedorento

Change textures during VBO draw

This topic is 2533 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

Hello, I'm implementing terrain multi-texturing using channels from textures, I have a terrain using a base texture, a texture to interpolate and a third texture using its red channel to interpolate between the two other textures in GLSL.

My terrain is a mesh of triangles, and each two triangles (a square) have a different texture with a different red channel for interpolation, my problem is how to change between each red channel texture during a call to glDrawElements.

I tried to use ARRAY_2D_TEXTURES, but that wasn't solving my problem, because my triangles have shared vertexes, and to use ARRAY_2D_TEXTURES I would need each triangle to have its own texture coordinates, with a third coordinate specifying the texture index in the ARRAY_2D_TEXTURES, and that would use more memory that the terrain I made.

Another way to solve this problem would be using different calls to glDrawElements between each square, and between each call I could change the textures, but that would become less efficient, due to the extra calls to glDrawElements.

A third solution would have an atlas texture of red channel textures, and each zone of my terrain would have part of the atlas texture.

Is there another way to solve my problem changing between the red channel textures with just one call to the draw functions?

Share this post


Link to post
Share on other sites
Advertisement
Have multiple textures selected into multiple texture units and use an extra attribute on the vertices to pick which texture you sample from in the GLSL?

Generally, when people do this, the texture which controls the blending between the base and the overlay textures is much lower frequency than the actual ground textures, so the ground can easily be drawn in larger blocks without such texture switches.

Share this post


Link to post
Share on other sites

Have multiple textures selected into multiple texture units and use an extra attribute on the vertices to pick which texture you sample from in the GLSL?


Can you give an example? Ithink you mean adding more information in my data so I can apply some kind of logic in my shader to help.


Generally, when people do this, the texture which controls the blending between the base and the overlay textures is much lower frequency than the actual ground textures, so the ground can easily be drawn in larger blocks without such texture switches.


you mean lower resolution texture for blending? Sure, by doing this I can make my terrain use less GPU RAM

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!