Well, the case is that I have a vbo that contains vertices which forms my terrain. But I can not figure out how I am supposed to use multiple textures in that terrain. The way I do it now, is binding a texture right before I draw my vbo. Any hints, snippets or example on how to approach this manner would be lovely.
Also a link to a tutorial on this manner would be lovely ;)
But an example is just as fine.
A quick google to the rescue :)
http://www.opengl.org/wiki/VBO#Sample_Code
Main part you're interested in:
glVertexPointer(3, GL_FLOAT, 64, BUFFER_OFFSET(0));
glNormalPointer(GL_FLOAT, 64, BUFFER_OFFSET(12));
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, 64, BUFFER_OFFSET(24));
glClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(2, GL_FLOAT, 64, BUFFER_OFFSET(32));
glClientActiveTexture(GL_TEXTURE2);
glTexCoordPointer(2, GL_FLOAT, 64, BUFFER_OFFSET(40));
Kind regards,
Mike
Thanks, I can't believe I didn't stumble upon that when searching. I need to improve my google skills.
Mind explaining me shortly what GL_TEXTURE(X) is, (Of course the obvious part is still obvious, but what is thoose constants doing there :p), also how do I assign one of my textures to thoose constants?
The GL_TEXTURE_X stuff is part of multitexturing. You assign them like so:
glActiveTexture(GL_TEXTURE_0);
glBindTexture(firstTextureId);
...
glActiveTexture(GL_TEXTURE_1)
glBindTexture(secondTextureId);
...etc...
Thank you, this is truly a great discovery for me. I was about to create a texture atlas, but this works aswell ;)
It sounds a bit to me like you want to draw different textures on different "tiles" of your terrain, not render multiple textures to a single polygon in one pass. In that case, a texture atlas is in fact what you're looking for, not multitexturing.
Indeed, if you don't have a texture atlas, start there :) If the atlas gets too big (bigger then 1024*1024 or so if you want to support old graphics cards) you will want both the atlas and multi texturing.
Always start with the atlas if possible :)
Mike
Well, I finished atlas, and played with multiple textures.
But now I am stuck with the blending textures part.
I did learn some basic shading language. But I got no idea on how to tell the shader what tile is next to the currently processed one. So I have no means of knowing what texture to blend the currently processed one with.
Is there any easier way to blend the textures into each other? I am rendering a huge vbo as I told you earlier.
I know I could play with the texture coordinates while buffering my vbo, but again I don't know how to blend thoose textures then.
If you didn't understand what I exactly ment with that, I basically want to overlap two textures to create some kind of transition.
You're talking about texture splatting.
Google can help out some but there was also a discussion about it on lwjgl a while back:
http://lwjgl.org/forum/index.php?topic=2933.0
All in all, it's quite complicated to get precisely right and will require you to either draw the vbo several times or use shaders.
Mike