Jump to content

Moving characters performance


Genebris
 Share

Recommended Posts

I have a huge FPS drop when moving rigged characters with simple Entity:Move method. The same mesh but collapsed in model settings causes no FPS drop.

 

 

100 characters on the top have bones. 100 characters on the bottom were collapsed. When moving bottom characters performance stays the same, when moving upper characters FPS drops from 500 to 100.

 

There is no lighting in the scene and character material uses not animated shader. So I think that the only difference is extra entities that are moving with rigged characters.

 

code:


function Script:Start()

chars = {}

for i=1,100 do

local e = Model:Load("models/crawler.mdl")

table.insert(chars, e)

e:SetPosition(math.random(0,10),0,math.random(0,10))

end

 

 

objects = {}

for i=1,100 do

local e = Model:Load("models/collapsed.mdl")

table.insert(objects, e)

e:SetPosition(math.random(0,10),0,math.random(-10,-20))

end

end

 

function Script:UpdatePhysics()

if window:KeyDown(Key.E) then

for k,v in pairs(chars) do

v:Move(-0.1,0,0)

end

end

 

 

if window:KeyDown(Key.R) then

for k,v in pairs(objects) do

v:Move(-0.1,0,0)

end

end

end

 

Can Anything be done about it? I don't need 100 characters, but when I tried 30 characters moving on the navmesh performance was very low compared to when they are standing still.

 

 

Project if you want to try: https://drive.google.com/open?id=0B5h7P9bq9NmIQmRDdGp1Y29LdFE

Link to comment
Share on other sites

I would expect 100 rigged crawlers to have a more significant expense when moving than 100 collapsed crawlers. The rigged crawler has 24 bones, so the engine is having to update not just 100 models but 2500 entities when you perform a Move().

 

Same idea with the navmesh navigation. And it may be worse with the character models you are trying- how many bones do they have? Then add animation ontop of that... One way to lessen the animation costs is to perform animation only in the Script:Draw() function. The only thing that might lessen the navmesh navigation is if Josh implements model LOD's at some point (like we had in LE2) - where at some distance the model can be swapped for a non rigged version of the model.

 

As far as FPS though - that's very subjective and will vary from computer to computer, but IMO if you can still achieve a fairly stable 60 fps then you are probably alright. And in some games, you might not need it that high, depends on the game/gameplay, etc...

  • Upvote 2

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I'm getting 60 FPS on a decent computer with pretty much empty scene and 30 characters moving on navmesh. I don't think it's a good result. After adding level geometry and lighting it will become 30 if not less.

 

I can reduce draw distance and shadow distance but it doesn't help, FPS is low even when characters aren't rendered. And this scene is even without animations.

 

Good idea about switching to non rigged models, I'll try that.

Link to comment
Share on other sites

http://www.leadwerks.com/werkspace/blog/1/entry-1866-common-bottlenecks/page__st__20#commentsStart\

 

... and you would probably save more performance with bones than with reducing polygons, although I would do both. You could disable the skeleton at the wrist and ankles at lower resolutions, and the mesh would just be weighted to the 100% to the parent bones.

 

Of course this would do nothing for performance when a lot of characters were immediately surrounding you. I don't recommend trying to make Left 4 Dead with Leadwerks, but if someone develops a commercial game that heavily uses a lot of characters onscreen at once it is something I will try my best to support.

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

A couple things to remember here. If you are going to have a lot of characters moving about. You would be best suited by creating an LOD system for them. It would help out tremendously. Reducing shadow quality can help.

Also, the end goal for your games fps should be around 60. Game development usually consists of building the world. Then finding ways for it to perform around 60 fps.

  • Upvote 1
Link to comment
Share on other sites

Documentation says that hidden entity won't be updated when parent moves, but I tried hiding the bones or entire model and it didn't help whatsoever. Is it correct behavior or a bug? How can I switch from rigged model to non rigged if not by hiding the model with bones?

 

http://www.leadwerks.com/werkspace/page/api-reference/_/entity/entityhide-r181

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...