Multithreaded Level of Detail & Procedural Loading [High Performance]

This is a nice asset, thank you for all your efforts :slight_smile:

Could they make LOD @ the trunk level? so every mesh has 3 meshes, that are “tagged” and it just swaps them out?

I’m looking for a way to create a big open map and other than the occluding modifier I’ll surely need a LOD script.

Your script seem awesome and I’d like to try it but since I’m new to BGE I’m needing info.

As we know, the main BGE loop runs only on a single thread. This thread manages everything…Solution? - Make a separate thread just for the logic.

Can you please explain what is a thread in the BGE? (all the tutorial that I have seen never mentioned this; at least none I can recall) Do you mean single cpu core?? guess not but I don’t understand what a thread is regarding the BGE.

  • Only one, object independent LOD script, which examines and handles all objects in the scene, and make decisions if they needs to be replaced or not.

Do you mean to create lets say en empty and apply the script to this empty

.- Make this LOD script run on the separate thread

Again, what do you mean by separate thread? Is it the same thread as the one you ask us to create at the beginning? (the one with the logic)

Eventually if you could create a video tutorial (with voice comments ideally) it would be easier for a lot of us I’m sure. :slight_smile:

By the way, are you still updating your script with the WIP you mention? Cant wait to see how it ends up.

-TheElwolf

I found the problem.
The meshes like “Mesh.L2” and “Mesh.L3” weren’t loaded through libload.

It is necessary to load the “Scene” with LibLoad and after that the "Mesh"es with LibLoad.
Cause it’s not possible to load a file twice I’d sourced the “LOD-Meshes” (like *.L2 and *.L3) into a seperate .blend-file.

This works. Sometimes…

I will try something out in the next days to get everything stable.

@Z4ure: Sometimes the thread breaks and doesn’t run anymore. What could cause this problem?
Suddenly the meshes weren’t replaced anymore.

@iFlowProduction
I’m glad to see that you made it.
The thread breaks every time the LOD algorithm couldn’t do that what it was supposed to. So a small mistake in the object names or mesh names, can cause trouble.
Please check the console, maybe it will provide us some useful information. It will write out the entire debug message if you remove the try: except: break commands from lines: 55, 58, 59 from my script.
If you still can’t find the solution, please paste your console’s content here. :slight_smile:

I find the solution for LibLoad. :slight_smile:

Summary for everyone who wants to know:

  • LibLoad your .blend (e.g. “Szenario”) as “Scene”.
  • Every object, which should use LOD, needs the necessary properties.
    (Your object is called like you want, but it needs the correct mesh-name; e.g. “TESTOBJECT.L1”, which is a connection to the next steps…)
  • Next Steps:
  • LibLoad a .blend (e.g. “Szenario_LODs”) in “Mesh”-mode, which includes all meshes you want to use.
  • e.g. Meshes are:
  • “TESTOBJECT.L1”; Yes, you have to load it again! Otherwise you the script can’t switch to the original-mesh (“Scene”-Mode doesn’t load the mesh itself…)
  • “TESTOBJECT.L2” and
  • “TESTOBJECT.L3”

Notice: “Mesh” is not “Object”! The object-name is not important, the mesh-name is.

That’s all. :slight_smile:

New test .blend ??

Here’s a full Demo for using ZLOD with LibLoad.

For everyone who’s interested in.

ZLOD_vs_LibLoad_iFlowProduction.zip (1.12 MB)

Move with “W” and “S”.
!ATTENTION! Blender crashes after finish the GE.
Don’t know what’s wrong.
Think it’s an sort of libfree-bug.

Yes, only loading one file doesn’t cause the crash, but both are needed. :confused:

To your Idea:

Very nice! :slight_smile:
I’d such a idea with a console too, a while ago.
It could be very useful for develop and debug a game.

I would like to add an idea to “Run Console Command”:
There should be a function to send a message too (or a function to display messages).
E.g. “msg: #content

I would create each function as a module, which could be loaded into main loop and exist for itself.
E.g. Using the console-function without Z-Lod or other functions.

In Fact: I like your idea. :slight_smile:

Creative Gun sounds very interesting!!! Will this be all python scripts or somekind of addon?

Amazing work!

the link seems to be broken… could someone please upload newest working version again? :slight_smile: the first version crashes blender :confused:

The crashing on exit is because one of the threads is still running when you stop the main thread. You need to join the thread to the main thread before the engine exits to stop the crashes. Python doesn’t keep track of what threads to keep running and what threads to stop, you have to do that yourself, which is fair enough as it gives you more flexibility. You can either wait for the running to stop before you exit, or you join it to the main thread and it will safely close and remove it resources as the main thread stops.

Haven’t had a look at your script, but I was having similar issues with threading a while back, and managing the threads helped to stop this.

Another thing, which sometimes crashes blender, is the stopping the engine after you have called for a Lib to be loaded, but before it has been added to the scene. I don’t think this happens with the new async functionality in LibLoad, and I could never reproduce the fault, but thats another thing to consider if you are having problems with blender crashing as you exit the game engine.

i only played the demo as is, without modifying it. The demo starts and crashes blender as the camera reaches the models by itself, without me manually stopping the game engine… may be an issue with the newest version of blender? or my computer being sucky :stuck_out_tongue:

This looks pretty cool, I look forward to playing with it. The latest version link is broken, so I am playing with the original.

Sorry… i’ve posted a new link with minor fixes. (If anyone developed a better version, or fixed a bug, please post it here)

… I want to start a Google code project for this and for my Content Creator Pack concept! Since I’ve no time nowadays (Working on my game project) I would like to ask for volunteers, who help me to realize my concept, and raise the BGE to the level of commercial Game Engines, with features like: Real-time scripting, Prefabs (Upgraded group instances) Procedural LOD, Terrain… etc…

Everything above is possible in BGE, just need a kickstart and a central unit (like my multithreaded LOD) for centralizing and “recalculating” the logic.

Project Summary: Using the BGE, to develop an Advanced Game Engine.

very cool :slight_smile: new version still crashes my blender though… probably an issue with blender stopping python threads on OSX or something

Take a look at my terrain lod using logic bricks for inspiration if you like.It is in works in progress and game demos forum and the thread is terrain.

Multi-threaded does not mean multiple CPUs, however. Blender python can only run on a a single CPU even though you launch multiple threads.

Well, I’ve tried a stress test, and measured the actual BGE player’s CPU usage.
If I haven’t used my script, it used 25% of my quad core CPU … (so 1 core)
As soon as I started my script, It went up to 50%…

Hey folks,

I’d forgot to inform you, that the bug was fixed, which caused the crash with my LibLoad-Version of Z4urces Z-LOD system.
Link for the Demo-Files: ZLOD vs LibLoad

But with Kupomans Blender Build we don’t need it anymore I think.

It works now with newer Blender versions (r57599 and upper). :wink:

Greets