Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Frustum Culling ported to DBP

Author
Message
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 18th Dec 2005 02:09 Edited at: 1st May 2009 22:01
[Edit] Fixed a few things reported 4-27-2009

I have a frustum culling code that will tell you if a sphere, box, or cube is on screen. No matter what the rotation or position of the camera. It requires this plugin to compile (for more accurate timing only).

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18 for acurate time testing (can be removed with no culling effects)

[edit] Code now has both whole object or limb culling flag and now no longer needs the DKShop plugin for DBP U6.6 and up.





I'll leave it up to you to decide which test to use and make the bounding containers. The sphere testing is the fastest between it and box. The sphere test also returns the distance of the sphere from the camera lense if it is on screen. I'll add comments later.

Any bugs let me know.

x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 18th Dec 2005 05:25 Edited at: 18th Dec 2005 05:32
Quote: "I have a frustum culling code that will tell you if a sphere, box, or point is on screen"


I apologize for my ignorance. I infact had to take the time to study "Frustum Culling" to understand what it even is. ( http://www.flipcode.com/articles/article_frustumculling.shtml for anyone else looking for a 101 on Frustum Culling) What is ment by "point". Will I be able to use your code to exclude my .x obj's

[edit] I now understand what was ment by "point"

- Do it, Do it Right, Do it right now..
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 18th Dec 2005 05:42
Yeah this is useless for whole objects really as DBP already does frustum culling on them already. You can use this to hide limbs of objects though. In DBP if any 1 part of an object is on screen it draws every poly and every limb of the object You can use the functions at the bottom to tell if a 3D point, sphere, or box is inside the camera's view. You can enclose the limb in a sphere or box (use code, there is no need to make sphere or box objects) and if the sphere or box isn't in the camera view then hide that limb else show it. I have yet to make a demo for this but it is coming. This is probably how they are doing the update terrain function in advanced terrain.

x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 18th Dec 2005 05:51 Edited at: 18th Dec 2005 06:15
Quote: "Yeah this is useless for whole objects really as DBP already does frustum culling on them already. You can use this to hide limbs of objects though"


I may be wrong, but it has been my experience that DBP doesnt do its own Frustum Culling, if my understanding that, frustum culling is that which is in cone view, keyword being "view". Example? In my current engine, I have a very sizable dungeon,roughly 10k polys that is positioned to the players immediate right but roughly 3k units away and very out of site(read: not on screen). Now, should I face left, my fps remains the same. face forward or backward? again the same. Face to the right where the dungeon is but out of site, my fps plummets to near 14fps from 70.

- Do it, Do it Right, Do it right now..
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 18th Dec 2005 07:52 Edited at: 7th Apr 2006 13:52
Well DBP's is flawed in some cases. Like I said if any part of the model in in the cameras view, it draws the entire thing. Even if it's just an offset (which is odd and only on some models), it doesn't even have to be a poly. Say you have a model with all of the polys offset to make a 10 by 10 by 10 box to be positioned at 1000, 1000, 1000 but the object's position is 0,0,0. DBP seems to make a 1010, 1010, 1010, box for the frustum check instead of a 10, 10, 10 box. So I guess in some cases you could use this for objects as well. I'll have to get a demo going lol.

[edit] It seems the offset bug may be fixed in 5.9 Here is a code showing DBP's frustum culling working on objects.



Just rotate the camera around and watch the number of polys raise and lower depending on the number of objects in sight.

[edit] Here is my code culling limbs. there is no culling unless you press the return key so you can see the difference. It would be way faster if I had an octree setup.

[edit2] And here it is a little faster but not much due to optimizing the get frustum code.



[edit3] I had no idea that the limb position commands were so slow. Save the limb positions to an array before the loop and use the array instead and the culling code is 8 times faster



Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 10th Apr 2006 11:14 Edited at: 11th Apr 2006 15:29
[edit] I edited the last code snippet to correct my code. I was using diam instead of rad for the sizes. I need to stop coding sleepy.

Here it is working on advanced terrain.

For those who don't have the advanced terrain help files and example:
http://www.mapmasterz.com/lit/FullTerrFrustCull.zip

For those who do have the advanced terrain help files and example:
http://www.mapmasterz.com/lit/FrustTerrainCull.zip

I'll clean the code up/ make it more portable and repost when I get time.

[edit] Here is the code that is alot more portable and also save 2 distance checks when getting the frustum data.



Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 11th Apr 2006 03:04
Nice code! And thanks for the tip about limb positions (although im trying not to use limbs anymore :p ).

All you need is zeal
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 12th Apr 2006 05:52
In that last code I posted, the box testing is just as fast and efficient as the Advanced terrains Update Terrain function. You can use keys 1,2,3, and 4 to change between culling modes.

Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 12th Apr 2006 19:59
wow, very impressive . Wonder if it will work as well with constructed dbo levels from 3dws. Haven't really made anything big enough that drains fps to a stupidly low number without culling... yet
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 13th Apr 2006 00:04 Edited at: 13th Apr 2006 13:57
I'm working on a tree system that should help with objects like that (for the free engine) if I can ever get time to work on it.

[edit] As long as your model has 2048 limbs total this should work pretty good. 4096 is pushing it (takes 8ms for total culling) and depending on your layout you won't really see much speed increase. If I can get a all purpose tree working it should help.

[edit2] Corrected several, several typos and missing code in the code that messed up the portablity of the code, yet it worked in the example lol. I have really got to get caught up on my sleep.

[edit3] Now supports movable objects, but still no rotations so use sphere's or cubes for them.

New code:


Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 21st Apr 2006 09:09 Edited at: 21st Apr 2006 09:09
This is looking great!!! I tried [Edit 3] with the boxes. It's a simple increase of FPS. I can't wait to implement this. My lightmapped buildings won't cause a time warp when you step into them now.

Is it too early for me to put it in? Anything that my dull mind isn't quite comprehending yet?

I guess the proper implementation of this would be to only cull buildings that are on the screen. I wouldn't even need to do it every program loop, I could probably set it to a timer to reduce overhead. I don't think I'd use it for any moveable objects, just my buildings.

Very, very nice.

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 21st Apr 2006 11:32
Thx. Right now sphere testing is the fastest. Even though it is the least accurate. You'll have to play with them to see what's best for you. Box testing is the best for advanced terrain, though sphere is best for my free engine. I plan on making this even better as soon as I get more time. Once I have all the dirty work done, I want someone with ASM and c++ to make a plugin out of it (they can sell it if they like and I'll even buy it).

Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 16th May 2006 18:47
Awesome work LiT definately will be using this

Theme park simulator wip boards

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 22nd May 2006 18:11
Quote: "Once I have all the dirty work done, I want someone with ASM and c++ to make a plugin out of it (they can sell it if they like and I'll even buy it)."

Get ahold of Sparky... Maybe they can include it in the upcoming GameFX Dll and throw some loot your way...



Come see the WIP!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 22nd May 2006 23:18
Just found out the new universe commands do portals which act similar to frustum and occlusion culling at the same time. So all this work may be for nothing

I'm still gonna finish it though (getting close now). If the universe commands get documented/ finished and it does this, If I disappear and yall don't hear from me a while, and Lee disappears. Yall will know what happened

Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 23rd May 2006 04:31
The work is never for nothing Its a brilliant piece of code that will up frame rates by a huge amount.

I expect tgc are going to charge for the new universe commands (which should be in dbpro by default in the first place) So the code will be useful to those who will not beable to afford it
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 23rd May 2006 06:10 Edited at: 30th May 2006 16:16
Yeah could be. The universe commands are still in U6 though, just not documented and are limited. I will be finishing this. It just may take a couple more days. Even though I am close I can only work on it an hour or so each night. I have alot of things going on ATM lol.

[edit] Thats what I hate about TGC. You find something that DBP really needs and wait and wait and wait. Then when you finally get tired of waiting and do it yourself ... bam they put something like it into DBP And even worse undocumented, so it's like torture waiting.

[edit2] Still working on an all purpose tree, but this pre-sphere test speeds up box and cube testing by 50%. You can't tell the difference here as there are only 289 limbs with polys around 450 each. If there were 1000 limbs at 131 polys each it is way faster. Made a big difference in my Inca Pro tests.



Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 31st Aug 2006 12:59 Edited at: 31st Aug 2006 13:25
Slight update (also changing first post)

Code is now more portable and faster (about 15-20 times faster on my machine). It takes a while to load as it makes an object with 4096 limbs. It takes between 1 and 8ms depending on camera position and direction on my machine. Framerate was 28 with no culling and from 28-77 with the culling depending on camera position and direction. I still haven't added any trees in yet as everything I add is slower with DBP's speed. Stuff surrounded by the `****************************************************************************
`****************************************************************************
is the actual culling code.

It requires these 2 plugin sets to compile.

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18 for acurate time testing (can be removed with no culling effects)

http://forum.thegamecreators.com/?m=forum_view&t=67196&b=5 for actual culling



Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 11th Sep 2006 19:18
Code has been modified to allow both limb and object culling since DBP doesn't cull animated objects. New flag is used when calling setup_Cull_obj(). Use 0 for limb culling and 1 for object culling.



FXTC
20
Years of Service
User Offline
Joined: 3rd Jul 2004
Location: CzechRepublic
Posted: 12th Oct 2006 11:59 Edited at: 12th Oct 2006 12:02
Nice code LIT
level exported from CShop 4.1 works good,but level exported from 3DWS not
I thing problem is with exported DBO format and limb position,
look:
http://forum.thegamecreators.com/xt/xt_apollo_download.php?i=1021074

AMD 2,4 512MB RAM,2x200GB hdd,GforceFX5700GT128MB,IBM21"

Attachments

Login to view attachments
FXTC
20
Years of Service
User Offline
Joined: 3rd Jul 2004
Location: CzechRepublic
Posted: 12th Oct 2006 12:47 Edited at: 12th Oct 2006 12:53
Test level exported from CShop 4.1 to *.x works good
http://forum.thegamecreators.com/xt/xt_apollo_download.php?i=1021085

AMD 2,4 512MB RAM,2x200GB hdd,GforceFX5700GT128MB,IBM21"

Attachments

Login to view attachments
FXTC
20
Years of Service
User Offline
Joined: 3rd Jul 2004
Location: CzechRepublic
Posted: 12th Oct 2006 15:58 Edited at: 12th Oct 2006 15:59
test with level exported from 3D max(use panda X exporter):
http://forum.thegamecreators.com/xt/xt_apollo_download.php?i=1021157

AMD 2,4 512MB RAM,2x200GB hdd,GforceFX5700GT128MB,IBM21"

Attachments

Login to view attachments
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 13th Oct 2006 00:10 Edited at: 13th Oct 2006 12:39
I'll check it again when I get home, but it seems to be working fine last time I tested it with the Inca Pro demo. I'll test it in about 12 hours or so.

[edit] Works here with the inca levels when code added to the inca pro demo. If you can send me the code and media showing that, I can check it out. The code works for all of my levels with the exception of 1 level from the csm importer that has one rogue limb that won't cull properly. APEX is changing back to DevC++ for the next update to resolve this I believe. Also I edited my forst post to show the latest changes as I forgot to earlier. This may fix it for you as well.

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 9th Nov 2006 05:14 Edited at: 9th Nov 2006 05:27
Hey LiT, sorry it took me so long to get to this fabulous code. I'm using it now, and it's amazing.

I disabled culling unless I got an integer value movement of position or angle.

I started out with 60 FPS, I get 155 moving and 200 resting FPS with sphere checking. Simply amazing stuff, thank you =)


Come see the WIP!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 9th Nov 2006 11:38 Edited at: 9th Nov 2006 11:41
@FXTC Did you even send an example level? My email might have ate it 0_o

@Cash Thx man glad you could use it.

dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 5th Mar 2007 03:15
@LiT
This is awesome just got it to work in my game.

AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 5th Mar 2007 09:24
Cool man, glad you could use it. If you find any bugs let me know. After the next DBP update I should be able to do it with just native DBP commands

dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 5th Mar 2007 22:50
@LiT
Quote: "
After the next DBP update I should be able to do it with just native DBP commands
"


is there a place where you get info from

AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 21st Mar 2007 22:04
As of DBP 6.6 you no longer need the DKShop plugin for this. Just replace the first part of the extract frustum gosub with this:



Notice the new command Get Matrix4 Element( m4num, elemnum )

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 25th Mar 2007 07:41 Edited at: 27th Mar 2007 03:51
Hey LiT I sent an e-mail to your mapmasterz.com address.


Come see the WIP!

Attachments

Login to view attachments
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 25th Mar 2007 10:01
Email recieved and reply sent, but part of the email didn't copy right.

I don't know if the culling is fixed in U6.6 yet since I use my culling code for everything. I'll try a few tests later.

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 27th Mar 2007 04:04 Edited at: 27th Mar 2007 04:25
Hey, my initial plugin tests are looking very nice. I've gotten an instant FPS boost.

This one is the DBP version...


And this is the plugin version...


Both of these examples are running at 800x800x16 in windowed mode.

The problem at the moment is that I'm having to manually calculate and pass the matrix4 element data to the function as a bunch of parameters. This requires me to recast all 16 numbers from integers to floats every loop. After I get this issue resolved, we should see another big speed increase.

Right now I've got two commands...
Quote: "null=CC_SetupCullObj(obj, 0)"

And I have the "CC_UpdateCull" command. However, because of the 3D math limitation, I have encapsulated it into an ugly little function...



So, I have to fix the 3D math problem and change it to use DBP6.6 whenever they get the fixed version out. Plus, I'm going to add an optional save/load feature to "CC_SetupCullObj" that will allow you to save the limb data to a file so you don't have to recalculate it.

I'm also going to add some feedback commands, so that you can access some of the important variables and arrays.

Hopefully I have this resolved in a couple of days. Until then!!


Come see the WIP!

Attachments

Login to view attachments
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 27th Mar 2007 14:28 Edited at: 27th Mar 2007 14:33
Looking great I have never used PB before, but what if you just made the Clip array gobal and just used it in your function instead of having to pass each element in as a parameter?

[edit] NM I didn't think about you possibly not being able to call the DKShop plugin command from your PB plugin. Also I have the money to buy PB and The Plugin to use it with DBP. I could go ahead and buy it if you think I could help you with anything, if not I'll wait until next Feb to buy it when I do my yearly software purchases.

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 27th Mar 2007 14:50 Edited at: 27th Mar 2007 14:52
I'm almost completely done. Every bit of code has been ported over and works great. I can call DKShop commands in PB as well.

The only problem I'm having is the any time I use a 3D math command it crashes the DLL. So, I have to do all of that in DBP and pass the results to the plugin. As soon as that is fixed I can put every bit of it inside the plugin.

Also, I don't have access to variables in DBP, only what I pass back and forth. It's a temporary solution, because I wanted to get the main body of code working. Freddix is looking at it right now.

I'd recommend getting PB and the PurePlugin anyway, but this is essentially completely finished. I wouldn't sweat it, and I'll get you the plugin as soon as it's ready.


Come see the WIP!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 27th Mar 2007 14:53
Cool. Another option you have, though a little longer code wise would be to use an undoccumented DBP command:



And use the pointer to get your values from that.

Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 27th Mar 2007 15:29
It is good to see this is being ported to a plugin. I actually came back to have another look at this thread because I was considering doing the same thing. This is a useful and necessary addition to DBpro.
So...
I haven't really looked through the code. Do limbs cull when they are behind other obstructions, or is this just for culling them when they go off screen?

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 27th Mar 2007 15:58
Just out of the camera's viewport/ frustum. Occlusion culling in DBP code would be insanity without CSG geometry and even then it would be terribly slow. Or at least all the tests I have come up with were. When I get PB and PurePlugin I'll see what I can come up with though for CSG geometry and terrains since they can easily be converted to CSG geometry in almost every case.

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 27th Mar 2007 16:42
I don't see occlusion working AT ALL with normal objects However, like LiT is saying, with CSG it is definitely a possibility. With the 3DWS importer he is working on, that is a definite and exicting possibility.

Just so everyone following this knows, LiT and myself discussed the limb culling code tonight. Basically, any way that we access the numbers from DBP will require type casting. The way we're doing it now is very fast. If we were type casting 16 integers to floats each loop with DBP code we'd get about 4 FPS. This issue will be resolved as soon as Freddix figures out what's up with the 3D Math commands. Then it will be totally encapsulated and invisible.


Come see the WIP!
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 27th Mar 2007 18:49
Quote: "I don't see occlusion working AT ALL with normal objects"


I do have some ideas that *might* work. When I get some time, I'll do some testing to see if it is at all feasible. If so, I'll talk to you guys about it. If you get proper frustrum culling with some occlusion working, it could probably be turned into an official TGC addon.

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 27th Mar 2007 23:50
The only way I have gotten occlusion culling to work on normal objects was to convert 3d to 2d and use a nasty sorting routine. It didn't work all the time though since DBP doesn't give us surface access and some limbs have multiple seperated meshes. This messed up the 3d to 2d conversion since some of the surfaces in the limbs had different z depths. Part of it could be in front of the camera and part of it behind it which messed up the frustum elliminatioon of polys. In any case this was so slow it isn't even funny. As Cash said with the 3dws levels it is quite possible in the form of a plugin, which is what I am hoping for. Time will tell. I got the terrains partially loading from 3DWS I just have to get the layer blending worked out properly. The rest of the geometry (brushes, lightmaps and meshs) is loading great already. Once terrain is done I will be doing the entity and groups setups. Then I will optimize the loader since for now it is thrown together as I only get to work on it a few minutes a night.

I think TGC's Game FX's plugin could beat us to the puch though if they could make their world commands work for more than one object.

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 28th Mar 2007 19:43 Edited at: 28th Mar 2007 19:46
I still can't directly access the matrix4 elements in the plugin. Annoying, but it will be fixed soon enough. In the interest of making it work in the mean time, I've done what you recommended and used the magical command "make memblock from array". It is very straightforward, the data is stored in increments of the datatype.

I've gained 2 FPS now, 108 fps. Not a huge increase, but nice nonetheless.

My current problem is that the command "DK Get Matrix4 Element" returns double floats. In order to cast from double float to float takes approximately 10x longer than it does to directly assign a float to a float. Fortunately, it is still fast.

In order to recast 16 double floats to floats in my above example takes around 0.0008 ms. If I didn't have to recast it would take about 0.00008 ms. Since they're so close I'll leave it as is until Freddix adds the ability for Pureplugin to accept double floats. I doubt I'd get any real speed increase at all.

The nice thing is that I just pass the memblock number rather than 16 stupid parameters. Very nice, thanks for the heads up

I know that this type of culling has limited applications in most situations. However, for Geisha House (and any overhead view game) it will do wonders.


Come see the WIP!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 28th Mar 2007 23:57
Cool man. I should be getting PB and PurePlugin very soon

Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 29th Mar 2007 15:53
Just to let you know, you guys are probably correct about the occulsion checking. The idea that I had probably wouldn't work very well. I do have some other ideas too, but I don't have the time to ivestigate them much right now.
Good luck with this! I think it is a very useful addition to DBpro!

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 30th Mar 2007 07:11 Edited at: 30th Mar 2007 10:17
It depends on how you do it I suppose. If you calculate the limb dimensions as boxes then you could perform the occlusion culling in the same manner as CSG with the limbs.

I finished the save and load feature!!! In order to calculate the limb data for the cube example, 4096 limbs (the DBO file is almost 6mb!!!) it takes about 19 seconds. When you load that same data back in, it only takes 330 ms to do so. The plugin is also running faster for me, around 117 fps with that same example.

I set it up so that it's fairly easy to make happen. I've got an optional initialization command. If you don't use it, then the plugin will use default values for the memblock and vectors. Or, you can assign them with the init command.


The setup_Cull_obj takes a new parameter, the filename. You can use "" and it will skip the file. If you specify a filename and it doesn't exist, it will create the file. If you specify a filename and it does exist then it will load it. I considered new commands to rebuild the data, etc., but this method seems the easiest to me. You don't have to change any code and it will simply work the next go-around.

I'll package it up for you and send it for you to test. I included a good amount of error checking and helpful error messages, but I'm sure something still isn't quite right.

[Edit]
I finally finished the plugin. Writing help and ini files is a real bitch. I'm sure that they're vague and sketchy in areas, let me know what's wrong and I'll fix them up. I included three demos, an improved animation demo, a culling demo, and a math demo. The math demo is a benchmark example of my replacement ABS() functions.


Come see the WIP!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 31st Mar 2007 14:36
Well Done Cash, this plugin is just a shade slower (6% appx) than the Advanced terrains update function I ran a few tests and the Update terrain takes .0067ms and yours took 0.00715ms You can't tell any FPS difference and it only took 1.1ms to cull 4096 limbs vs my DBP code's 11.2ms. So it's about 10 times faster than mine. Also it loads faster and you can save the data for loading even faster. Great job man.

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 1st Apr 2007 09:12
Glad you like it After the 4096 limbs took 19 seconds to calculate, I figured a save file was necessary. I was really surprised at how fast it loads back in. Do you like how it is handled? Right now if the limbs don't match then it gives an error and bails out, not adding the object to the culling queue at all. I should probably make it rebuild the limb file automatically if it doesn't match. I can't think of an advantage of having it not rebuild the file automatically.

One other annoying thing I just noticed when I added the save feature to Geisha House was that it won't save in a folder. I'll fix that too.

I'm really glad that it runs fast. That certainly is the most important thing.


Come see the WIP!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 1st Apr 2007 09:48
Yeah man I'm loving it.

Quote: "I should probably make it rebuild the limb file automatically if it doesn't match. I can't think of an advantage of having it not rebuild the file automatically."


Maybe a flag or something. It could be possible to accidently use the file on the wrong object (2 objects with accidently the same file name). I personally would rather it bail out or give me an error message. This way if you have 2 objects and accidently specify the same file name it won't act up.

After I finish the 3dw importer I am going to have a quick recoding of my code to add the 2 new culling fields I mentioned to you and change it from having the same culling type on all objects to specifying which type you want on each object when entering it. I just went with the universal mode so the users could toggle through quickly and try out the speeds. This would also save on the file size in the saving since cube and sphere testing requires less data than box. And sphere needs less than both since cube uses sphere and cube testing. Though it won't save but 4 to 8 bytes or so per limb probably.

I could possibly even come up with a faster way to get the data calculated in the first place since I never really tried benchmarking other methods.

Olby
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 20th Apr 2007 16:06
@Cash Curtis II - So hows going on porting culling code to a dll side?

AMD Sempron 1.8+ Ghz, 512MB Ram, ATI R9550 256MB Ram, Sound Blaster Live!, WinXP Pro SP2, DirectX 9.0c (Feb2007), DBPro 6.6b
http://www.myspace.com/producerolby
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 23rd Apr 2007 17:47
It's done. I'm just hoping to include the 3DW importer for a more complete package.


Come see the WIP!
Olby
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 23rd Apr 2007 18:10
Any ETA on release date then ?

AMD Sempron 1.8+ Ghz, 512MB Ram, ATI R9550 256MB Ram, Sound Blaster Live!, WinXP Pro SP2, DirectX 9.0c (Feb2007), DBPro 6.6b
http://www.myspace.com/producerolby

Login to post a reply

Server time is: 2024-11-22 19:16:10
Your offset time is: 2024-11-22 19:16:10