I have solved the dark edges on the cube problem, and significantly reduced the dark band you got on one side of the cube.
You need to change this function. Look for the comments that have (sswift) in them. You will also need to change the terrain lighting function in the same manner.
Bascially, the problem was that the lightmapper was casting rays from the light to the TOP LEFT CORNER of each lumel instead of at the lumel's center. The center of each lumel corresponds to the center of each pixel in the lightmap. So it was sampling from the wrong place.
The only issues now are that the top of the cube displays slightly lighter bands near it's edges, and near the bottom of the cube on the floor you see either a slightly lighter shade or slightly darker shade in the lightmap depending on wehther you offset the cube into the floor a tiny bit or not.
You should be able to reduce these artifacts by doing 4x antialiasing on the lightmap. Ie, sample it at twice the resolution and then average it down. But that won't solve the issue entirely.
As for how to solve the issue entirely, I think you'd need to be able to detect when a texel is partially in shadow so you can darken it. So that would involve sampling at each of the 4 corners of the texel. Then texels which have a center that is just inside a wall on the opposite side of the wall from a light would have two corners out side the wall on the shadowed side of the wall, and that texel would therefore become shadowed.
You need to change this function. Look for the comments that have (sswift) in them. You will also need to change the terrain lighting function in the same manner.
Bascially, the problem was that the lightmapper was casting rays from the light to the TOP LEFT CORNER of each lumel instead of at the lumel's center. The center of each lumel corresponds to the center of each pixel in the lightmap. So it was sampling from the wrong place.
See link two messages down.
The only issues now are that the top of the cube displays slightly lighter bands near it's edges, and near the bottom of the cube on the floor you see either a slightly lighter shade or slightly darker shade in the lightmap depending on wehther you offset the cube into the floor a tiny bit or not.
You should be able to reduce these artifacts by doing 4x antialiasing on the lightmap. Ie, sample it at twice the resolution and then average it down. But that won't solve the issue entirely.
As for how to solve the issue entirely, I think you'd need to be able to detect when a texel is partially in shadow so you can darken it. So that would involve sampling at each of the 4 corners of the texel. Then texels which have a center that is just inside a wall on the opposite side of the wall from a light would have two corners out side the wall on the shadowed side of the wall, and that texel would therefore become shadowed.