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.

Work in Progress / Real-time Occlusion Culling

Author
Message
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 12:52 Edited at: 7th Jan 2012 12:50


What is Dark Occlusion?
Dark Occlusion is a real-time occlusion culling library for DarkBASIC Pro. It hides all the objects that aren't visible to the camera to speed up the render process, resulting in a higher framerate.

Features
Object/Limb occlusion
Auto-updated dynamic objects
Fast object setup
Auto-creation of low-poly bounding models
Multi-threaded for maximum use of multi-core pc's
Fast and unlimited levels of detail

Command list


Demo
Demo attached!

Screenshots
10,000 houses, 14.5 Million polygons


Off (1 fps, 13.961.115 polygons):


On (87 fps, 22.164 polygons):



1,000 houses
Off (19 fps, 1.401.284 plygons):


On (755 fps, 4.929 polygons):


Attachments

Login to view attachments
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 3rd Jun 2011 15:14 Edited at: 3rd Jun 2011 15:35
So are you going to release the code? Or a Plugin? Or neither and you're just going to use it for a game you're working on?
Either way, looks extremely handy (and I'd have no idea how to implement something like that in a way that actually speeds up the rendering), I'll try out the demo later.


Edit: I just tried it out, but seemingly the culling doesn't work here. When I turn it on I see nothing but grass. The frame rates however are just as you said, ~12 without culling and ~150 otherwise. So it seems to be doing what it's supposed to do, more or less, it just doesn't show me the results.

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 15:44
I'm planning on releasing it along with a game engine i'm working on. I think the first beta will come out in about 1-2 months.
For the culling... I have no idea why the buildings won't show up, i'll have a look at it
Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2011 16:21
Can you compile the demo with the newest dbpro beta? It doesn't work on Windows 7 with sp1

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 16:41
@Mr Kohlenstoff
The visible object id's are now printed to the screen. If you can download and run it again to see if there are any id's printed it will be easier to track down the problem.

@Brendy boy
Recompiled it

see first post.

btw when do my posts no longer need approval, it's getting kinda irritating
Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2011 16:58
without occlusion: 10
with occlusion: 200

But, i don't see any object but grass when occlusion is on.
And the grass looks weird. When i walk or turn around the grass looks like it's texture is shaking, the texture is fuzzy

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 17:01 Edited at: 3rd Jun 2011 17:03
weird... did it say any objects were visible?
Can you post a screenshot? Maybe I can figure out why the buildings won't show if I can see the problem.
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 3rd Jun 2011 17:26 Edited at: 3rd Jun 2011 17:27
http://img850.imageshack.us/img850/9015/cullingscreenshot.png

It doesn't say anything regarding visible objects. So I assume there aren't any? Or maybe something wen't wrong with the upload of the new version, who knows.

By the way, I'm having the same issues with the grass. Looks like maybe there are several grass textured objects at the same height resulting in these strange artifacts everytime the view is changing. (this problem exists all the time, not just when the culling is active)

Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2011 17:26 Edited at: 3rd Jun 2011 17:28
Quote: "did it say any objects were visible?"

no

Quote: "Can you post a screenshot?"

i get the same as Mr Kohlenstoff

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 17:30 Edited at: 3rd Jun 2011 17:38
You can press the returnkey to take a screenshot

For what I can see in the screenshot it loads the grass instead of the buildings, if you can take a screenshot of the updated demo I can make a better guess
edit
since there are only 2 polygons, I think that's not the problem...
edit
what is the amount of polygons in the screen when the culling is off, if the model didn't load correctly it would be the wrong amount.
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 3rd Jun 2011 17:38 Edited at: 3rd Jun 2011 17:39
Are you sure you updated the Download? Both versions say that the exe file has been last updated at the exact same time. Well maybe I did something wrong, but I wouldn't know what.

Are you using any shaders? And how are you handling the grass, is it a plain, a matrix or what?


When culling is off, I get ~4 million polygons, and I can see the buildings as well. They just disappear as soon as I press 1.

Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2011 17:39 Edited at: 3rd Jun 2011 17:41
Quote: "if you can take a screenshot of the updated demo I can make a better guess "


without


with


Attachments

Login to view attachments
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 17:40
The grass is just a large plain with a grass texture, and no shaders are used, just darkBasic only.
Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2011 17:40

Attachments

Login to view attachments
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 17:43 Edited at: 3rd Jun 2011 17:45
I'm already closer to an answer... when the culling is off, does the grass look good then? and what screen resolution do you guys have, it wont be the problem but it can help.
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 17:46
I'll make a little debugger to test if the problem is what I think it is.
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 3rd Jun 2011 17:53
For me the grass looks the same way no matter if the culling is on or off. And my screen resolution is 1280x800.

Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2011 17:55 Edited at: 3rd Jun 2011 17:55
Quote: "For me the grass looks the same way no matter if the culling is on or off."

the same with me. Resolution: 1366x768

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 17:57 Edited at: 3rd Jun 2011 18:04
I think it is a problem with the low-poly culling object or with the visibility calculation.
The debugger is almost finished.
edit
the debugger is finished, just replace the old exe with the new one, start the program make sure the occlusion is on then press the backspace. The program will create a debug.txt file and exits. If you can upload the debug file I can see where the error is (hopefully)

Attachments

Login to view attachments
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 18:27
I think I have the solution for the problem, but I have to see the result in the debug file to be sure.
Jimmy
19
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 3rd Jun 2011 19:05
The demo in your original post works fine for me.

Results:
13-16 FPS with culling off
100-120 FPS with culling on


May 10th / Jerico2day-OBese87 / VOTE NOW
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 19:20
I'm glad to hear that it is working
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 3rd Jun 2011 19:26
Debug file attached.

Attachments

Login to view attachments
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 19:33
accoarding to the debug file everything works fine... is it running in 32 bit mode?
it's the only thing I can think off now
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 3rd Jun 2011 20:11
Quote: "accoarding to the debug file everything works fine... is it running in 32 bit mode? "


I think so. At least my system is running with 32 bit.

Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2011 20:48
i have windows 7 64bit

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 3rd Jun 2011 21:06 Edited at: 3rd Jun 2011 21:07
64 bit shouldn't be a problem.
I almost figured out what the problem is. I have attached a new exe with some extra debug info.
Make sure to check the numbers after object index they should be >0.
The grass is removed to make sure that wasn't a problem.
If it still isn't working try moving close to a wall, turning culling off and press space. It will recalculate the quality of the culling.
edit
also decreased the amount of buildings to make sure it isn't a problem with a small amount of memory or something similar.

Attachments

Login to view attachments
Red Eye
14
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 3rd Jun 2011 21:43
Can you tell use the system? Because alot of people did it with Raycasting but it makes it run very slow on big scenes. Or did you do it like Umbra?

Sounds great anyway. Testing beta...

Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2011 22:10
still doesn't work

Quote: "If it still isn't working try moving close to a wall, turning culling off and press space. It will recalculate the quality of the culling."

i did. I got the following error: runtime error 1002: Bitmap does not exist at line 498

Quote: "Make sure to check the numbers after object index they should be >0."

all numbers are negative

Uncle Sam
17
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 3rd Jun 2011 22:38
Great work! I got around 20 fps with culling off, but 90-120 with it on. You, my good sir, are a genius. Well done!
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 4th Jun 2011 09:08
Quote: "all numbers are negative"


In my case they're all -1677721, to be exact. That's -0.1*2^24 (2^24 = 16777216).

Oh, and I just realize, I can't start the newest exe anymore. It opens, then seemingly sets window on and of 20 times within some seconds, then minimizes itself and as soon as I open it I get a windows error. Same for the second version.
Furthermore, everytime I ran any of the exes, my complete desktop got rearranged. Not sure what's going on there, but it brings them in pretty senseless orders that don't make any sense to me.

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 4th Jun 2011 11:59 Edited at: 4th Jun 2011 12:22
Quote: "Furthermore, everytime I ran any of the exes, my complete desktop got rearranged"

Fixed that.

Quote: "You, my good sir, are a genius. Well done! "

Thanks

Quote: "In my case they're all -1677721, to be exact. That's -0.1*2^24 (2^24 = 16777216)."

I know where the error is now...

Quote: "all numbers are negative"

are they all -1677721 to?

new exe attached, everything sould work now... I hope

edit
@Red Eye
I dont know much about Umbra but as far as I know it calculates the data for culling in the editor and uses that data in the game for culling. My system works at real-time so adding/removing objects from the system can be done at runtime as well.
And for large scenes.. GTA style scenes/games should work greath using this, but the larger the scene the less improvemend you get. I'm still working on optimizing that so verry large scenes are supported, I already have an idea on how to achieve it.

Attachments

Login to view attachments
Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Jun 2011 13:06
Quote: "are they all -1677721 to?"

no, they are all different negative numbers
I wanted to take a screenshot to show you here but every time a press space i get an error on line 502: image doesn't exist

Quote: "new exe attached, everything should work now... I hope"

it doesn't work

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 4th Jun 2011 13:13 Edited at: 4th Jun 2011 13:17
Quote: "no, they are all different negative numbers"

are they around -500?

Quote: "i get an error on line 502: image doesn't exist"

Quote: "runtime error 1002: Bitmap does not exist at line 498"

these errors are really weird since it is only creating things here, the program isn't doing anything with them.

edit
I should have done this before, but here is a list with controls:
Returnkey: take screenshot
Space: Recalculate occlusion quality, make sure a building is filling the whole screen.
WASD: move
Mouse: look
Backspace: Create debug file and exit.
Shift: Move faster
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 4th Jun 2011 13:36
Strange things are happening here. The new version doesn't work either. I had to start it like 10 times until it finally worked instead of resulting in a windows error. Still the same as before, but the object numbers were -16776676 now, and sometimes (I think when I looked up, but I'm not sure) changed (constantly, even if I didn't move the camera anymore). I then wanted to try out the space-thing, but didn't remember if culling had to be on or off while doing so. When trying to return to the program however, it kept minimizing itself (an issue I usually have with Half Life 2 Episode 2). When it finally worked, the backdrop was seemingly off and no objects were drawn anymore (the screen stayed black, the only thing I saw was text, overwriting itself constantly). Very mysterious.

Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Jun 2011 13:38 Edited at: 4th Jun 2011 13:41
here:




Quote: "... and sometimes (I think when I looked up, but I'm not sure) changed (constantly, even if I didn't move the camera anymore)."

the same here

Attachments

Login to view attachments
Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Jun 2011 13:39

Attachments

Login to view attachments
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 4th Jun 2011 13:54
Quote: "Very mysterious"

it is...

Created a new exe, shows more info on the screen and runs in windowed mode to prevent the windows crash, I hope.
After this test I should have a clear idea what the problem is.

Attachments

Login to view attachments
Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Jun 2011 14:01
Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 4th Jun 2011 14:11 Edited at: 4th Jun 2011 14:23

I'll make a better version in fullscreen with less debug info on the screen. Comming in a few min

edit
new exe attached, I hope it still works
Thanks for helping me with this.

Attachments

Login to view attachments
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 4th Jun 2011 15:46
Works here as well. Even in full screen mode and completely without windows errors.

Max P
12
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 4th Jun 2011 17:42
I'm glad to hear that, I'll update the first post
Brendy boy
17
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Jun 2011 21:00
Red Eye
14
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 5th Jun 2011 16:19
Quote: "I dont know much about Umbra but as far as I know it calculates the data for culling in the editor and uses that data in the game for culling. My system works at real-time so adding/removing objects from the system can be done at runtime as well."


Umbra's Oclusion Culling is realtime. http://www.youtube.com/watch?v=MZRHgUFdUe4

But sounds good anyway, keep this up!

Red Eye
14
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 12th Jun 2011 12:33 Edited at: 12th Jun 2011 12:34
I was working on one for my engine too. Realtime Oclusion Culling.




What you see is a close up on a wireframe rendered cube. Behind far away you have loads of other cubes. The computer calculates which objects he must hide and polys are saved . See images for difference of camera position.

You inspired me!

Cheers,

RedEye

Matty H
14
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 12th Jun 2011 14:02
This is very interesting.

I think I would go for as much non-real time as I could, obviously it needs to work in real time but there is alot of pre calculation you could do with static objects, like Umbra does.

Dynamic objects would be tricky, I suppose you would need intense calculations in real time for those, but if the objects are high poly enough you could still save alot of CPU.

Red Eye
14
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 12th Jun 2011 16:46
Quote: "I think I would go for as much non-real time as I could, obviously it needs to work in real time but there is alot of pre calculation you could do with static objects, like Umbra does."


Depends really on which way you achieve Oclusion Culling.

Quote: "Dynamic objects would be tricky, I suppose you would need intense calculations in real time for those, but if the objects are high poly enough you could still save alot of CPU."


Aye, there must be a balance between the ammount of polys per object, the ammount of obejcts added to the Oclusion Class, and the ammount of CPU time that is needed for one calculation.

I am pretty sure, with those things you could easily roll out a formula that could describe the max and min range.

Matty H
14
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 12th Jun 2011 17:32
Quote: "Depends really on which way you achieve Oclusion Culling."


I have a few ideas but don't want to hijack this thread, since we would be discussing C++. I would be interested to what approach you have gone for, I may make a thread in the GDK section if I attempt it, see what ideas other people might have.

Red Eye
14
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 12th Jun 2011 19:06 Edited at: 12th Jun 2011 19:12
Quote: "I have a few ideas but don't want to hijack this thread, since we would be discussing C++. I would be interested to what approach you have gone for, I may make a thread in the GDK section if I attempt it, see what ideas other people might have."


Add me on msn.

For anybody interested:

http://www.livestream.com/quadrastudios/

Uploaded a video of the Oclusion Culling.

PS: Max P, do you happen to have msn?

Cheers,

Leo

Matty H
14
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 12th Jun 2011 20:56
@Red Eye - Added you on msn, I like the look of your engine/editor

Login to post a reply

Server time is: 2022-12-09 17:16:16
Your offset time is: 2022-12-09 17:16:16