Optimising rendering

Started by
4 comments, last by hplus0603 17 years, 11 months ago
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?
Advertisement
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.
enum Bool { True, False, FileNotFound };
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]
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.
ZMan
I checked the model that I exported in ASCII format and it has 8 vertices...
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.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement