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: 24th Apr 2007 14:48
Well the 3DW importer will be finished as soon as I get more time to work on it. I started it just before we started putting in our new building at work and ran a bit longer than I thought. Now the building project is taking up most of my time. The building project is planned to be finished in 2 to 3 weeks. It will be then unless I get a breather sometime before then. It is mostly finished but the terrain, as far as loading the worlds. Then all I have to do is work out the 3 grouping options I have planned and add .mesh support to the mesh loading.

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 26th May 2007 13:46
I've been trying to use this code for one of my projects but the results are pretty bad to say the least. Using your latest code and 6.6 / 6.6b all of my objects get prematurely culled and thus makes the game totally unplayable(as you can basically see nothing.)

It only seems to display objects which are close to the camera, especially when the camera is very low. Once I raise the camera substantially(10k units or so) all objects become invisible, these objects are on average around 200 - 1000 units in size so are not tiny. I'm using the default FOV, each object is setup using the object mode and not per limb. I tried updating using spheres, cubes and boxes but all return the same results. At first I thought this was due to the camera angle being so drastic(top down) but this isn't a case as it still happens when flat.

So is there some issue with 6.6? did I mess something up? your demo example works fine on my PC however, I guess it's because the demo uses DBP primitives and maybe you haven't tested with .x / .dbo models?

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 27th May 2007 09:56
Sorry I haven't had time to do any coding as of late. This code has been tested with several different .x, .dbo, and DBP memblock mesh made objects and works great here. It is very possible however that it is some kind of internal offset in your model or code that is causing the conflicts. If you will send me one of the models (model file only I don't need textures) I'll check it out this weekend. I may need to modify the code a bit.

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 27th May 2007 12:52
Try this.

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 May 2007 13:54 Edited at: 11th Jun 2007 14:01
Indeed it seems to be something messed up in the distance from camera calcs. It only does it when the object is in the very center of the screen here and the camera range affects this. I'll see what I can find this after noon.

Also you can remove the far plane (camera distance) checks if you want for now. In the for next p = 0 to 5 loops of the sphere/box/cube in frustum function add a check to only run if p <> 4. Then the camera range won't matter.

[Edit] Found bug with placement of projection matrix code. You have to call it after changing the camera range. It was accidently moved when cleaning up the code a bit. New code in first post.

Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 11th Aug 2007 14:21 Edited at: 11th Aug 2007 14:26
Sorry for bumbing..

But hey Cash Curtis II. Could i get that DLL version of this ?

And also i got proplems..

Does this only work with dbo objects? Cuz i tried this with 3 diffrent objects.. Plants, Trees , Rocks and only Trees worked (Wich was dbo object) andother objects crashed.

Thank you..

//Edit

Converted my objects to dbo.. Still seems not to work.. It crashes..

If you want one of objects what crashes i can send it.

[center]
DarkBIBLE Wikipedia for TGC Users!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 11th Aug 2007 14:29
Seems to work with all of my objects here. If you send me an example I will try to find time to investigate it and fix it if need be. Also it is worth mentioning that stuff like trees, plants, and rocks should be ran on object culling instead of limb culling since they are relatively small in size and low in limb count anyway.

Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 11th Aug 2007 14:51 Edited at: 11th Aug 2007 15:14
Yes im using both object and this culling and FPS increased even more.. This is just awesome!

I filled whole my 3dws terrain with trees and fps was steady 32.

And when my friend tested FPS was over 100 whole time..

I cant afford example now.. But i can send one of those models what crashes!

//Edit

I noticed that when i putted trees what had frustrum culling on.. Dint drop fps at all.. And when i putted few of those grass objects what i sent to you decreased fps noticably.. (They dint have frustrum cuz they crassed)

[center]
DarkBIBLE Wikipedia for TGC Users!

Attachments

Login to view attachments
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 11th Aug 2007 21:31
Sorry for being so stupid, but what is this exactly, how does it work, and how do I implement it into a game?

I searched the thread, I couldn't find much info to answer those questions.

Again, sorry.

Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 11th Aug 2007 21:46
Just put the correct variables types and dims on your program.. Then put the functions.. And use Setup_Cull or whatever the function was called for those objects you want to be culled..

Basically culling means that it hides those things what arent on view from render so it basically speeds up your game

[center]
DarkBIBLE Wikipedia for TGC Users!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 12th Aug 2007 11:43
It seesms to work fine here with no crash on that object. Here is my test code:



However you will not notice a fps gain really with objects of this type from limb culling as it is low limb count and low poly. Plus since it is not animated, DBP culls the object itself. If it were animated you could use the optional object culling flag in this function instead of 0: setup_Cull_obj( num_Objs-1, 1 )

This type of culling is really for objects that have either a high limb count with medium number of polys per limb (such as an object that is a group of those rocks and maybe a little higher polys count per rock), or a medium limb number count with a high number of polys per limb (such as advanced terrain). For instance run this code and press 0 to turn off limb culling when it starts up. You'll notice the FPS drop alot (to about 137 here) no matter where you are if any part of any rock is on screen as DBP only culls the object as a whole. Now press either 1, 2, or 3 for culling by limbs. If all the rocks are on screen the FPS will actually drop by a few (to about 134 here) because the culling is running but not hiding anything. Now move around and watch the FPS raise and lower as the rocks are off screen while others are on screen. With only 1 rock on screen I get 80 polys at 345fps with any of the 3 culling types vs the 137fps with native DBP culling. I get 365 fps with culling wither on or off with no rocks on screen. Test code:



Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 12th Aug 2007 12:42
ok i used the obect culling for rocks and plants and it worked fine Thanks.. Trees are med poly with high limb count so i use limb culling for them and fps increased pretty much

[center]
DarkBIBLE Wikipedia for TGC Users!

Login to post a reply

Server time is: 2024-11-22 23:35:03
Your offset time is: 2024-11-22 23:35:03