Archived

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

nick316

Optimizing a Mesh

Recommended Posts

nick316    100
If I am rendering a mesh with draw subset will draw subset work any faster if i clone the mesh to be write only and call mesh->optimize() before rendering? Or will i only see a speed increase if i am rendering using draw primitive? Any comments welcome. Thanks, Nick

Share this post


Link to post
Share on other sites
thedo    124
Quote from Microsoft:

DrawSubset() draws all triangles of a given attribute
Needs Attribute Table
Else it does linear search per face
Efficient if attributes are sequential, starting from 0
Else it does search of attribute table
Uses Fixed Function FVF shader
Avoid unless all above conditions met.

As you can see if you optimize you can meet the aboveand get decent performace.

I think.....

Neil


WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
nick316    100
I think that is a yes to mesh->optimize().

The WRITE ONLY option would not allow access to the mesh
for other operations so that would be the downside.


---------------------------------------------
"Do unto others, whatever you think is funny"
---------------------------------------------

Share this post


Link to post
Share on other sites
EvilDecl81    360
Optimize will do all optimizations, including attribute sorting. However, the big (up to 200%) perf win is in the vertex cache optimization reordering.

OptimizeInPlace will reorder the index buffer, but not change the vertex buffer. If you create the mesh D3DXMESH_VB_WRITONLY flag, then you can still reorder the index buffer and keep your vertex buffer unchanged. There is little perf gain on current hardware for a writeonly index buffer, but if you create a mesh with one, you won''t be able to optimize after that.



Share this post


Link to post
Share on other sites
nick316    100
Hello EvilDecl81,

You bring up some good points. But in my case I had
to experiment a little bit with this stuff. Here is what i found.
The D3DXMESHOPT_VERTEXCACHE flag did not help me at all. Only
when I used the D3DXMESHOPT_ATTRSORT did i see a huge perf
increase. The solution to the write only mesh is to create it,
call optimize and then clone the mesh with the writeonly flag
specified.

hr = g_pMesh->CloneMeshFVF(
g_pMesh->GetOptions() | D3DXMESH_WRITEONLY,
g_pMesh->GetFVF(),g_pd3dDevice, &outMesh);

Share this post


Link to post
Share on other sites
thedo    124
In my experience Atrribute sorting produces the faster results as state changing is SLOW. Vertex cache optimisation should help too though....

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
nick316    100
Does this sound like a reasonable frame rate.
The card is a 32mb nvidia gforce 2 gts.
I am getting about 60fps for 30,000+ faces.
Not counting collision detection.
Any comments welcome.

Thanks,
Nick

Share this post


Link to post
Share on other sites
thedo    124
Not exactly great.

I have Duron 1Ghz, 32Mb Geforce2 MX, 512 MB RAM and win XP and consistantly get 3-4 million polys per sec in my prog.

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
nick316    100
I should have explained that more.

The 30,000+ faces is a golf hole. This golf hole demo has
full collisions on everything and multiple animated
meshes.

Share this post


Link to post
Share on other sites
thedo    124
check without collisions- I use D3DXMESH and get much greater results. If the speed goes massively up then you may want to rewrite your collision code. Obvioulsy I don''t know the specifics of your engine or your physics, but mine runs substantially quicker using similar rendering techniques.

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
nick316    100
There does not appear to be a significant speed inc when
taking out collisions.
I use LPD3DXMESH and this seems to work fine. The collisions
are done with the ray itercepting the object, picking which
face it hit and calculating the bounce from that. It looks good
and the bounces are right. The tree collisions aren''t bad either. thedo, have you ever experimented with shadows in your
engine?

Nick

Share this post


Link to post
Share on other sites
thedo    124
Not yet. My stuff is for a university final year project so may experiment if the time is available. However at the moment just getting every thing to work seamlessly is a pain. I want to look into shadow volumes and stencil bufers later though. Why you ask? You wanting to implement it? There is a good doc on gamasutra about d3d stencils - seems a good place to start. Just out if interest are you using HW T+L on your card as that could make a difference.

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
nick316    100
I am using the stencil buffer to do shadows on the regular
meshes and it works fine. But, the skinned meshes present a big
problem. I found some shadow map stuff on the nvidia site, so i might try that.

Nick

Share this post


Link to post
Share on other sites
EvilDecl81    360
Attribute Sorting must happen before Vertex Cache Optimization can happen.

For non-attribute sorted meshes, DrawSubset will have to manuelly search the index buffer and build up a list of triangles to render, possibly rendering one at a time, cleary, this can be dirt slow. In addition to that, your vertex chache is blown when you have to do another drawprimitive.

Personally, I think Drawsubset should just fail and force the user to have an attribute sorted mesh. There is no excuse not to have one. Think of attribute sorting less of an optimzation, and more of not doing something insane...




Share this post


Link to post
Share on other sites