Blitz Framerate issue - Quads/Models/Number of Entities

Blitz3D Forums/Blitz3D Programming/Blitz Framerate issue - Quads/Models/Number of Entities

Matty(Posted 2004) [#1]
Hi,

I am having a bit of trouble with Blitz's framerate and was hoping to get some opinions as
to why this could/should be so.

Tell me if this logic is incorrect:

I have a model with 60 triangles and 1 surface. On my PC (500 Mhz, GeForce 2MX)
using Blitz I can easily have about 100 of them in the viewport at one time, usually
on a terrain( with LOD of 500). I noticed when fiddling around with the mesh earlier that if I had 2
surfaces I could only have about 40-50 of them in the viewport easily and only about
20 of them if I had 4 surfaces.

So I concluded that my system should be able to handle 6000 polygons easily on the screen
at any one time (60 triangles multiplied by the 100 models). Therefore, if I used quads,
a polygon with just 2 triangles I should be able to have at least a thousand of them on
screen at one time.

This is the problem though:
I can still only have about 100-150 of these quads on the screen at once without incurring
massive slowdown. Yet that is only 2-300 polygons as compared to the 6000 or so that were
rendered when I used the mesh with 60 polygons. This is the case regardless of whether I
am updating the models position every frame or simply leaving them in place and moving the
camera around.

It seems that when I have more than about 200 entities in total in the 3d world I get real
slowdown. But - when I run some of the samples, like the Firepaint3d sample which has about
3-400 entities at any one time on my PC they run fine.

Is there something I might be doing wrong or have missed out on?
I am using the latest version of Blitz3d on a Windows 98 500Mhz PC with a Geforce 2 MX 32 Mb RAM
with 256Mb system RAM.


Updated message:
I began playing around with the Tween parameter and that seems to have fixed the problem to an extent. I can now have a larger number of entities on the screen at once, although I am unsure of how to best use it.


Binary_Moon(Posted 2004) [#2]
The problem is the number of surfaces NOT the number of polygons.

If you use quads a lot then try writing a single surface system, since they are relatively simple to set up and enable large amounts of quads at much higher speeds.


Matty(Posted 2004) [#3]
I thought my quads only had a single surface or do you mean that it is possible to have a single surface for all my quads?


Binary_Moon(Posted 2004) [#4]
You want a single surface for all your quads combined.

http://www.blitzbasic.com/codearcs/codearcs.php?code=437


Gabriel(Posted 2004) [#5]
You'll be so happy you did. That Geforce 2 MX is easily capable of rendering 30,000 polygons at 80+ fps if your surface count is low.


Ross C(Posted 2004) [#6]
Single surface for all of your quads. Everytime to want a new quad, you simply add 4 vertexs and 2 tris to the mesh. You use ONE texture. So all the quads use the same texture. Now, if you want different texture on each quad, you simply use a texture that has all the textures you need, then adjust the quads UV-co-ords to show the correct part of the texture.

Alot of surfaces kill blitz :)

Id imagine your Quads's are entities?

quad=loadmesh("quad.b3d")

or
quad=loadsprite("quad.bmp")


then you are copying that? That will result in lots of surfaces i'm sure :)


Matty(Posted 2004) [#7]
What I have done is create a mesh, create a surface, create the 4 vertices then join them with addtriangles. I then used the Entitytexture command to texture them with the one texture I have loaded into memory.

Is this what you mean?


Ross C(Posted 2004) [#8]
how are you creating new quads?


Matty(Posted 2004) [#9]
This is how I am creating new quads:

MyMesh\meshid=CreateMesh ()
mymesh\idnum=i
surf=CreateSurface(MyMesh\meshid)
Vertex(1)=AddVertex(surf,0,0,0,0,1)
Vertex(2)=AddVertex(surf,0,4,0,0,0)
Vertex(3)=AddVertex(surf,3,4,0,1,0)
Vertex(4)=AddVertex(surf,3,0,0,1,1)
Tri=AddTriangle(surf,Vertex(1),Vertex(2),Vertex(3))
Tri2=AddTriangle(surf,Vertex(1),Vertex(3),Vertex(4))
PaintMesh MyMesh\meshid,MyBrush


Ross C(Posted 2004) [#10]
Ah, well see once you've set up your mesh. Just add 4 more vertexs to the surface, everytime you want a new quad like so.

Set up your mesh and add a quad:

MyMesh\meshid=CreateMesh () 
mymesh\idnum=i 
surf=CreateSurface(MyMesh\meshid) 
Vertex(1)=AddVertex(surf,0,0,0,0,1) 
Vertex(2)=AddVertex(surf,0,4,0,0,0) 
Vertex(3)=AddVertex(surf,3,4,0,1,0) 
Vertex(4)=AddVertex(surf,3,0,0,1,1) 
Tri=AddTriangle(surf,Vertex(1),Vertex(2),Vertex(3)) 
Tri2=AddTriangle(surf,Vertex(1),Vertex(3),Vertex(4)) 
PaintMesh MyMesh\meshid,MyBrush


then add some new quads:

for loop=1 to 5
   Vertex(1)=AddVertex(surf,0,0,0,0,1) 
   Vertex(2)=AddVertex(surf,0,4,0,0,0) 
   Vertex(3)=AddVertex(surf,3,4,0,1,0) 
   Vertex(4)=AddVertex(surf,3,0,0,1,1) 
   Tri=AddTriangle(surf,Vertex(1),Vertex(2),Vertex(3)) 
   Tri2=AddTriangle(surf,Vertex(1),Vertex(3),Vertex(4))
next


to access each quad, just adjust it's position, using vertexcoords(), and input the correct index for each vertex. The way i did it, was to create a type object for each quad. I'd store the index for the first vertex of the quad.


Gabriel(Posted 2004) [#11]
It's been said two or three times already, but ONE surface for ALL quads ( that have the same texture. ) NOT one surface for EACH quad.

The link Binary Moon gave you shows you how. There's another version by Elias T as well.


Bouncer(Posted 2004) [#12]
Or you can look in my sig.... although it's not very well commented code :) but it's as fast as it gets.


Matty(Posted 2004) [#13]
Thanks, that helps a lot. Another question though - could this procedure be used for more complicated meshes than quads.


Bouncer(Posted 2004) [#14]
yes. You just have to make your own rotating and positioning functions for vertex groups. But I think moving objects with hundreds of vertices might be slower than blitz entities.


Michael Reitzenstein(Posted 2004) [#15]
But I think moving objects with hundreds of vertices might be slower than blitz entities.

On a hardware TnL card, this is almost certainly the case. But then, they are fast enough anyway...