• 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
ProtectedMode

Voxel-based lighting

11 posts in this topic

We are currently working on adding lighting to a small game with a voxel-based world.

 

Our current method consists of a list of changed blocks, and an update function invocated on every item on the list until the list is empty. The update method can add new blocks to the list in case they need an update. This works.

 

The only tiny problem is that it takes around a few minutes to calculate lighting for a world with one single lamp... The performance problem originates from the fact that the list doesn't check for duplicated blocks. So blocks can be updated more times than needed and therefore exponentially create more updates. A possibility would be to check for duplicate blocks but this is obviously a bad idea.

 

The world is dynamic so lights should be able to be removed and added, preferebly without having to remove all lighting and recalculating everything. This is possible with the current algorithm, however it's obviously too slow.

 

For people interested, here is the simplified algorithm executed on every item of the list:

  • Calculate own light level by getting the neighbour with the highest light level and substracting it with one.
  • Next, all blocks around the current block are added if their light levels are lower than the light level of the current block.

Does anybody have any experience or ideas about voxel lighting, preferably fast enough for updates every now and then...?

0

Share this post


Link to post
Share on other sites

Some thoughts:

1. Use insertion sort and avoid duplicates when inserting the voxel into the list.

2. Google for LPV (ligth propagation volumes), a technique used by crytek to simulate realtime GI. They utilize the GPU, which would be a good idea for your scenario too.

3. With one light, you mean a directional,infinit light (aka sun) ? In this case consider standard shadow mapping approaches.

0

Share this post


Link to post
Share on other sites

Some thoughts:

1. Use insertion sort and avoid duplicates when inserting the voxel into the list.

2. Google for LPV (ligth propagation volumes), a technique used by crytek to simulate realtime GI. They utilize the GPU, which would be a good idea for your scenario too.

3. With one light, you mean a directional,infinit light (aka sun) ? In this case consider standard shadow mapping approaches.

1. I still expect this approach to be too slow when considering there will be thousands of blocks on that list and it needs to be done very often.

2. Calculating lighting on changes and baking the light level into the vertices should probably still be faster, and fast enough since Minecraft somehow gets it working properly.

3. With one light I mean a single light block that emits light.

0

Share this post


Link to post
Share on other sites


since Minecraft somehow gets it working properly.

Minecraft's lighting is not that great. Simple shadow mapping would give better results.

0

Share this post


Link to post
Share on other sites

 


since Minecraft somehow gets it working properly.

Minecraft's lighting is not that great. Simple shadow mapping would give better results.

 

The smooth lighting is good enough for my taste. How would you handle hundreds of lights with shadow mapping?

0

Share this post


Link to post
Share on other sites


How would you handle hundreds of lights with shadow mapping?

 

I'd use light maps only for the closest lights - hundreds of shadow casting lights may require too much computing resources and memory. 

 

Cheers!

0

Share this post


Link to post
Share on other sites

 


How would you handle hundreds of lights with shadow mapping?

 

I'd use light maps only for the closest lights - hundreds of shadow casting lights may require too much computing resources and memory. 

 

Cheers!

 

That's why I think a voxel-based lighting model would be better. The light information could easily be baked into the voxels, which is much more efficient after the initial calculation is done. But that initial calculation is the problem...

0

Share this post


Link to post
Share on other sites

1. I still expect this approach to be too slow when considering there will be thousands of blocks on that list and it needs to be done very often.


Try and measure. A measly few thousand primitives (integer ids/indices) aren't likely to give you any trouble.
0

Share this post


Link to post
Share on other sites

Why don't you use an octree or a grid for the changed blocks? That would make it faster for you to find the voxels in range of a light for example (since they are 3D rather 1D), and they also don't allow duplicates (this is handled during insertion).

Since you are using voxels, you probably already have a grid or octree? An octree would be better, though (a grid will just waste memory). With an octree, you could just add a "changed" flag to the chunks of the existing octree (the flag should propagate to the parent chunks, all the way up to the root), and then if you want to find out if a voxel is changed or not, just traverse the octree geometrically all the way down to your voxel, while checking if the "changed" flag is set on the traversed chunks. If any of the traversed chunks aren't "changed" you can just return immediately - otherwise, you get to your voxel's chunk, and just check if it is "changed".

 

(Corrected to allow for fast removal of "changed" flag - i.e., not having to traverse a whole branch just to tell if a chunk's "changed" flag should be reset; now only the leafs should have the flag)

Edited by tonemgub
0

Share this post


Link to post
Share on other sites

I would just calculate direct contribution first and then scatter/blur that a bit. Should look better and be faster.

0

Share this post


Link to post
Share on other sites

Couldn't you add a single bit for each voxel that tells you of the voxel is already in light list or not?

This is the technique I'm using now with a breadth-first search and it's working a hundred times faster than before. I was using a byte for the lighting value, which is too much space anyway... Thank you all for your suggestions and answers.

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