Jump to content
  • Advertisement
Sign in to follow this  
tenpoundbear

Index Buffer & normals

This topic is 3011 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys,

I am trying to optimize my code a bit with vertex buffer and index buffer.

What do you do when you have a shared vertex but it is suppose to have different normals?

This is rendered without index buffer.
But to clarify my problem... the north vertex and the vertex at the cube edges shares the same vertex, but they have different normals.


How can I achieve this when using vertex buffer and index buffer... because the vertex buffer can't have duplicate vertices.

Thanks guys

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by tenpoundbear
because the vertex buffer can't have duplicate vertices.


Why not? That's usually how this problem is handled.

Share this post


Link to post
Share on other sites
Unless things have changed radically in DX 10/11, you can only have one index buffer active at any given time, and all vertex buffer streams must be indexed using that buffer.

This means that (e.g.) if you have multiple vertices that share a position but have different normals, you'll just need to create multiple copies of the vertex (one for each unique normal).

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP
Quote:
Original post by tenpoundbear
because the vertex buffer can't have duplicate vertices.


Why not? That's usually how this problem is handled.


Hmmm... from the texts I've read and tutorials I looked at on the net, its says you don't.

I guess the commonly used example is the cube...

3 * 2 * 6 = 36 vertices (3 vertex/per triangle, 2 triangle/per face, 6 faces)

The purpose of VB & IB is so that the duplicate vertices are removed, hence only 8 vertex needed for VB. And using IB, all the faces can be indexed just from the 8 vertex alone. Faster, more efficient rendering.

This is how I understand it anyways... let me know if I am wrong.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
This means that (e.g.) if you have multiple vertices that share a position but have different normals, you'll just need to create multiple copies of the vertex (one for each unique normal).


Hmmm... this sounds more trouble then it is worth.

Using my image in the OP as example, the top 4 faces will have shared vertices... hence you are suggesting I create another 4 vertex buffer to accommodate the normals?

Sorry I don't exactly know what you mean :)

Share this post


Link to post
Share on other sites
Quote:
Original post by tenpoundbear
Using my image in the OP as example, the top 4 faces will have shared vertices... hence you are suggesting I create another 4 vertex buffer to accommodate the normals?
(Assuming you mean "create another 4 vertices"), yes. A vertex is not a position, a vertex is a position, normal, texture coordinate, diffuse colour and anything else you need to describe one vertex.
If you have two positions that are the same but with two different normals, then they are two discreet vertices.

Likewise if you have two vertices, one with a position (0, 0, 0) and with a colour of RGB(1, 0, 0) and one with a position of (123, 456, 678) and a colour of RGB(1, 0, 0) they're discreet vertices, even though they share one component.

Modelling packages generally define a vertex as a position with no other attributes, that is not the case in DirectX or OpenGL.

Share this post


Link to post
Share on other sites
I see.. I understand now :)

I just assume.. if same position then same vertex. But as you pointed out, there are other properties too that determine this.

Thanks :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!