PDA

Click to See Complete Forum and Search --> : 4800 vertices = 8 fps...


The_Fog
Dec 18th, 2001, 02:04 AM
I'm using vb and directx8 to create a small surface. It consists of aprox. 2400 squares (4800 triangles) in the 800x600 resolution. I'm using the normal transformed and lit flexible vertex format.
I'm using createTextureFromFile do load the textures.
The squares are overlapping each other in the following way.
1. Every square is 30x60 px.
2. Each squares x increase with +10 px compared to the square before it.
3. When one row has been completed, y is incresed by 20, and another row is drawn.

This results in small 10x20 squares that are overlapping eachother. This will result in as much as 9 squares overlapping eachother at some places. I'm using D3DBLEND_SRCCOLOR and D3DBLEND_DESTCOLOR to get some very cool effects on this.

The only problem now is the speed.. I'm running this on a celeron 667 mhz with an ATI rage fury pro card. And I'm only achieving about 8 fps. I need at least 25 to make it look good.
Are there any faster vertex format I can use? Any other way of loading the textures?
I'm using the "DrawPrimitiveUP" method to do the drawing. I'm using the "TriangleStrip" to create to solid squares which I then places my textures on. Are there any faster way to do this?
I know that this could be done faster since I've seen games in vb rendering like 10 000 vertexes and still getting about 25-30 fps. (on this computer)
As of now, I can only run this in 32bit color depth. If I try another format, then I just get an "automation error".

I'm thankful for every answer and tip that I get!

Sincerely
Benny Olsson

Staifour
Dec 18th, 2001, 11:00 AM
yeh,
i have that problem too. I also think that your relly lucky to have 8 fps for 4800 vertices cause i made a model of about 2000 vertices ( but that is loaded using a X file) and i had 4 fps althought i have a PIII 750 Mhz, and that's the reason why i left learning Direct3D after only 3 weeks of learning. I'm really looking forward to hear that there is a way to make it faster. I know that all that i've told you BULL $#&@ but anyway i only wanted to tell you that it seems to be a common problem.
Am i drunk or what !? This is really BULL %@#*

Zaei
Dec 18th, 2001, 02:14 PM
DrawPrimitiveUP = SLOW. Never use it for anything. Likewise, calling DrawPrimitive or DrawPrimitiveUP with a 2 triangle strip is slow. Optimal performance can be acheived using strips in vertex buffers, with 300..1000 vertices, even better if you can use index buffers.

Z.

The_Fog
Dec 18th, 2001, 03:06 PM
Ok.. Tnx!

Now.. I can create a vertex buffer containing all the 4800 vertices.. Just tell me how, and how to use it.. Do you have any code examples?

Thanks for the help!

Zaei
Dec 18th, 2001, 04:29 PM
Since you are doing quads, you have to make a decision. You can make a vertex buffer with 6 * numSquares, and use Tri Lists, and 4 * numSquares, and use Multiple DrawPrimitive calls. The first is probably your best bet.

There are examples of creating, filling, and using vertex buffers in the SDK tutorials. Its nothing really special.

Z.

The_Fog
Dec 19th, 2001, 02:21 AM
If I use the first technique you described, will I be able to set different textures for each square?

Thank you so much for all your help!

Zaei
Dec 19th, 2001, 06:36 AM
No, you would have to make multiple calls. If you reuse textures, you need to batch the calls:

SetTexture()
DrawPrimitive()
SetTexture()
DrawPrimitive()
...

So that with each pair of calls, all of the squares that use the texture are drawn. If enough textures are reused, this will still be faster then calling DrawPrimitive for each quad.

Z.

The_Fog
Dec 19th, 2001, 06:47 AM
Makes perfect sense.. Thanks.. :-)

I did some tests with vertexbuffers.. But I only managed to get it to draw 1 triangle. It wouldn't draw the other tringle no matter how I set the coordinates.
i.e:

------
vertices(0).x = 0
vertices(0).y = 0

vertices(1).x = 50
vertices(1).y = 0

vertices(2).x = 0
vertices(2).y = 50

vertices(3).x = 50
vertices(3).y = 50
------

It would only render the first 3 vertexes, so I tried defining 6 vertexes.

------
vertices(0).x = 0
vertices(0).y = 0

vertices(1).x = 50
vertices(1).y = 0

vertices(2).x = 0
vertices(2).y = 50

vertices(3).x = 50
vertices(3).y = 0

vertices(4).x = 0
vertices(4).y = 50

vertices(5).x = 50
vertices(5).y = 50
------

But I got the same result.. I did think of changing the size of the vertex buffer, so that's not the problem..

/Benny

Zaei
Dec 19th, 2001, 07:09 AM
You defined your vertices in the wrong order:

vertices(3).x = 50
vertices(3).y = 0

vertices(4).x = 50
vertices(4).y = 50

vertices(5).x = 0
vertices(5).y = 50


To check for things like this, SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE), and see if the triangles show up.

Z.