-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floodfill lighting #4
Comments
From Tasks.md to be retired
|
I've implemented the floodfill from the linked article and it's fast enough. Currently it supports adding multiple lights and removing one light at a time. The initial lighting of the chunks needs to happen only at generation time. The sunlight isn't currently being updated on block placed/removed. |
I've implemented the heightfield, initialized by raycasting down from the highest loaded point and updated at each block add/remove. Followup work:
|
The minecraft lighting works by having a 2 light values for each blocks, each 4 bits (0..16). The first is torchlight, the second is sunlight. The light of the block is max(torchlight, sunlight). The torchlight propagates from block light sources decreasing by one each further block. The sunlight propagates from the top of the world decreasing by one sideways and by zero downwards.
The problem is that a view distance of 300 has 200 million blocks. That's too many to do in 1 frame, or a second.
The propagation algorithms for torchlights i've seen are:
Bruteforce naivity of naiveness
For every block look at the 6 neighbors and set the light as max(neighbors).
Converges after 16 updates.
Recalculates the entire lighting every time.
It's really reeeeeally slow, like 16 seconds slow.
Floodfill
Linear scan for lightsources. Start a breadth first search for each lightsource.
Converges in 1 update.
Can do incremental updates.
source
The text was updated successfully, but these errors were encountered: