Jump to content
  • Advertisement

Archived

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

ji yan

MD2 file rendering performance in DX8.1

This topic is 5754 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: I''ve written a MD2 file loader and used it in my game project to render MD2 file models. However, it seems that rendering the MD2 object takes a long long time. What I did is that in every frame when updating animations, I calculate the new vertex positions and then stuff them into a vertex buffer which is later used for DrawPrimitives() function. My current situation is that in EVERY UPDATE, I need to loop for about 3 thousand times for calculating new vertex positions, and then these positions are stuffed into a vertex buffer with calles to the functions of Lock() and Unlock(), after setting the vertex buffer, I then use the function DrawPrimitives to draw the MD2 model. Can anyone give me any suggestions on how I can improve the performance of my MD2 model rendering? (oh, I found that the DrawPrimitives() func is extremly slow) Thanks for help in advance

Share this post


Link to post
Share on other sites
Advertisement
Can you be more specific on how to use DrawPrimtive.. correctly? And I am not sure if the dolphin example fits my situation because it is using the technique of Mesh while I am just plainly using Vertex buffer for storing vertex information.

More ideas from my fellow game developers please...

Thanks for any help in advance

Share this post


Link to post
Share on other sites
The dolphin example loads a mesh but extracts a VB from it. Same as your stuff. I used vertex shaders to do MD2 animation. I did a benchmark and drew 100 of them at 50 fps on a 1Ghz PC in software mode.

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
100 of them with a fps of 50??? AMAZING!!? Can someone please shed some light on how to achieve that performance? I am poorly rendering 15 of them only at 15fps with 900 cpu.

Share this post


Link to post
Share on other sites
Not the ref device - SW Vertex shaders on GF2 MX.

How did I get 50? No idea. I did no optimization - a different VB for every frame, interpolate between frames in VS. I didnt do lighting which may have made a difference and i recall that i was running in a low resolution (~400x300 in windowed mode).

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
Hey all,

I recently implemented an MD2 loader/renderer for my engine in much the same manner as described by thedo. The shader code - while simple to read if commented correctly - can be a bit of a nightmare and for a while it was causing me texture mapping issues because of a faulty shader declarator which I fixed up yesterday, just before I was ready to throw the computer out the window (A note to all: don''t forget D3DVSD_SKIP( 1 ) for any diffuse in your vertices )

Calculating each vertex position per frame (as I''ve seen in several dodgey implementations) will slow things down immensely - calculate all your vertices when you first load your MD2 (i.e. in between a per-frame vertex buffer lock and unlock during your MD2::load or whatever) and you''ll find things will speed up to an acceptable level.

Tom

Share this post


Link to post
Share on other sites
Thanks for all the helps first! There are still two questions left:

1.If we create a VB for every key frame, won''t we be eventually out of memory or sth? As far as I know, many MD2 files contain around 100 frames, also this seems to be slowing down the loading of the game a lot.(In my experiment it shows)

2. I seem to have done the exactly same thing as all you have suggested, but the speed just disappointed me. I am wondering if my vertex shader program is not efficient enough. I posted my VS code as following, hoping to get some comment on it from my fellow game developers:

;------------------------------------------------------------------------------
; Registers Layout
; v0 = Position of the first Mesh
; v1 = Tex coords
; v2 = Position of the second Mesh
; v3 = Tex coords
;
; c0 = matWorldViewProjection
; c5 = Time elapsed since last update
;------------------------------------------------------------------------------
vs.1.1

;------------------------------------------------------------------------------
; Vertex transformation
;------------------------------------------------------------------------------

; Tween the 2 positions (v0,v2) into one position
add r0, v2, c0
sub r0, r0, c0

sub r0, r0, v0
mul r1, r0, c5
add r2, r1, v0

; Transform position to the clipping space
m4x4 oPos, r2, c0

;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------

; Copy tex coords
mov oT0.xy, v1


Thanks for help again in advance



Share this post


Link to post
Share on other sites
It is greatly appreciated if anyone is willing to share a bit of code or two. I am really dying enhancing the performance of my game project.

Need your help please

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!