PDA

View Full Version : Applying textures in a fast manner?



posixoptions
05-03-2010, 03:38 AM
Part of my program loads and uses OBJ files, some of the objects are quite complex and I'd like to have a way in which I can apply textures in a fast way.

Storing the vertices, normals and texture coordinates in a VBO is fine, I already do that; however is there some way to also store the glBindTexture() directives?

I'd like to be able to just make ideally a single call as in with glDrawArrays() which would then not only use the VBO data for the vertices, normals and texture coordinates -- but also bind the appropriate texture as specified by some form of indices.

Is this even possible?

What is the correct manner of doing this, i.e. rendering a complex object with many different textures in a fast way?

I've looked at multitexture but that seems to be for applying several textures on the same face -- not what I'm looking for.

Nighthawk
05-03-2010, 05:54 AM
Use the same texture image set for all objects - either via "Texture Atlas" or "Texture Array".

posixoptions
05-03-2010, 06:57 AM
Use the same texture image set for all objects - either via "Texture Atlas" or "Texture Array".

Thanks, so you're saying that I basically should create some ad hoc bitmap based on all the textures in the associated MTL of the OBJ file, load that bitmap as a large texture and then modify texture coordinates to select the according and appropriate section of the large texture that corresponds to the original texture?

It does sound fast, but it also sounds like a bit of work to make this actually function properly for an arbitrary OBJ.

Ilian Dinev
05-03-2010, 08:00 AM
Do note that texture-array is completely different from texture-atlas. You understood what a texture-atlas is. A tex-array has 3 coordinates, the Z value is an integer that specifies which slice it should use. All slices (textures) in a tex-array have the same width and height, and can have mipmaps. Tex-arrays require OpenGL3.x-compatible hardware.

The easiest, most compatible and natural approach is to split the mesh into sub-meshes, each containing only polygons with the same texture. (If you use 11 textures, 11 sub-meshes will be created) . Why is this not an option for you?