vertex associated with several texture coordinates?

Hello guys,

I (too :wink:) intend to design an easy-to-extend (for Python programmers) minecraft clone.
But the blocks should be smaller and are used for terraforming only, objects and actors shall be rather smooth. Maybe I will open a thread to describe my project, in another sub-forum. If someone wants to join, he/she is very welcome.
Basis for my first approach was the ā€œProcedural-Cubeā€ example, of course. The pycraft prototype
(http://www.youtube.com/watch?v=qg4gMMDaJM8)
was then used to check, why my approach was so slow. Now, the engine is quick enough that I am certain it makes sense to go on.

For my question:
For optimization, I would like to reduce the number of vertices I send to the pipe. I thought about using Tristrips instead of Triangles.

http://imageshack.us/f/210/pandacube.png/

The problem: vertices can be used for several triangles (using Tristrips), but their texture-coordinates are linked to the vertices as defined in the GeomVertexData.

Now in PyCraft, the texture coordinates of one (vertex) coordinate may differ for adjacent triangles, for example if a dirt cube face touches a stone cube face. In the picture you see vertex 2 and 3 that belong to two faces, a red and a green one. The left triangle holds tex-coords of the texture imageā€™s right side, the right triangle tex-coords of the imageā€™s left side.

The texture-coordinates should have been saved in the triangle instead of the vertex, so they could be set explicitely for the adjacent triangles, without touching the vertices again.

Can anyone propose a way to assign one texture coordinate for one Tristrip triangle and set another texture coordinate for the adjacent triangle? Or a similar solution to reuse vertices?

Many thanks for your ideas!

Michael

Hey, as far as I know thereā€™s no way to do what you want in Panda3D or in OpenGL itself. I might be wrong though. But you could try and send only those cube faces as triangle strips, which share same texture coordinates. However, that would require additional logic when generating chunks and that might affect the performance. Youā€™d save calls on GPU, but use more CPU. So see whatā€™s best in your case and go with that.

Taez, thanks for your reply.

You are right. I am afraid there will be way too much logic needed to determine the rare cases where this is possible. Even adjacent faces of the same type (f.i. dirt) in one plane cannot reuse vertices, as the texture should repeat itself.

At least I could use a tristrip to create a 2-triangle-face (quad) instead of two triangles, but Iā€™m not sure whether it pays since I donā€™t save vertices, only a shape.

Kind regards,
Michael

You should duplicate each vertex for each triangle, and this will be possible. This is a common thing to do, actually, with not a lot of loss in rendering performance.

Tristrips used to be much more efficient than triangles, but with the advent of VBOs and IBOs, the difference isnā€™t that much anymore. Are you noticing much of a performance improvement when using tristrips instead of triangles?