[MagicaVoxel / Bug] Empty/blank shader
homiczke opened this issue · 0 comments
homiczke commented
[never mind, i forgot that I have to first select the color(!) then apply shader]
Hello,
I'm using noise shader in MagicaVoxel 0.99.6.2-macos-10.7 I'm sure I'm doing everything right, I've watched some tutorials on youtube and I'm trying to use the shaders exactly the way authors used it, but it's empty and plainly doesn't work. I've tried restarting/reinstalling the program. The particular shader worked before, I used it in the project before.
Help :(
// Copyright (c) 2023 Lachlan McDonald
// This work is licensed under the MIT License (MIT)
// https://github.com/lachlanmcdonald/magicavoxel-shaders
//
// This script utilises or modifies code from other projects or publications.
// Please see the attributions below for more information:
//
// 1. Copyright (c) 2020 ValgoBoi <https://github.com/ValgoBoi/clover-noise>
// MIT License (MIT)
// https://github.com/ValgoBoi/clover-noise/blob/master/LICENSE
//
// xs noise [Target Color] [Size X] [Size Y] [Size Z] [Seed]
//
// xs_begin
// author : '@lachlanmcdonald'
// arg : { name = 'Target Color' var = 'm_target_color' range = '0 255' value = '1' step = '1' precision = '0' }
// arg : { name = 'Size X' var = 'm_size_x' range = '1 256' value = '1' step = '1' precision = '0' }
// arg : { name = 'Size Y' var = 'm_size_y' range = '1 256' value = '1' step = '1' precision = '0' }
// arg : { name = 'Size Z' var = 'm_size_z' range = '1 256' value = '1' step = '1' precision = '0' }
// arg : { name = 'Seed' var = 'global_seed' range = '1 100' value = '1' step = '1' precision = '0' }
// xs_end
float target_color = m_target_color;
vec3 dim = vec3(m_size_x, m_size_y, m_size_z);
bool no_axis_mode = all(equal(ivec3(i_axis), ivec3(0)));
bvec3 axis_mode = no_axis_mode ? bvec3(true) : equal(ivec3(i_axis), ivec3(1));
float hash(vec2 p, float seed) {
p += seed + global_seed;
return fract(1e4 * sin(17.0 * p.x + p.y * 0.1) * (0.1 + abs(sin(p.y * 13.0 + p.x))));
}
float pal(float p) {
float f = floor(mix(0.0, float(i_num_color_sels), p));
return color_sel(f);
}
float map(vec3 v) {
float index = voxel(v);
float x = axis_mode.x ? floor(v.x / dim.x) : 1.0;
float y = axis_mode.y ? floor(v.y / dim.y) : 1.0;
float z = axis_mode.z ? floor(v.z / dim.z) : 1.0;
float j = hash(vec2(x, y), i_iter + 1.0 + global_seed);
float k = hash(vec2(j, z), i_iter + 1.0 + global_seed);
if (index == target_color) {
return pal(k);
} else {
return index;
}
}```