LWJGL
May 22, 2012, 16:24:40 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: VBO's multiple textures, huh?  (Read 942 times)
Meanz
Newbie
*
Posts: 38


« on: September 26, 2011, 07:29:22 »

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 Wink
But an example is just as fine.
Logged
Mickelukas
Talks Too Much
***
Posts: 152


WWW
« Reply #1 on: September 26, 2011, 08:05:00 »

A quick google to the rescue Smiley

http://www.opengl.org/wiki/VBO#Sample_Code

Main part you're interested in:
Code:
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
Logged

Meanz
Newbie
*
Posts: 38


« Reply #2 on: September 26, 2011, 08:34:00 »

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?
Logged
Chuck
Newbie
*
Posts: 42


aka sproingie on freenode


« Reply #3 on: September 26, 2011, 08:55:45 »

The GL_TEXTURE_X stuff is part of multitexturing.  You assign them like so:

Code:
glActiveTexture(GL_TEXTURE_0);
glBindTexture(firstTextureId);
...
glActiveTexture(GL_TEXTURE_1)
glBindTexture(secondTextureId);
...etc...

Logged
Meanz
Newbie
*
Posts: 38


« Reply #4 on: September 26, 2011, 09:06:12 »

Thank you, this is truly a great discovery for me. I was about to create a texture atlas, but this works aswell Wink
Logged
Chuck
Newbie
*
Posts: 42


aka sproingie on freenode


« Reply #5 on: September 26, 2011, 15:47:32 »

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.
Logged
Mickelukas
Talks Too Much
***
Posts: 152


WWW
« Reply #6 on: September 26, 2011, 23:22:26 »

Indeed, if you don't have a texture atlas, start there Smiley 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 Smiley

Mike
Logged

Meanz
Newbie
*
Posts: 38


« Reply #7 on: September 27, 2011, 07:46:35 »

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.
Logged
Mickelukas
Talks Too Much
***
Posts: 152


WWW
« Reply #8 on: September 27, 2011, 08:36:47 »

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
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!