MultiTexturing + VBO?

Started by
1 comment, last by V-man 14 years, 11 months ago
Hey guys, Assuming i got a vbo that contains an entire terrain, and i want each of the triangles to have a different texture + that it will combine together. how can I do it? do I have to make a vbo for each triangle? Thanks in advance
Advertisement
You could use a texture atlas, multiple sets of texture coordinates and some blend values to combine the textures in a shader.
So, if you want to combine up to 3 textures per triangle (one for each corner) you would need:
1. The texture atlas (all of your terrain textures packed into one big textures)
2. 3 texture coordinates per vertex (for the 3 textures)
3. 3 blend values (you could pack those into a vertex attribute or you could use per vertex colors)
4. A fragment shader that samples the 3 textures and blends them together using the blend values

(you may also achive that through texture combiners but that is most likely more complicated than to use a shader)
http://www.opengl.org/wiki/Multitexture_with_GLSL
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement