Why my FPS is rating is SO low???

Blitz3D Forums/Blitz3D Programming/Why my FPS is rating is SO low???

gameproducer(Posted 2003) [#1]


#1 = 50 bots (1000 polys .b3d models each - not seen on screen)
#2 = current polycount (and hey... only 10MB out of 64MB videomem used, doesn't show on screen)
#3 = main character


Warren(Posted 2003) [#2]
How are you computing the FPS?


gameproducer(Posted 2003) [#3]
that isn't an issue, I quarantee - I notice that on screen when the framerate lowered from 150 to just about 5 ;)

there's also more info at:
http://www.blitzcoder.com/cgi-bin/ubb-cgi/postdisplay.cgi?forum=Forum14&topic=001011


Warren(Posted 2003) [#4]
Just seems sort of pointless. "My game is slow. Why?"

Without information or code, you really can't expect any kind of useful answer.


Ethan3850(Posted 2003) [#5]
Unfortunately if u want specific help you'll have to reveal your code. Short of that, switch off the Blitz debugger, your debugging code, check your not mixing 3d and 2d code, resolutions, terrain detail settings, calling AI functions too frequently, etc...


Caff(Posted 2003) [#6]
Well, this is a bit of a long shot, but it might possibly be your graphics card drivers? There is a known slowdown occuring due to directdraw and nvidia drivers.

There were some problems with recent Nvidia drivers, and was recently fixed (I think a stable working version was 43.45? Check Nvidia website for latest MS certified drivers).


gameproducer(Posted 2003) [#7]
@EpicBoy & Sainfohi: sorry, you are very right. I didn't provide much information so I try to do it now:

it seems that when adding more .b3d files there seems to be huge slowdown in-game. I tried to remove all my game logic but still the fps were near 10. I also put the game logic back and tried to remove updateworld - no effect. then I put that back and removed renderworl - no effect. I tried to hide all entities (even when they aren't seen) and got a little better rating, not much, but few fps.

Next I will try to make sure those guys aren't animated and I won't draw those 2D images and see what that does.

@Caff: nice try - but I don't think this is the issue... at least I have seen 150 fps (when there was no bots) so don't think it's a driver thing.

thanks for you all - does somebody have better information about how .b3d format works? it seems to be quite buggy thing...

and I would most appreciate if somebody - with a project where there is at least 50 bots - could tell me if they have had similar problems?


Ethan3850(Posted 2003) [#8]
it seems that when adding more .b3d files there seems to be huge slowdown in-game
If you mean what I think you mean then you should avoid doing it - that is, you should load files that you are going to use before actual game play begins...

Think of 3d commerical games. Before you start a new level you usally get a "Loading Game" / "Saving Game" screen when the game loads in 1 of every type of graphics/model it is going to use... so you should structure your game something like this:

[CODE];-------------------DECLARATIONS
Type .new_type_data
Field mesh
Field x,y,z
;--- etc.
End Type

Dim originals(0)
;-------------------LOAD LEVEL CODE
originals(0)=LoadMesh("filename")
HideEntity(0)
;------ etc.

;-------------------PREPARE LEVEL CODE

; Load/create robot data etc.

robots.new_type_data=New new_type_data
robots\x=0:robots\y=0,robots\z=0

;---- etc.
For robots.new_type_data=Each new_type_data
robots\mesh=CopyEntity(originals(0))
PositionEntity robots\mesh,robots\x,robots\y,robots\z
;------ etc.
Next
;----- etc.
;-------------------LEVEL GAME LOOPS
;-- Player code, and stuff
For robots.new_type_data=Each new_type_data
;-- Do code for robots, delete dead ones, create new
Next
[/CODE]Don't forget to use Functions to remove code from your main loop that isn't executed everytime. Hope that helps.


gameproducer(Posted 2003) [#9]
@Sainfohi: thanks for your help, but - nope it isn't that. I have a structure which loads first all stuff and then uses copyEntity (trust me, I'm not a newbie programmer).

and hey - I have got this working with .3ds models (or similar test anyhow) but now as I use .b3d models then it doesn't work... has anyone tried anything similar? (with 30 .b3d bots or like?)


Jeremy Alessi(Posted 2003) [#10]
Are you using Linepicks (linepick,camerapick, entityvisible) in your A.I. code? If you're using 50 linepicks for all your characters to determine where they're going, that would kill the framerate even with only 1200 polys. Complete guessing on this of course.

Just re-read your above post. If you got it working correctly with .3DS then I'm not sure why .B3D would give you trouble. The test must be doing something different (you said similar test) what's the difference?

Also, it must be said that drawing 2D over 3D gives me about a 10 FPS hit.


RetroBooster(Posted 2003) [#11]
remove all text and 2D drawing, then check your fps again!
I'm guessing thats the only probable cause for your problem.


FlameDuck(Posted 2003) [#12]
Check Nvidia website for latest MS certified drivers).
Except the last Microsoft WHQL certified drivers are 30.82! So if you've got a GeForceFX you're screwed.
remove all text and 2D drawing, then check your fps again!
I'm guessing thats the only probable cause for your problem.
I agree. I have a scene with 22 "bots" *on* *screen* at the same time, and 4 large meshes for a total of more than 27000 polygons. I get around 200 fps when not doing anything.


gameproducer(Posted 2003) [#13]
@Retrobooster & FlameDuck: well, as you can see... there's only few 2D images on screen, so hardly three 2D images can cause this kind of slowdown (especially when I have tested the whole scene WITHOUT renderWorld command...). Anyhow - mind if I ask, Flameduck, do you use B3D format there? or are your models .3ds or other? (I have a STRONG hunch about the fact that B3D FORMAT causes problems)

I too had no problems when running my benchmark with trees, land, dragon etc. on screen when I used .3ds format (but that was quite a long time ago - now I'd like to hear if anyone has used .b3d format, and I mean HEAVILY used it! :)

I appreciate all the help, so thanks already - keep'it'posting ;)


Ethan3850(Posted 2003) [#14]
I have a STRONG hunch about the fact that B3D FORMAT causes problems
I don't see how since meshes are all stored the sameway by Blitz. However, B3d does store slightly different settings to 3ds so perhaps when you converted them something got added, taken away or screwed up. It might be an idea to re-convert them, checking all the settings and the integretary of your models.


gameproducer(Posted 2003) [#15]
@Sainfohi: I'm not that sure .b3d model format is optimized (compared to how long time .3ds format has been there...) but I will check this: I shall replace those .b3d models with similar .3ds models and check what happens. thanks for your help.

oh, and I'm still waiting to hear if somebody has a game which uses at least 30 .b3d bots and that game runs nicely.


Jeremy Alessi(Posted 2003) [#16]
I don't know how you think you're going to blame the 3D model format! That doesn't make sense.

In Aerial Antics we've got hundreds of seperate .B3D entities in our levels and it runs fine. That's the only 3D format we're using. I'd say it's either drivers or you're being careless with collisions, linepicking, or shadows.


gameproducer(Posted 2003) [#17]
@BAN300: well, based on the facts that .3ds models were running fine, pure logic plus other comments on the blitzcoder forums (where there was other guy who said .b3d models bring troubles - each model added got heavy slowdown). and I must say another thing: do you use ANIMATED .b3d models - it can be the animation (have to test that right away...) format which causes problems.

(but... I can always be wrong :)

Also: if you are using animated .b3d models - how many childs do they have (we have quite many bones in our human character)? And I must confirm: you said you have hundreds of simultaneous .b3d models in-game? (so that it doesn't copy stuff to memory (or something) when you proceed - on one same even you have hundreds of models flying around?)


gameproducer(Posted 2003) [#18]
hmm... one possible chance is that my player TYPE is too complex - can it be?
Type player
	;---------------------------- game specific
	;identification
	Field id

	Field side				;which side player takes (1=humans, 2=elves)
	Field run 				;TRUE/FALSE - whether character is running or not
	Field charavailableflag	;whether player mouse clicks affect ground

	Field actionCurrent
	Field actionOld
	Field actionAvailableFlag		;TRUE/FALSE whether character is in combat or otherwise not controllable
	
	Field gravity#

	Field animationDeathDoneFlag 	;indicates whether player has done death animation or not

	Field labelImage[2]		;player label in-game

	;entities - everything which must be deleted after session (check out function playersDelete)
	Field pivot				;pivot
	Field ghostPivot		;ghost pivot - to determine other players' REAL positions
	Field mesh				;model
	Field walksoundloop
	Field shadowSprite		;player shadow

	;linker (slot 0 is for warrior sprites)
	Field playerLink[256]
	Field playerLinkOld[256]
	Field linkerSprite[256]
	Field linkerFlag[256]
	Field linkerSpriteAlpha#[256]	;sets the alpha value of the linker sprite

	;player race
	Field race				;0=none, 1=dwarf, 2=elf, 3=human, 4=dark elf
	Field race_new			;the race which character chooses as a new race

	;player gui
	Field labelmodifier		;how many pixels left will the player name make the player label to appear (remember to change when changing player name in game)
	Field barModifier		;similar to label modifier...

	;game stats
	Field ctr_side_change
	
	Field waypoint
	Field waypointReachedFlag
	
	;equipment	::	1=right hand, 2=left hand, !!!3=back
	Field equipmentMesh[PLAYEREQUIPMENTSLOTAMOUNT]	
	Field equipmentChildPointer[PLAYEREQUIPMENTSLOTAMOUNT]	;lefthand2, righthand2, !!!needs also "back" child bone
	Field equipmentTypeId[PLAYEREQUIPMENTSLOTAMOUNT]		;current equipment type IDs so that game knows what equipment to create in respawn place
	Field equipmentTypeIdOld[PLAYEREQUIPMENTSLOTAMOUNT]		;defines the ids before changing weapons on hands

	Field armorRating

	Field pick$
	Field ticks				;each tick = 100 ms, this is used for testing flag capture for example
	
	;battle
	Field target			;target player pivot
	Field target_id			;target player id
	Field target_side		;target side
	
	;flags
	Field flag_moving		;check whether character is currently moving
	Field flag_capturing	;check whether character is currently capturing flagpoint
	Field flag_attacking	;check if attacking
	Field flagpointRespawnId	;the flagpoint player has chosen to be his respawn place
	
	;network
	Field netmessagessent	;amount of packets sent
	
	;game stats
	Field statDeaths			;how many times player was killed - MOST something...
	Field statSpentRPs			;how much resourcepoints spent - this can be used to count "player price" - how valuable for the team
	Field statIndividualkills	;how many individual (not part of group) kills - LONE WOLF MARK
	Field statAssistedkills		;how many kills done by some other group member - this can be used to count MOST VALUABLE LEADER
	Field statLoyaltykills		;how many kills under group leader - MOST LOYAL WARRIOR
	Field statTraitormarks		;how many times changed side - TRAITOR
	

	Field controlledTroopsCount	;how many member belong to your group
	
	;some elements	
	Field speedOriginal#
	Field speedCurrent#

	Field manaCurrent
	Field manaMax

	;combat skills
	Field rank	;RANK_WARRIOR = 1, RANK_GROUPLEADER = 2

	Field attributeStrengthCurrent
	Field attributeStrengthMax
	Field attributeConstitutionCurrent
	Field attributeConstitutionMax
	Field attributeMindCurrent
	Field attributeMindMax
	Field attributeDexterityCurrent
	Field attributeDexterityMax
	Field attributePerceptionCurrent
	Field attributePerceptionMax
	
	Field skillMeleeAttackOriginal
	Field skillMeleeDefenseOriginal
	Field skillMeleeDamageOriginal
	Field skillBowAttackOriginal
	Field skillBowDamageOriginal

	Field skillMeleeAttackCurrent
	Field skillMeleeDefenseCurrent
	Field skillMeleeDamageCurrent
	Field skillBowAttackCurrent
	Field skillBowDamageCurrent

	Field hitpointsCurrent
	Field hitpointsMax
	Field hitpointsLost

	Field moraleCurrent
	Field bonusLeadership

	Field combatAvailableFlag
	Field combatTicks
		
	;-----------------rpg elements

	;role thingies
	Field name$

	;attributes
	Field foodpoints
	Field foodpointsmax
	Field carrypoints
	Field endurance_points
	Field endurance_delay

	;knowledge
	Field booklore
	Field itemlore
	Field animallore
	Field weaponlore

End Type



Jeremy Alessi(Posted 2003) [#19]
Surely, our game doesn't use as many (complex) animated meshes as yours of course (we have no need for many humanoid bots of any sort) but we are running quite a few models with bones and animation.

If fact currently we're using all animated boned objects in order for my artist to build levels in 3D Studio Max and for us to retrieve local coordinates from an Ultimate Unwrap export. We have some levels that contain 20 - 40 animated objects (platforms with rotating propellers mainly, in addition to other animated background objects, and the main character all on top of many other boned objects that don't animate).

If the only difference between your two tests are .b3d models vs. .3ds I guess there is some bottle neck, but it doesn't seem to make much sense. A 3D model format is a way of storing information, when you load it up it's just polys and textures. The only thing I can think of is that the .b3d is using more surfaces upon export or something. Even then I can't see you getting such low framerates.

Also, you said the framerate stays low even if you remove renderworld. Wouldn't that remove the bottleneck of surface count issues which slows rendering down?

One thing I will say is that we're using dynamic animation with the exception of only a few objects that have many frames of pre-recorded animation. With regard to that I cannot say if using traditional animation commands on a .b3d make it slower.

Basically, I haven't heard of another instance where someone had a problem with animated .b3d's and you haven't given enough information for anyone to really figure the problem out. Generally, the 3D model format doesn't matter. When .b3d came out, many people were saying it should be/or is faster than any other format for Blitz3D. Mark was quick to explain that the format wouldn't change the speed, so my first inclination is to trust his advice in that aspect of a game engine.

Perhaps those bad drivers only have a problem with the .b3d model format and you should update them. The first time my artist tried True-Vol he only got about 8 FPS. That game relies on the .b3d format and when he got new drivers the game ran correctly. That makes at least a little sense. I don't think that the model format is inherently bad.


gameproducer(Posted 2003) [#20]
@BAN300: thanks for your answer. and I must say that when I used those .3ds models the game logic (player types etc.) weren't that complex - so it can't be just that (this was my first thought because I thought it was the dramatic change there...)

I'll try to give some more accurate readings soon. And I will test just to create several meshes there (without use of type) and let see what that does.


Jeremy Alessi(Posted 2003) [#21]
Hey I posted ... I guess at nearly the same time as you. That is a complicated type, but I don't think that only the size of it can be slowing your game down but with something that complex and then 50 of them all battling or whatever it probably is logic, expecially if you removed renderworld. Also, it's a networked game which adds even more complexity.

You may have to cut back on the complexity of each character or the number of characters running, probably a little of both.

You're dealing with a complex simulation and so it looks to me like you need some really good data management tricks not graphics tricks to make it run faster.


skidracer(Posted 2003) [#22]
So if you are sure it's b3d you have proven it to yourself by using similar 3ds or not?

What setting is the camera?

If it's orthographic, can you try normal camera with lots of zoom, marks says b3d bone / vert stuff is done by cpu but if they are clipped by viewing frustrum should be zero cpu load - hence me wondering if isometric still has a culling issue.

Is your polycount based on trisrendered? That could be wrong with two cameras, can you disable the inset cam?


gameproducer(Posted 2003) [#23]
I tried the game with 50 spheres instead of .b3d models and that didn't helped so that make me think it (possibly) couldn't be just the model format. And guess what:

I FOUND DA BUG :D

big thanks to all of you who had taken time to help me out with this. Listen to this.

I realized that I had a code that created sprite lines in my createNewPlayer function:
 !!!add here identification for PLAYER ID = CURRENT ID (so that sprites are made for own player only)
		For i=0 To 256
			f\linkerSprite[i] = CreateSprite() : EntityColor f\linkerSprite[i], 20, 250, 20 : SpriteViewMode f\linkerSprite[i], 2 : EntityAlpha f\linkerSprite[i],0 : EntityOrder f\linkerSprite[i], -1
			f\linkerFlag[i] = 0
		Next

and because I hadn't listened to myself - heh - I hadn't added that one IF line
If (f\id = g_player_id)

Now when I added this line (so that only YOUR player creates the sprite lines) the FPS rate got back to normal.

Well, you can imagine: you have 1 player with about 250 sprite lines -> 50 player makes 5000 sprite lines (surfaces...) which is quite a lot to handle. And because I only need the sprites added to PLAYER character the surface count affect was dramatic when I removed those extra sprites (even when the sprites were not rendered - but they were taken into UpdateWorld or something what is happening in blitz engine.)

So - big thanks for you all with this brainstorming, you have been great help.


skidracer(Posted 2003) [#24]
Hurrah!


gameproducer(Posted 2003) [#25]
:)

Here are some results I got:
GAME LOGIC (LOOPS ETC.) TAKEN OFF
2ms before updateworld (game logic)
8ms after updateworld
32ms after renderworld 

GAME LOGIC (LOOPS ETC.) ON
2ms before updateworld (game logic)
8ms after updateworld
32ms after renderworld 

(so the millisecs are similar, same time passes to get things done - game logic doesn't affect much - even with network etc. ON :)


Jeremy Alessi(Posted 2003) [#26]
Whew!