UPBGE: Geometry instancing and Batch: Not working well?

Guy, what is the right way to use this two features? Cuz I’ve made A LOT of tests, reading the UPBGE doc to make everything right, using (obviously) objects with the same mesh/materials and low poly count, but the results are:

Mesh Batching: Absolutely no difference with or without them. No gain or loss of fps. Searching a little bit here, I’ve found that some people had a lot of fps gains batching objects, and others (like me), no…
I’m batching my objects like this (in a summarized way):


if not "batchedTrees" in cont.owner:
    cont.owner["batchedTrees"] = types.KX_BatchGroup( [obj for obj in scene.objects if "batchTree" in obj] )

Geometry Instancing: If I activate this option (following the instructions on UPBGE API), this just ruined my fps!! Goes from 70-80 fps to 5 or 3… And I don’t know why, but in some objects (like my grass), If I activate this, the objects glitch,I think they stop getting theright camera transformation, or something like this, and always stays in front of the camera (no matter if I’m looking or not to the objects, they cover everything!).

What is the right way to use them? Can someone give me a .blend example? Thanks!

is it just me? or should it be

bge.types.KX_BatchGroup(list)

in the documentation code example?

EDIT:
your funky “for” loop is driving me nuts.

import bge

owner = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()

list = []

for obj in scene.objects:
    spname = obj.name.split(".")  #"tree.000", "tree.001" or "tree" objects will be found
    if "property" in obj or spname[0] == "tree":
        list.append(obj)

owner["batchgroup"] = bge.types.KX_BatchGroup(list)

Yeah I’m 99% sure it is supposed to be bge.types. for some reason it doesn’t work when you do just types.

This is interesting…I tried his method and it gives no errors, but it also does nothing…I just closed blender to see what was going on here at the forum, so I have yet to try out using a list. I’m not sure if this is something I need…since most of my trees get culled anyway…most I have on screen is about 50…maybe…I also have tree groups(many trees as one object, not an actual group)…this increases the vertex count but since a group of 8 trees is about 4k verts(estimate)…I feel it is faster…and then I place individual trees around to beautify and offset the looks.

GI only works on objects duplicated using Alt+D, also check your console for errors! Your hardware might not support this feature.

Actually your code do the same thing as my code.


list = []
for obj in scene.objects:
    if "tree" in obj:
        list.append(obj)

and


list = [obj for obj in scene.objects if "tree" in obj]

do exactly the same thing. :smiley:

Actually, if I import the bge like this:


import bge

I’ll have to use “bge.types.”
But if I import like this:


from bge import types

It’s ok to just use “types.” (Note that here, I’m not importing the entirely BGE, just the types)

Yes, I’m using Alt + D. I’ve no errors on the console. By the way, my GPU supports OpenGL 4.4+ (Nvidia GTX 960).

:o

Try my example file: https://drive.google.com/open?id=0B6yNvVGWiWysM3NIbWpWdDVCY00