Archived

This topic is now archived and is closed to further replies.

Erzengeldeslichtes

Why does my box have 24 vertices?

Recommended Posts

I built a single box in 3d studio max (after noticing a large number on a more complex object) such that is has 8 vertices. I convert it to a .x, asking it to use text based so I can read it. Says it has 8 vertices in it, 1 texture/material, 12 faces, 24 face normals, etc. Now I use an ID3DXMesh object, and call GetNumVertices(); (so I can loop through them to find the min/max vertices on each direction). It returns 24. That's alot of vertices for a box. Edit: My "also" had forgotten that I'm working in hexidecimal... [edited by - Erzengeldeslichtes on October 7, 2003 2:03:30 AM]

Share this post


Link to post
Share on other sites
DirectX has to split out the "position verts" into fully "normalized verts" to submit it to the hardware.

This means that every unique combination of (position,normal,texturecoordinate,color,anythingelse) needs to be one hardware vert; this is because hardware can only (efficiently) index a single index for all the different kinds of data for a single vert. Someone tried making hardware that could look up normal, position, etc from different arrays using different indices, but it ran slower. Shuffling all those extra indices around takes bandwidth, too!

For a box, you get pretty much the largest possible expansion, because each of your 8 position verts has 3 separate normals, so each vert gets split into 3.

For a soft skin mesh, you''ll typically only see splitting along material/texture boundaries, so with good artists, the expansion from Max verts to rendering verts will be < 10%. Also, the higher poly the model, the fewer verts are affected by splitting (in general).

Share this post


Link to post
Share on other sites
Yes, it is possible to create a box from 8 vertices. Just define the vertices and render an indexed primitive with them. But then you will have problems with lighting and texturing. Try to understand how texturing and lighting works in D3D using the data stored with vertices (normals and UV coordinates)!! For the 6 sides of the box it is better to use separated vertices (6*4=24), which can have the same xyz coordinates, but different normals and UV coordinates.

Share this post


Link to post
Share on other sites