Results 1 to 12 of 12

Thread: UPBGE batching

  1. #1

    UPBGE batching

    Hi,

    I'l would like use batching to optimize my game but, i have try to use some exeple i've find, but it doenst work very well.

    i have try batch_test.blend file exemple we can find on this forum, but when i try to change by my 3D model it doenst work, and tell me an message "no model to merged", i have see if i replace my name model by an number is work, so i dont understand.

    Someone can shae an blend file exemple work, or script to explain because im blocked.

    I'm would like have like that

    from bge import *from mathutils import *


    scene = logic.getCurrentScene()
    own = logic.getCurrentController().owner
    #bge.types.KX_BatchGroup
    batch = types.KX_BatchGroup ([obj for obj in scene.objects if obj.name[0] == "colune4"])
    find all model have name colune4 like that colune4, colune4.001, colune4.002 and more and after can possible to batch other models like stair1, stair1.001, stair1.002

    Otherwise i'm would like to know if batching work with group name, because it's not explain, exemply like for assets map called into main blend file, and use name group as name object.

    i have try but i have everytime an error.

    Thank you.
    Last edited by kengi; 11-Jan-18 at 07:44.



  2. #2
    object.name[0] == "colune4" means object which name's FIRST CHARACTER equals "colune4". Surely you can understand that the condition will really never return true, hence why the list of meshes passed to the batch function turns out to be empty.
    BGE Python framework: https://gitlab.com/bgez/bgez.git



  3. #3
    So how i'm suggest to do, have you an exemple?



  4. #4
    You are creating a list on the go with this bit of code (taken from what you already have):

    Code:
    [obj for obj in scene.objects if obj.name[0] == "colune4"]
    The filtering happens in the condition, so far you wrote:

    Code:
    if obj.name[0] == "colune4"
    But if I try any name, here is what happen...
    Lets take an object named "Cube". We have obj.name = "Cube" at some point in the loop.
    obj.name[0] is the first character, here it would be "C".
    The test is the same as "C" == "colune4".

    This will never work.

    Just find a condition that better suits your need. Look for Python conditions if you have trouble, and string comparison.
    I mean just write something that makes sense and suits your needs.

    edit: tu peux faire un tour sur OpenClassroom (anciennement site du zéro) pour de l'aide sur Python etc... Le principal problème dans ton code c'est que quand tu essayes de générer une liste d'objets à batcher, ben à cause de ta condition ya rien quoi.
    Last edited by WKnight02; 11-Jan-18 at 20:28.
    BGE Python framework: https://gitlab.com/bgez/bgez.git



  5. #5
    Member BluePrintRandom's Avatar
    Join Date
    Jul 2008
    Location
    NoCal Usa
    Posts
    18,520
    Also if they are all the same mesh just click use geometry instancing*
    Break it and remake it - Wrectified
    If you cut off a head, the hydra grows back two.
    "headless upbge"



  6. #6
    Member JustinBarrett's Avatar
    Join Date
    Jul 2009
    Location
    Trier(near), Germany
    Posts
    2,304
    does that actually work? I was told otherwise, but I should test it myself.
    "The crows seem to be calling my name." Thought Kaw.
    Myrlea, "The Shepherd's Quest" formerly "Valiant" [project]



  7. #7
    I have try geometry instancing, but it's an shit, and not work with model have more than 150 polygon, so until, and FPS get less.

    Otherwise for the python condition i have find that:

    [obj for obj in scene.objects if "colune4" in obj] i think it's work but not sure.

    i have made an batching test i share the blend file, it's work for me with no error and support too many object and polygon.

    i dont know how is work and why but if i use obj.name.startswith it's work fine with no error.

    http://pasteall.org/blend/index.php?id=48717

    Let me konw if for you is work, the scene have 800k polygon test.

    Batching doesnt support object are linked from other blend file, but append object work with my script, i have try to add group of differents assets and is work too if you call the name of the model and not the name of the group.


    exemple for multiple object in same line
    from bge import *

    scene = logic.getCurrentScene()


    types.KX_BatchGroup ([obj for obj in scene.objects if obj.name.startswith("Cube") or obj.name.startswith("Suzanne") or obj.name.startswith("Icosphere")])
    other test on real asset, 800k poygon too with 4 texture 2048x2048, you can look difference, but i find not crazy the optimization with batching, 135fps between 115fps without...

    d.jpg

    not sure batching have an real interet finally if its just 10 or 15 fps, i've expect more like 30fps.
    Last edited by kengi; 12-Jan-18 at 13:29.



  8. #8
    Member Akira_San's Avatar
    Join Date
    Aug 2004
    Location
    Bulgaria
    Posts
    1,887
    Batching works, but it just joins meshes in game. Its good because it allows you to merge and split in game the objects. But its the same as joining object. Its best to use the feature if you have multiple of objects with a single or so material, like in a shelve. I think you have to add the - bge.types.KX_BatchGroup to make it work if i remember.
    anime, manga, blender3d



  9. #9
    Member BluePrintRandom's Avatar
    Join Date
    Jul 2008
    Location
    NoCal Usa
    Posts
    18,520
    Yeah all obj using batching need to use a material atlas,

    All building etc are made of pieces of geometry using the same pieces 100s of times.

    This is what batching is best for.
    Break it and remake it - Wrectified
    If you cut off a head, the hydra grows back two.
    "headless upbge"



  10. #10
    Member JustinBarrett's Avatar
    Join Date
    Jul 2009
    Location
    Trier(near), Germany
    Posts
    2,304
    This is how I assumed batching worked myself...in my tests I find it better to just join the objects myself outside of the game engine...it gives slightly better performance...this is how I am trying to manage my trees atm. I am currently sitting at 57-60 FPS by joining them by hand...when I use batching I get 55-58 FPS, I'm not really certain why...but it is what it is....I am sure there is a much better way to do what I am trying to do....but I'm an idiot(and proud of it!) I make no excuses
    "The crows seem to be calling my name." Thought Kaw.
    Myrlea, "The Shepherd's Quest" formerly "Valiant" [project]



  11. #11
    I have try different method, first method to have the best fps is calling assets from an other blend file with link, but that method not allow batching^^, otherwise with batching i have the same result of you, but i have see like the screen i have share, you can see my container model have more fps with batching, but if i put others assets on map and make the same method i have less fps with batching activated, so yes i think batching it's just an shit system because if we look on UE4 batching system, we win a lot of fps, for my part i will add the batching but not sure can give to user the best after i have RX vega64, so for me the diffrence is little, maybe on small configuration can be more interesting, anyway for real game like i want i'm cant use texture atlas because can reduce my quality texture.

    It's cool to see some others guys have same problem of me, otherwise the file i have share about batching is the good solution, that method count all model have the same name, i think it's the best way and simple

    About geometry isntancing, i have see when i active it on any model i receive in console an totblok error 1, so maybe the sytem too is bugg, if someone can verify too, anyway 150 polygone for using is really funny, need like 1000 poly not 150...
    Last edited by kengi; 13-Jan-18 at 05:29.



  12. #12
    Member BluePrintRandom's Avatar
    Join Date
    Jul 2008
    Location
    NoCal Usa
    Posts
    18,520
    geometry instancing on a set low poly 'trims' you use 1000s of times works great.
    (all trims use 1 atlas)

    this ends up being like 1 draw call for each trim geometry type



    batching
    (where all objects use 1 large material atlas)
    can batch all objects that share material into 1 call.

    Last edited by BluePrintRandom; 13-Jan-18 at 16:11.
    Break it and remake it - Wrectified
    If you cut off a head, the hydra grows back two.
    "headless upbge"



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •