• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
pressgreen

Index Buffer help

4 posts in this topic

So I am still having problems understanding the index buffer completely. There are a few thing related I need cleared up. Such as, how is an index buffer informed. I mean does like 3dsMax or blender generate the index buffer when you export your geometry? Is this index related to the face count and face setup of your geometry. like is the face index and the index buffer the same thing or equal I mean? the reason I ask is because I am trying to cook a mesh with PhysX and Reading on this subject it says this:

  • "Do not duplicate identical vertices. If two triangles are sharing a vertex, this vertex should only occur once in the vertex list, and both triangles should index it in the index list. If you create two copies of the vertex, the collision detection code won't know that it is actually the same vertex, which leads to decreased performance and unreliable results."

After reading this I realize that I need to nail down my understanding of indexing triangles. If any one would help explain any of my questions I would be internally grateful. thanks

0

Share this post


Link to post
Share on other sites

Suppose you have a 2D rectangle of size [2, 2].

These are the vertices it uses:

[-1, -1]

[-1, 1]

[1, 1]

[1, -1]

 

While we only need four vertices to represent this rectangle, the graphics cards wants triangles, each one having three vertices.

So if we were to split the above rectangle into triangles, we would need to send six coordinates instead of four.

 

Another way to do this, is send only those four vertices, but together with them also tell the graphics card how to form triangles from them.

This is where the index (element in OpenGL) buffer comes in.

The element buffer has numbers that index your vertices.

E.g. 0 would be the first vertex, 1 the second, and so on.

So with an element buffer, to form the triangles needed for the rectangle, we need to send these indices: [0, 1, 2, 0, 2, 3]. If you replace the numbers with the actual vertices they index, you will see you get the original six vertices to form the triangles.

 

Indexing reduces memory and bandwidth (except for very uncommon worst case scenarios), which in turn help rendering speed.

 

Most file formats (to which you export from Blender, 3ds Max, etc.) support indexing, but there are two variants of indexing for file formats.

In modeling tools (and in fact, in your OpenGL code too!), a "vertex" isn't a position, it's a combination of a position, a normal vector, a color, a texture coordinate, and so on.

Every one of these things is called a vertex attribute, and is only one part of the whole vertex.

OpenGL (and Direct3D) only allow 1D indexing, or in other words - you have one index that points to all the vertex attributes.

 

For example, if you have an array of vertex positions and another array of vertex normals, then index 0 would be the first position and the first normal.

 

This might seem obvious, but some file formats don't actually store their data this way.

In most cases, a model doesn't actually need the same amount of positions, normals, and so on.

If there are many vertices that have the same normal, the file might store only one normal, and let them all share it.

You then have different indices for each vertex attribute, which you can't directly use for rendering.

In this case, you will have to "flatten" the arrays and fill them up with all the shared data.

 

This can be seen in the completely obsolete, bad format *.OBJ (it's the most terrible format in existence, but for some reason it's used everywhere).

Edited by Chananya Freiman
1

Share this post


Link to post
Share on other sites

so with what your saying. say i have a number of vertices and then an index that has been generated properly for efficiency. even though i might not use all the vertices i still include all of them in the VBO?  because with the Index buffer many of those verts will be passed up right because there will be another being used in its place right?

0

Share this post


Link to post
Share on other sites

You will use all the vertices.

 

The idea is that you don't use the vertices to describe your mesh.

You use indices to describe your mesh.

 

At the end, to actually render a rectangle, you have to give OpenGL two triangles, which are six vertices. So you can either give OpenGL the six vertices up front, or you can give it the four vertices that actually define the rectangle, and tell GL "I gave you four vertices, I want you to make two triangles out of them like this index buffer tells you".

 

When using indices, GL simply grabs the vertices from your vertex buffer. Your first value in the index buffer is 0? ok, let's grab the first value in the vertex buffer. The second value is 1? grab the second value in the vertex buffer. 2? grab the third. Now we grabbed three vertices, which form the first triangle.

Then it continues with indices 0, 2 and 3. Note that we reused two vertices - 0, and 2. Even though we sent them only once, we actually used them twice.

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0