// Copyright (c) 2022 Lachlan McDonald // This work is licensed under the MIT License (MIT) // https://github.com/lachlanmcdonald/magicavoxel-shaders // // xs_begin // author : '@lachlanmcdonald' // arg : { name = 'Spacing' var = 'm_spacing' range = '1 100' value = '1' step = '1' precision = '0' } // xs_end float spacing = floor(m_spacing + 1.0); bvec3 axis_mode = equal(ivec3(i_axis), ivec3(1)); float map(vec3 v) { float index = voxel(v); if (axis_mode.x) { int x = int(mod(v.x, spacing)); return x == 0 ? voxel(vec3(floor(v.x / spacing), v.yz)) : 0.0; } else if (axis_mode.y) { int y = int(mod(v.y, spacing)); return y == 0 ? voxel(vec3(v.x, floor(v.y / spacing), v.z)) : 0.0; } else if (axis_mode.z) { int z = int(mod(v.z, spacing)); return z == 0 ? voxel(vec3(v.xy, floor(v.z / spacing))) : 0.0; } else { return index; } }