• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
rouncer

volumetric flood filling

7 posts in this topic

Ive got this voxel csg algorythm, and it works volumetricly, that is so easy to write, thats why I did it that way. You just simply switch on and off bits due to volume takeup. The problem is I store my world using a surface representation of a simple point list every 256^3 volume in a 3d grid.

I got around this by flood filling the surface points to fill in the volume for the csg to act on it, and it works - the only problem is because of the cpu taking so long, especially since I have to traverse from the cpu to video ram after its done per chunk, im waiting 10 seconds for a smallish operation to finish.


Anyway, So I then got back to theorizing some method that could possibly work on the video card, and I imagine some kind of mip by mip approach could be the answer, but the solution eludes me... anyone could possibly help me out at all?



thanks for reading.
0

Share this post


Link to post
Share on other sites
If it's taking 10 seconds to do that then I'm guessing you are using a really inefficient algorithm. I've done a realtime light-propagation for voxels (26-directions), it could handle 20x20x20 fills well within a single frame on a single core (and rebuilding and uploading the mesh) after tuning it.

Something that you may have fallen for is to put all adjacent voxels onto the queue when the current voxel is hollow... rather than first check if each adjacent voxel is hollow and then put it in the queue. Depending on how you traverse, this can considerably shorten the number of iterations. Also, make sure that your voxel checks are inlined and fast.
1

Share this post


Link to post
Share on other sites
well the fill itself takes 1.5 seconds per chunk, all added together everything it comes to 10 seconds (which would be more than one chunk) so you think you could fill a 256x256x256 chunk in less than 1.5 seconds? I mean the closer it gets to 10 milliseconds the more id be happy...
0

Share this post


Link to post
Share on other sites
You could do it completly on the GPU.
256^3 could be placed on a single 4096x4096 texture (16x16 patches of 256x256 texel). You need two of these textures and switch them as render source/target between render frames. The shader will check per texel all 26 neighbor texel(when diagonal filling is allowed) or 6 neighbor texel and decides if the target texel should be filled. [s]The worst case should be 512 render frames, which should be no problem on a current hardware.[/s]

Edit: the worst case could be higher....
1

Share this post


Link to post
Share on other sites
[quote name='rouncer' timestamp='1324423828' post='4895929']
well the fill itself takes 1.5 seconds per chunk, all added together everything it comes to 10 seconds (which would be more than one chunk) so you think you could fill a 256x256x256 chunk in less than 1.5 seconds? I mean the closer it gets to 10 milliseconds the more id be happy...
[/quote]

Well, filling a 256x256x256 chunk it's hard to say, I mean, we are talking 16.7m voxels... all I have to go on is the performance of my minecraft-like lighting engine, I can create spherical holes 50x50x50 and propagate light into them in a single frame, if even that, I can easily do it 10 times per second and the FPS drops from ~500 to somewhere around ~350... and like I mentioned, that also includes mesh rebuild and upload. Some basic math on those rather sketchy numbers would indicate that I could repeat it 1000+ times a second if I avoid rendering. And since mine is more than 5x5x5 times (125+) smaller than yours, logic would indicate that it indeed it is possible to bring it down to somewhere around 0.2-0.3s if you flood fill something really complicated spanning the entire volume. But those numbers may also be way off, I can't really benchmark it in any meaningful way.

And light-propagation is a tad bit more complicated as I actually propagate light values and not just a single bit... and more importantly, I also do this in all 26 directions (!) which I know for a fact significantly slows it down, even though I've written some really tricky code to speed it up. But it depends on what you are interfacing with, if it's some OO class linked from a DLL with virtual methods and such, there might not be all that much you can do unless you can are able to have direct access into memory.

But really, if you want to speed it up, you need direct access and some serious fine-tuning, even switching an if-else-statement around can significantly increase performance. And I should also add that, my code is also significantly slowed down because the world is divded into blocks and not a single continous chunk of data... meaning, there is "significant" overhead in determining boundaries of blocks and computing block local coordinates for indexing.

[quote name='Ashaman73' timestamp='1324449682' post='4896054']
You could do it completly on the GPU.
256^3 could be placed on a single 4096x4096 texture (16x16 patches of 256x256 texel). You need two of these textures and switch them as render source/target between render frames. The shader will check per texel all 26 neighbor texel(when diagonal filling is allowed) or 6 neighbor texel and decides if the target texel should be filled. [s]The worst case should be 512 render frames, which should be no problem on a current hardware.[/s]

Edit: the worst case could be higher....
[/quote]

Indeed, worst case would be a single tile wide "snake" going back and forth through the entire cube, that would not be pretty... but then again not really something that would occur either.
1

Share this post


Link to post
Share on other sites
Thanks for the suggestions, Ive been away thinking about other things, but im back to this program now and I still need a solution to this.

Actually, that snaking tunnel isnt a problem for me, cause I only need to either fill space or solid, so I can make a filling element behind every single solid voxel, so the snake fill would happen in a single draw call.

I was thinking, (although its a little tricky to program) I could maybe take the first mip, and develop a filled mip from that at half the resolution, then develop a filled mip from that at half the resolution... and I could get it done in less batches, if you could get your head around that idea.
0

Share this post


Link to post
Share on other sites
Ok, I got it from 10 seconds to about 1 second, i sorta do it with brute volume passes on the gpu, thats not all it is tho, if thats all it was it would probably go just as slow if not slower than the cpu version, i actually speed it up by filling a bit, then converting to a lower mip, then filling some more, then converting lower again... its got some bugs and its probably not the quickest it can be, but i guess its resolved for now, at least I can get on with the rest of the program now.

To proove it, heres a shot of a 256x256x256 swiss cheese cube, note the program actually works with infinite volumes, not just 256^3 [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img].

[img]http://img835.imageshack.us/img835/5420/speedcsg.png[/img]
0

Share this post


Link to post
Share on other sites
slightly cooler shot, with bigger plot, the floor was a single plot, in about 8 seconds.
[img]http://img31.imageshack.us/img31/1266/yes2q.png[/img]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0