mikolalysenko / ao-mesher

Voxel mesher with ambient occlusion
http://mikolalysenko.github.io/ao-shader/index.html
MIT License
40 stars 7 forks source link

Does this require padding added to the voxel data? #7

Open kevzettler opened 7 years ago

kevzettler commented 7 years ago

I belive this is the same issue as #6

I have a source voxel struture.

screenshot 2017-03-21 13 55 23

When I import it with ao-mesher and ao-shader I get

screenshot 2017-03-21 13 56 14

If I pad the voxel ndarray with:

function paddVoxelNDarray(ndvoxels){
  var resolution = ndvoxels.shape;
  var padding = resolution.map(function (r) { return r + 4; });
  var voxelsWithPadding = zeros(padding, 'int32');

  var x, y, z;

  for (x = 0; x < resolution[0]; x++) {
    for (y = 0; y < resolution[1]; y++) {
      for (z = 0; z < resolution[2]; z++) {
        var v = ndvoxels.get(x, y, z);
        v = v ? (1 << 15 | v) : 0;
        voxelsWithPadding.set(x + 1, y + 1, z + 1, v);
      }
    }
  }

  return voxelsWithPadding;
}

It renders as expected:

screenshot 2017-03-21 13 55 33

Should I PR the padding to be include in this module?