afonsolage / projekto

Voxel game made with Bevy Engine
MIT License
59 stars 4 forks source link

Implement smooth lighting #38

Closed afonsolage closed 2 years ago

afonsolage commented 2 years ago

Current light implemented on #30 is very "blockly", this happens because each voxel face knows nothing about it's surrounding and light values has a huge step between then (~6,66%). The solution for this problem is to smooth lighting per-vertex per-faces using it's surrounding data.

While doing it, Ambient Occlusion can also be implemented, since both techniques are very similar.

In general, those goals should be accomplished:

  1. Gather the light information of all neighbors, including edge (NW, SW, NE, SE) ones, this should be 54 neighboring voxels per voxel;
  2. For each face, for each vertex, compute the avg value of 4 surrounding light neighbors. Also apply AO on this step;
  3. Update faces_merge to only merge if all 4 vertices of the given face has the same value;

Step 1 should be the most complex one, since it can be very expensive, so a neat algorithm should be used.