Sign in to follow this  

About efficient rendering of X meshes

This topic is 2566 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
Use
D3DXWeldVertices

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
D3DXSimplifyMesh
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,

<code>
HRESULT hr=0;

ID3DXMesh* pMesh=0;//source mesh
ID3DXPMesh* ppMesh=0;//progressive mesh
ID3DXBuffer* adjBuffer=0;
ID3DXBuffer* mtrlBuffer=0;
DWORD numMtrls=0;
//variables
//load mesh
hr=D3DXLoadMeshFromX(
"bigship.x",
D3DXMESH_MANAGED,
Device,
&adjBuffer,
&mtrlBuffer,
0,
&numMtrls,
&pMesh);

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

//then create progressive mesh

hr=D3DXGeneratePMesh(
pMesh,
(DWORD*)adjBuffer->GetBufferPointer(),
0,
0,
1,
D3DXMESHSIMP_FACE,
&ppMesh);
//you can know this method more at MSDN
if(FAILED(hr)){
//an error occurs
}
/*
then you can use following methods to set the property of the mesh:
DWORD GetMaxFaces(VOID)
DWORD GetMaxVertices(VOID)
DWORD GetMinFaces(VOID)
DWORD GetMinVertices(VOID)
DWORD GetNumFaces(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:
ppMesh->SetNumFaces(30);

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.
ppMesh->SetNumFaces(ppMesh->GetNumFaces()-50);

</code>

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
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

This topic is 2566 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.

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