Hi everyone, here’s a little demo with fake(ish) frustum culling in python. It’s obviously not as good as doing it in source, but it gives a reasonable speed up. The landscapes split into sectors, and these are made invisible when outside the view.
Use the arrow keys to move around, X and C to turn fog on/off and A/Z to increase/decrease view distance.
I’ve kept the poly count high, and the codes pretty messy, so with optimizations it’ll run faster, but this should show it’s possible. I get 20 - 40 fps increase, which can’t be bad
Great way of culling, I even had a framerate of 55. That’s better then the person who released the last culling. (forest demo)
Btw, it should be awesome if you cooperate with the person who made Character AI, then you can create with each other a city (using your culling) with people (using test AI) THen we’ve got a awesome demo.
Nice saint_pill!!! Very simple the way it’s set up too I duplicated the sectors you had so there were 8 surrounding the ones you have already(total of approximately 320k faces) and it was still able to run at around 16fps!
Saint_pill, I tried to remake a blend with your technic of culling with python. I made a scene with some planes, camera, and an empty. I added sensor with script to the planes, and empty. But when I run the game, it doesn’t cull, so what did I wrong, and what do I have to add more? I’ve .blend of what I mean.
In your realtime buttons you have your 2 keyboard sensors setup…these have to be named to ‘up’ for A and ‘down’ for Z in your file(they’re named sensor1 and sensor2 in yours). Then you will see that your whole group of tiles will disappear when you run the game. Holding down A will make a few sqares visible in front of the camera.
Sorry, I was going to write a short explanation on how it worked when I got the first landscape in my game up and running, but thats taking some time so heres a quick fix…
…and Hush beat me to it…(thanks for saving me the effort :P)…but theres a few other things to change as well…
on the empty, change the values of “view_dist” and “tile_width” to match your scene - “view_dist” is the starting distance the camera can see and “tile_width” is the distance from the tiles centre point to the edge (I think it’s 6 in your .blend).
Also, the “always” sensors on the tiles should have both pulse modes OFF, they only need to trigger once when the scene starts.
And finally, at the bottom of the script is “if cam.view_dist < 30”, change 30 to match the maximum distance you want the camera to see.
I think thats everything, hopefully by the end of the week I’ll have a proper demo working with a cleaner version.
I chanced all the options liek you said, but nothin happens, it still doesn’t work. :x So I think I have to wait for your .blend file with the cleaner one.
Unfortunatelly it’s another proof that at actual state the Game Logic of Blender
is quite limitated.
We’ll need much more Logic Bricks to get a bit of the scripts power!
The landscapes not finished or setup very well, but I’ve commented the scripts so now it should be easier to use and see whats going on This is just so anyone can use it if it’s useful.
What’s not working, is it doing anything at all or what? Do you get any error messages in the console? I need more info if you want me to do something about it…
and that fog is just your basic mist, in the world settings (the blue/white button).
I tried applying the mist, with the exact same settings as you and it still won’t work. It’s in a third-person game with a sky sphere, but the mist is within the sky sphere the camera follows the player as a parent, abut the mist STILL WON’T WORK :x :x :x