Jump to content
  • Advertisement
Sign in to follow this  

About efficient rendering of X meshes

This topic is 2782 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

Hi all,

I just built a scene with individual lego bricks,

each lego brick had about 500 polygons and
totally I had about 589 000 polyygons in my scene

Just used 2 directional lights , one at the top of the scene one at the bottom of the scene , for debug purposes turned Vsync off

There was no specific culling ( no bsp , no occlusion culling , no frustum culling , not even backface culling )

The FPS I got was 20 .

Later in my mesh class , when I called :
m_mesh->OptimizeInplace( D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE, (DWORD*)adjacencyBuffer->GetBufferPointer(), NULL, NULL, NULL );

The FPS became 70 !!

Just want to ask you , what else could be done to improve the X rendering performance except the culling methods ?

many thanks

Share this post

Link to post
Share on other sites

Weldvertices will merge vertices that are very close together so you can reduce your poly count. You define how close they are in the

const D3DXWeldEpsilons *pEpsilons

Try low settings, like

epsilons.Normal = 0.001f;
epsilons.Position = 0.1f;
But, make sure to set the struct to zero first, otherwise you will have problems. The settings are all model dependent so play with them to get it right.

Also, you can use
to reduce the poly count further and create different levels of detail for different distances

Its sad that Microsoft took most of these functions out. They really didnt need to.

Share this post

Link to post
Share on other sites
There are two techniques that widely used today:LOD(level of Detail)and progressive mesh.
I got progreesive mesh technique in my engine,which is based on ECT(Edge Collapse Transformations),every time ECT runs and it removes a point and two surfaces.
You can use D3DXGeneratePMesh() to create a progressive mesh,


ID3DXMesh* pMesh=0;//source mesh
ID3DXPMesh* ppMesh=0;//progressive mesh
ID3DXBuffer* adjBuffer=0;
ID3DXBuffer* mtrlBuffer=0;
DWORD numMtrls=0;
//load mesh

//load textures,materials of the mesh...,etc.

//then create progressive mesh

//you can know this method more at MSDN
//an error occurs
then you can use following methods to set the property of the mesh:
DWORD GetMaxVertices(VOID)
DWORD GetMinVertices(VOID)
HRESULT SetNumFaces(DWORD Faces)
this method enables us to set the number of the faces of the mesh,for example,if the mesh has 50 faces,we want it to be 30,then we can write:

the less faces you set,the quicker the mesh can be rendered

please notice that it you set a number that is less than GetMinFaces(),it will be GetMinFaces().If you set a number that is more than GetMaxFaces(),it will be GetMaxFaces()

//In my program,I made the mesh faces fewer.


you can look for more information about progressive mesh by google,even in the SDK samples.
hope this helps

Share this post

Link to post
Share on other sites
PS:it worked well in my engine,and one more thing that I suggest you is that you can Set less faces for the objects far away,and set more faces for the objects near.

Share this post

Link to post
Share on other sites
Progressive meshes are a deprecated solution.

* They do not work well with tangent space normal mapping.
* They need an uninstanciate index buffer for each instance.
* On current hardware, remove two triangle do not affect performance, you have to remove them by batch of a thousand at least. It means that the granularity of the progressive mesh algorithm is over needed and you lost too much Cpu power
* They are less friendly with the gpu pre and post transform cache

It is far better to use some static L.o.ds, they can be proceseed offline to be friendly optimise for Gpus.

The progressive mesh algorithm can be used to create the L.o.ds if you do not have enought graphist on your project.

And last, with static L.o.ds you can simplify the material too!

Share this post

Link to post
Share on other sites
You should also look into instancing to make your scene run faster.


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!