Sign in to follow this  
cppcdr

Optimising rendering

Recommended Posts

cppcdr    168
I was wondering if it is possible to have a set of indices that selects the normals to render Right now, I am trying to draw a cube, but the cube looks wierd because my vertex normals are at 45 degrees to the face. That is because my normals are calculated using the face normals (i add the face normals form the faces that are touching the vertex and I devide by the number of faces touching the vertex). I want to be able to use 8 verts to represent the cube while using 24 normals (4 for each side of the cube). So the same vertex is used many times (with the index buffers) and each time it is used, it has a diffrent normal... Is this possible?

Share this post


Link to post
Share on other sites
hplus0603    11356
No, you cannot use a separate index for normals than from vertices. You have to normalize the array by splitting out every unique combination of vertex+normal+texturecoord+color (plus whatever other vertex attributes you're using).

I wrote an article a while back that explains how to do it.

Share this post


Link to post
Share on other sites
cppcdr    168
So basically, what you are saying is that I should have 24 verts for rendering the cube (in this case) because I have 24 diffrent normals.

And in some other cases, I could have less because I use the same normal data?

EDIT :
How does Milkshape do it? It can render a cube with the proper normals while only having 8 verts.

[Edited by - cppcdr on May 20, 2006 11:25:52 AM]

Share this post


Link to post
Share on other sites
thezbuffer    706
You are only seeing 8 verts in the editor, but by the time milkshape renders the cube its translated that into 24 verts with the correct vertex normals.

Share this post


Link to post
Share on other sites
hplus0603    11356
Re-read the article I pointed you at.

There are many possible ways of representing the same geometry. The graphics hardware, however, needs a normalized vertex array that uses a single index, because that's how it works, if you're using indexed primitives.

Internally, I would guess that the modelers just index their various arrays and generate one big non-indexed list of vertices. Thus, they'd use DrawPrimitives(), rather than DrawIndexedPrimitives(), to render.

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