I’m using a color buffer.
I’m calculating all blocks exposed to the sky (strait up) and giving them a light value of 9.
Then every step away from those ‘source’ blocks I deduct 1 light value until you hit 0.
Then when I generate the mesh chunk, I give it a black to white scale color.
I was emulating the minecraft lighting pattern. I didn’t use normal lights/shadow casting because I didn’t want a natural look. I probably did it the hard way. I didn’t look very far into anything built into JME. Although I would be really surprised if it had something that already did this. (but happy, so please do tell!)
Right now it only supports sunlight as a source. I intend for it to support placed light sources such as lava/torches/glowing rocks etc. I also think I will try coloring the light to the source, so lava would give off red light, torches would give off orange, etc.
It does support breaking and placing blocks. So if you dig a cave, the cave gets light from the entrance, and gets darker the farther in you go. If you close the cave from the inside, it gets dark. Break a hole in the roof an it lights up again etc. Its configurable to how many levels of light you want. I have some performance improvements let to make. Right now placing and breaking blocks is fast because it just makes a delta calculation, but I’m not batching the chunk generation enough, so I still consider that part slow.
Right now my current challenge is a friend dared me to round the corners on the blocks so I’m not just making a minecraft clone. That is going to create some interesting lighting problems, but I’m still planning on how I can generate the more complex mesh correctly and quickly.
I’ve pushed it all to github. But I don’t consider it done yet.
BigScorch.