Jump to content


Photo

3D Game Optimization


  • Please log in to reply
13 replies to this topic

#1 RoyalCardMan

RoyalCardMan

    GMC Member

  • GMC Member
  • 244 posts

Posted 24 August 2011 - 05:08 PM

So, I am working on a 3D game, and so far it was going well, as far as speed, but not that I have included more into it, it started going down to 5-6 FPS, which I know is either the graphics or the amount of instances within the room.

Now, first, I tried taking out the code that wasn't needed(or could be simplified) and when I tested it, it raised only 2 or 3 fps.

Then, I tried putting code into other objects and deleting the objects that had the code in them, and then tested it. No FPS was gained from that.

Lastly, I deleted all the resources and loaded then externally, but no FPS was gained(only the loading speed was way faster, which is good).

So, there is only one choice I have. Delete a lot of the objects in the room, but before I did that, I wanted to ask if there is something more I can do to increase the FPS.

Also, all models are only loaded once, to make the loading time faster, but it did't affect FPS.

Thank you for anyone that responds. The only conclusion I came to was it was my computer or the high polygon count in the models that is causing the problem, but I don't know. Thank you for any responses.
  • 0

#2 BattleRifle BR55

BattleRifle BR55

    Moo

  • GMC Member
  • 8247 posts
  • Version:GM7

Posted 24 August 2011 - 05:16 PM

How many instances do you have in the room?
  • 0

#3 RoyalCardMan

RoyalCardMan

    GMC Member

  • GMC Member
  • 244 posts

Posted 24 August 2011 - 05:18 PM

How exactly would I find out? :sweat:

EDIT: 296 instances

Edited by RoyalCardMan, 24 August 2011 - 05:20 PM.

  • 0

#4 BattleRifle BR55

BattleRifle BR55

    Moo

  • GMC Member
  • 8247 posts
  • Version:GM7

Posted 24 August 2011 - 05:44 PM

Why so many? What are they all doing? Look into sorting all that out, because I get a horrible, horrible frame rate in your game.
  • 0

#5 RoyalCardMan

RoyalCardMan

    GMC Member

  • GMC Member
  • 244 posts

Posted 24 August 2011 - 06:01 PM

Most of it is because of drawing the terrain. I will see what I can do.
  • 0

#6 Poeman

Poeman

    GMC Member

  • GMC Member
  • 382 posts

Posted 24 August 2011 - 06:44 PM

d3d_set_culling(true);

Try that ;)
  • 0

#7 Zesterer

Zesterer

    Professor of Articul

  • GMC Member
  • 1019 posts
  • Version:GM8

Posted 24 August 2011 - 06:45 PM

1. Lower the poly count - lower the steps in drawing spheres, cylinders or cones.
2. Turn culling on at all possible moments.
3. Don't draw instances behind the camera, directly above or below, or instances that are too far from the camera.
4. Lower the texture quality. A huge amount of processing time is taken drawing detailed textures.
6. Only make the screen redraw ever other step - lowers smoothness, increases speed.
7. Don't draw surfaces that aren't facing the camera or that are behind things.
8. Replace as much as possible with 2D sprites - details like grass.
9. Never draw objects un-necessary to a game - such as an invisible object.
10. Lower the screen resolution. This will greatly increase game speed. However, it lowers quality, so I suggest making your game windowed.

These will all increase game speed if used correctly. Good luck!
  • 0

#8 RoyalCardMan

RoyalCardMan

    GMC Member

  • GMC Member
  • 244 posts

Posted 24 August 2011 - 07:18 PM

d3d_set_culling(true);

Try that ;)

I still get 8 FPS. O_O

It may just be my computer. I tried lowering my object count, it somewhat worked, but it still lags.
  • 0

#9 Desert Dog

Desert Dog

    GMC Member

  • Global Moderators
  • 6409 posts
  • Version:Unknown

Posted 25 August 2011 - 09:38 AM

What's your view size? I wouldn't recommend going over 640x480 for a 3d, GM game. You could try scaling the view size down, too.
  • 0

#10 ynspyred

ynspyred

    GMC Member

  • New Member
  • 328 posts

Posted 25 August 2011 - 10:47 AM

Group static models into one large model, if they share the same texture. For example, if you have several identical trees in the level, each with the same model and textuer, and an instance each to draw them, it will be much quicker to weld all those trees into one model and draw that.
  • 0

#11 Jobo

Jobo

    No neurons left today

  • GMC Member
  • 2405 posts
  • Version:GM:Studio

Posted 25 August 2011 - 11:24 AM

To elaborate on ynspyred's post, use as few Draw events as you possibly can.
Draw events are terrible slow in Game Maker, and the less the better. So by grouping all static (non-moving) models together, you are also using much fewer draw events.

Also, if you have 100 instances checking for collision with the player - don't do that.
If you have 100 instances of object objWall and they all have an event for "collision with objPlayer" - then that's wrong.
If you happen to have that, remove all collision with objPlayer events from the 100 instances and set a collision event on the player; "collision with objWall".
  • 0

#12 RoyalCardMan

RoyalCardMan

    GMC Member

  • GMC Member
  • 244 posts

Posted 25 August 2011 - 12:52 PM

Hmmmm....Well I do have a lot of draw events. I will try to combine to some models together.

I'll report if it works or not.
  • 0

#13 brett14

brett14

    GMC Member

  • GMC Member
  • 1150 posts
  • Version:GM8

Posted 01 September 2011 - 06:19 AM

Group all your static models into one larger one. If you need to use gm's room editor to place trees etc. then call this code with a "controller" object (only needs to be called once)

treemod=d3d_model_create();
d3d_model_primitive_begin(treemod,pr_trianglelist);
with(tree){
d3d_model_tree(other.treemod,x,y,z);//models a tree at x,y,z in controllers treemod
instance_destroy();//Remove this instance
}
d3d_model_primitive_end(treemod);

[this code was typed on-post, so there is no guarantee that it will work as-is].

Cheers
~~Brett14;

Edited by brett14, 01 September 2011 - 06:21 AM.

  • 0

#14 GS-games

GS-games

    Creative

  • GMC Member
  • 323 posts
  • Version:GM:Studio

Posted 14 February 2012 - 08:15 PM

you can also try to deactivate and activate objects that are far from the camera position (If you use objects to draw 3d) Posted Image
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users