Avoid lag with lots of objects

Ok, so in my level lots of bamboo is needed lots and lost AND LOTS of bamboo.
In fact, besides the small town there is supposed to be an entire bamboo forest, but its literally EATING my computer speed.
I’ve played games with forests before, or at least, with lots of stuff on screen, without much lag.
The bamboo clusters aren’t even high-poly, but it gives my processor (when I look at the Task manager) 1.098 MB to do.
Is there any way to have this large bamboo forest done without the epic lag (or the crashing; can’t get the engine started).
(Linking?.. doesn’t make that much differance…)

Specs:
AMD Dual-Core Processor E1-1200
AMD Radeon HD 7310
4GB DDR3 Memory

Use level of detail. Only display the ones close to you, images on planes for the ones slightly furthur away, and not display them at all beyond a certain distance.

Kupoman made a LOD build of blender. It’s link is somewhere in the recent posts in this forum.

Join objects which do not need to be separate, this too will improve your speed.

Yeahhh… I heard quite some about it here (mostly things lie "thanks to LOD it runs at 60 fps), I thought it was just some Blender trick I didn’t know about…

Did that, didn’t improve a thing DX

To make it short, i’d try this - which is a lod system by the way. Create an empty, add to that empty N objects, each of them representing the same object at different level of detail.
Name the childrens 0something, 1something, 2something, Nsomething, where a lower N represents a more detailed object.
Then you add a “Always”, repeated with some frequency, that executes the “update” method on a script like this:

import bge, math

NAME_OF_THE_PLAYER_OBJECT="Player"

def cacheLodData(node):#sorts the children and cache the list in the node
    lods = sorted(node.children, key=lambda e: e.name)
    node["levels"] = lods
    node["size"] = len(lods)
    return lods

def update(controller):
    node = controller.owner
    levels = node.get("levels")
    if levels == None: levels = cacheLodData(node)
    lodSize = node["size"]
    player = bge.logic.getCurrentScene().objects[NAME_OF_THE_PLAYER_OBJECT]
    distance = node.getDistanceTo(player)#get the distance from the player
    thr = int(math.sqrt(distance / lodSize))#use a quadratic to choose the lod index
    thr = min(lodSize-1, thr)#remove if you want the object to disappear when far away
    for i in range(0, lodSize): levels[i].visible = (i == thr)#hide/show the selected layer

You create a group with the node and its lod children, then you create as many links to that group as you want and you should have your forest. It should work, in theory, I haven’t had the time to test it properly though.

Add to, you mean parent? And should it be on another layer?

Yap, parenting. Like:

+Empty
–0HighDetailTree
–1MediumDetailTree
–2LowDetailTree

The objects don’t have to be in a different layer, the script just toggles the visibility property of the children according to the distance of the parent node from the player.
The grouping idea is just to make it easier to insert lots of trees into the scene but it is not needed, the script just needs a parent and a set of children, whose name reflects the level of detail they express (tecnically they are sorted lexicographically but you just have to prepend an integer to the name, from 0 to 9, where 0 is the object with most details and 9 the one with less details).
It may or may not increase FPS depending on how the engine deals with the visibility state but I suppose that it restricts renderability in a early stage of the rendering pipeline, so it should increase performances.

Here’s a blend test:

http://www.tukano.it/blender/lodtest.blend.zip

Aaaah, right I get it… sort off. Well I can’t understand 75% of the script I do sorta get how it works.

Sounds like maybe it’s something other than “Rasterizer”, then. What’s the profiler say?

You haven’t talked about polygon count? How many tris in your scene?

I also hope you are duplicating your bamboos via dupligroups and not just SHIFT+D which could explain the excessive usage of memory.

A scene with model of 1000 cubes cloned 15 times with instances: 108mb memory usage
The same setup with duplicates: 250mb memory usage

But yeah, you will need LOD and all the other games with forests etc. you’ve played have LOD as well. They probably have more aggressive culling than BGE as well.

271851 Verts.

Uuuuuuuuuuuuuuuuuhhhh… Maybe? ^^;
Dupligroups? Dunno how to do that, though I suppose its nothing a google search can’t solve…

Yeah I got that; When I play a game I pay attention to such details and I was hoping for an easy blender trick.
Unfortunatly the easy part will only be implemented in Blender v2.70… (googled it)

dupli groups = instances (alt+d).