// Copyright (c) 2023 Lachlan McDonald // This work is licensed under the MIT License (MIT) // https://github.com/lachlanmcdonald/magicavoxel-shaders // // xs brush/zigzag2 [Direction] [Width A] [Width B] // // xs_begin // author : '@lmcdx.bsky.social' // arg : { name = 'Direction' var = 'm_direction' range = '0 3' value = '0' step = '1' precision = '0' } // arg : { name = 'Width A' var = 'm_width_a' range = '1 256' value = '2' step = '1' precision = '0' } // arg : { name = 'Width B' var = 'm_width_b' range = '1 256' value = '2' step = '1' precision = '0' } // xs_end int direction = int(m_direction); float map(vec3 v) { if (direction == 1) { v.y = -v.y; } else if (direction == 2) { v.x = -v.x; v.y = -v.y; } else if (direction == 3) { v.x = -v.x; } float size = m_width_a + m_width_b; vec3 c = floor(v / size); vec3 ic = floor(v - c * size); if (mod(c.x + c.y, 2.0) == 0.0) { if (any(lessThan(ic.xy, vec2(m_width_a)))) { return color_sel(0.0); } else { return i_num_color_sels < 2 ? 0.0 : color_sel(1.0); } } else { if (all(lessThan(ic.xy, vec2(m_width_a)))) { return color_sel(0.0); } else { return i_num_color_sels < 2 ? 0.0 : color_sel(1.0); } } }