Jump to content


Photo

3D Game Lag


  • Please log in to reply
4 replies to this topic

#1 GMRescue

GMRescue

    GMC Member

  • GMC Member
  • 125 posts
  • Version:GM8

Posted 27 June 2012 - 02:19 PM

Hello GM users,

I am GMRescue and I have a very basic problem. My game lags alot. Probably because of the amount of instances that I use. In the debug mode, it still doesn't get any more clear than before about the amount of instances there are since it is changing all the time. Is there a way for me to turn this lag-ful game into a smooth game? I've got a small demo right here:

Link to the Demo

What I'm trying to do is making a full game of this, because it's working out pretty well, but it has so much lag thought. I hope there is a solution for this problem.

What will you see

You'll probably see when you walk, that the FPS slows down from 64 to 42 or so. I think it's because of the amount of grass and rain. I added fog for lower detail and all the objects that are too far away (about 256-512 pixels away) will not be seen.

I hope I gave you all enought information. I don't want anybody to make my game. I want to do it by myself, but I called in help because of a small problem.

Thanks in advance, GMRescue
  • 0

#2 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1590 posts
  • Version:GM8.1

Posted 27 June 2012 - 09:35 PM

Link to the Demo

Switch hosts to Mediafire or Dropbox to avoid the log-in requirement. I'm not going to make a box account just to download this.

Also, don't just give a demo. Let us muck around in the source.

You'll probably see when you walk, that the FPS slows down from 64 to 42 or so. I think it's because of the amount of grass and rain. I added fog for lower detail and all the objects that are too far away (about 256-512 pixels away) will not be seen.

Sounds to me like you're not properly limiting the amount you push through GM's renderer (Also sounds like you're using fog naively). Depending on the game (Solve the problem listed above so we can see it), there are several solutions.

If your ground is ALWAYS flat, you can draw patches of grass ONLY in the area near the player by drawing 1-9 models.
If your ground is hilly or you need a large view distance, consider using a quadtree to render more-detailed grass near the user. (Lowest-level node has high-detail grass, each parent node has lower detail grass over a larger region) When using this method, you may want to generate new patches dynamically to reduce the amount of video memory you use. You can modify this system to show more-detailed models only once they are generated.

Edited by Gamer3D, 27 June 2012 - 09:37 PM.

  • 0

#3 slayer 64

slayer 64

    GMC Member

  • GMC Member
  • 3278 posts
  • Version:GM8.1

Posted 27 June 2012 - 11:46 PM

you probably gave us a link to the file when you're looking at the files, not a normal link that anyone can use. i made a box account and couldn't access the file.

if i did grass and rain, i would have a few models with lots of blades of grass and rain drops in them. only displaying the models nearby, not the whole map and try to hide it with fog. defiantly don't create an instance for each blade of grass and rain drop. group lots of primitives together in one model and maybe have a few instances displaying the models
  • 0

#4 GMRescue

GMRescue

    GMC Member

  • GMC Member
  • 125 posts
  • Version:GM8

Posted 28 June 2012 - 08:15 AM

I already disabled the rain, because it was really beyond GM's ability to render this amount of polygons. Because of the fog, blades that are too far away, are hidden from the map and the player won't see anything. Thanks for all the replies you gave me. These are pretty helpful and I'm sorry about the demo. My host-a account didn't allow me to host any more files and it seems that box isn't working out at all. I'll go to Mediafire next time. It's just, if I would say:

if distance_to_point(obj_player.x,obj_player.y) < 64 then visible = 1 else visible = 0

Then it would look a little strange. The larger the allowed distance to the player, the better it looks, but the slower it goes. Isn't there a DLL out so I can get unlimited data rendering. That would be great. I've tried alot of topics, but none of them had what I was looking for.

If there is anything unclear, please PM me or reply to this topic.

Thanks in advance, GMRescue

Edited by GMRescue, 28 June 2012 - 08:16 AM.

  • 0

#5 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1590 posts
  • Version:GM8.1

Posted 28 June 2012 - 07:53 PM

I already disabled the rain, because it was really beyond GM's ability to render this amount of polygons. Because of the fog, blades that are too far away, are hidden from the map and the player won't see anything.

Fog just changes the color. It doesn't stop them from rendering. Besides, I think the problem is your code, not the graphics card's fill-rate.

Then it would look a little strange. The larger the allowed distance to the player, the better it looks, but the slower it goes. Isn't there a DLL out so I can get unlimited data rendering. That would be great. I've tried alot of topics, but none of them had what I was looking for.

No such thing exists. Whenever something looks unlimited, it's because the programmer is using clever tricks to make limited data look more detailed than it is.

if distance_to_point(obj_player.x,obj_player.y) < 64 then visible = 1 else visible = 0

That actually shows the root of the problem. STOP USING OBJECTS FOR GRASS BLADES. Instances each have their own cost, even if no code is in them; also keep in mind that each GM function call is expensive, so drawing patches of grass individually will be slow. Take one of our suggestions for grouping grass blades into objects.
  • 1




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users