PDA

View Full Version : Multiple textures and meshes



SaLiVa
03-08-2011, 04:41 PM
Hi,

I've implemented a Wavefront object loader for my Opengl 4.1 context program. I use Vertex Buffer Objects and Vertex Arrays for the multiple meshes. It works perfectly with the vertex, normal, tangent and texture coordinates information sent to the GPU.

In order to map textures to these multiple meshes I had a choice of using texture atlases or 2D texture arrays. I opted for 2D texture arrays since my textures were never going to differ in size. So I added another vertex attribute to each vertex in each mesh corresponding to the layer number in the array.

This implementation works. However since I also have a normal map and perhaps an additional light map implementation later on, I was wondering if there was a better way to choose the layer to use than to use glVertexAttribPointer for each vertex. Uniforms as far as I know would not work in this situation. I also tried using glVertexAttrib with little success (probably not using it right - and would still be per vertex).

Any advice would be appreciated.

SaLiVa
03-09-2011, 02:23 AM
Okay,
After some further research I have come to the conclusion that passing the layer as a third integer "r" coordinate is the way to go. Apparently it's set in the specification and looking at nvidia's sample program it's the way to go.

However, if someone does know of a way to pass information in a per-mesh basis, please let me know. =)