hi, I've got this problem when I'm loading mesh files,
I load vertex data from a file which is then put into a vertex array and drawn with glDrawArrays(), my problem is that when I was drawing in immediate mode I could easily switch textures in the middle of drawing the scene, the result was each face had a different texture, now with vertex arrays all the faces are drawn at once and I can't change the texture while this is happening, I end up with a mesh covered in a single texture. How can I achieve the same effect I had in immediate mode but with vertex arrays and without drawing each triangle separately?
I know I can do this using one really big texture but i'd rather do it with multiple textures.
Thanks in advance
multiple textures on one mesh
Never done multi-texturing without shaders. So maybe its time to mesh with shaders? Its not that hard to pick up.
Or you could change your data containers, for this I normally have a Model which can have multiple meshes which form the entire model but every mesh holds its own material with a texture etc. This way you can push the array's in like you normally would and bind the texture for that current mesh. The best example of this is within the OBJ file format, it has groups which have a unique material if you want them too. This way you have the same data structure like I just explained, a model with meshes with each mesh having its own material.
You understand it correctly, you can't switch textures while drawing this way (generally it is bad idea to change gl stuff in drawing state). You changed it between triangle drawing states which is correct but vertex array method is much more batch render so you wont be able to do it.
I am not sure if there is any solution for fixed pipeline but for shaders you can simply add another attribute array which will represent texture unit for your vertex.
Correct me if I am wrong but using fixed pipelines you have only two options:
- you will be forced to use texture atlases as you already write
- you will divide your mesh
I am not sure if there is any solution for fixed pipeline but for shaders you can simply add another attribute array which will represent texture unit for your vertex.
Correct me if I am wrong but using fixed pipelines you have only two options:
- you will be forced to use texture atlases as you already write
- you will divide your mesh
You understand it correctly, you can't switch textures while drawing this way (generally it is bad idea to change gl stuff in drawing state). You changed it between triangle drawing states which is correct but vertex array method is much more batch render so you wont be able to do it.
I am not sure if there is any solution for fixed pipeline but for shaders you can simply add another attribute array which will represent texture unit for your vertex.
Correct me if I am wrong but using fixed pipelines you have only two options:
- you will be forced to use texture atlases as you already write
- you will divide your mesh
can I use 3d textures and give each texture a different z coordinate
[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]Ha good idea.
Well this should work if you set glTexCoord3f() where z coordinate ( layer of 3D texture ) will represent your texture
You should determine z like this:
[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]
But don't forget to enable GL_TEXTURE3D
[/font][/font][/font][/font][/font][/font][/font]
Well this should work if you set glTexCoord3f() where z coordinate ( layer of 3D texture ) will represent your texture
You should determine z like this:
//desiredTexture is indexed from 0 to (numTextures-1) and represent index of texture unit
z = (0.5 + desiredTexture) / numTextures;
[/font][/font][/font][/font][/font][/font][/font][font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]
But don't forget to enable GL_TEXTURE3D
[/font][/font][/font][/font][/font][/font][/font]
[quote name='SaTANO' timestamp='1321750228' post='4885743']
You understand it correctly, you can't switch textures while drawing this way (generally it is bad idea to change gl stuff in drawing state). You changed it between triangle drawing states which is correct but vertex array method is much more batch render so you wont be able to do it.
I am not sure if there is any solution for fixed pipeline but for shaders you can simply add another attribute array which will represent texture unit for your vertex.
Correct me if I am wrong but using fixed pipelines you have only two options:
- you will be forced to use texture atlases as you already write
- you will divide your mesh
can I use 3d textures and give each texture a different z coordinate
[/quote]
You could but it is better to use GL_TEXTURE_2D_ARRAY which I think is available in GL 3.3
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement