Im going to say this first- I am making this for fun, no profit. I am using C# and XNA.
My current algorithm for lighting is a recursive method. However, it is expensive, to the point ofwhere one 8x128x8 chunk calculated perevery 5 seconds. There are two options:
Are there other lighting methods that will make variable darkness shadows?
Or is the recursive method good, and I am just doing it bad?
- Are there other lighting methods that will make variable-darkness shadows?
- Or is the recursive method good, and maybe I am just doing it wrong?
It just seems like recursive stuff is fundamentally expensive (forced to go through around 25k blocks per chunk (a guess)). I was thinking about using a method similar to raytracingray tracing, but I have no idea how this would work. Another thing I tried was storing lightsourceslight sources in a List, and for each block getting the distance to each lightsourcelight source, and using that to light it to the correct level, but then lighting would go through walls.
My current recursion code:
Notes: is below. This is called from any place in the chunk that does not have a light level of zero, after clearing and re-adding sunlight and torchlight.
world.get___at
world.get___at
is a function that can get blocks outside of this chunk (this is inside the "chunk"chunk class)
Location. Location
is my own structstructure that is like a Vector3Vector3
, but intsuses integers instead of floating point values.
"light[,,]" light[,,]
is the lightmap for the chunk.