// Copyright (c) 2023 Lachlan McDonald // This work is licensed under the MIT License (MIT) // https://github.com/lachlanmcdonald/magicavoxel-shaders // // xs outline2 [Color] // // xs_begin // author : '@lmcdx.bsky.social' // arg : { name = 'Color' var = 'm_color' range = '0 255' value = '1' step = '1' precision = '0' } // xs_end bool isSelectedPal(float p) { for (int i = 0; i < i_num_color_sels; i += 1) { if (p == color_sel(float(i))) { return true; } } return false; } float map(vec3 v) { float index = voxel(v); if (isSelectedPal(index)) { float n = voxel(vec3(v.x - 1.0, v.y, v.z)); float s = voxel(vec3(v.x + 1.0, v.y, v.z)); float e = voxel(vec3(v.x, v.y - 1.0, v.z)); float w = voxel(vec3(v.x, v.y + 1.0, v.z)); float a = voxel(vec3(v.x, v.y, v.z - 1.0)); float b = voxel(vec3(v.x, v.y, v.z + 1.0)); if ((isSelectedPal(n) == false && n != 0.0) || (isSelectedPal(s) == false && s != 0.0) || (isSelectedPal(e) == false && e != 0.0) || (isSelectedPal(w) == false && w != 0.0) || (isSelectedPal(a) == false && a != 0.0) || (isSelectedPal(b) == false && b != 0.0)) { return m_color; } } return index; }