// Zcolorシェーダ // ver 1.0 2020/08/24 // by yarunashi@dooon // xs_begin // author : 'yarunashi@dooon' // arg : { id = '0' name = 'type' value = '1' range = '1 2' step = '1' decimal = '0' } // arg : { id = '1' name = 'range' value = '8' range = '-255 255' step = '1' decimal = '0' } // arg : { id = '2' name = 'top' value = '255' range = '0 255' step = '1' decimal = '0' } // xs_end float type = i_args[0]; float range = i_args[1]; float top = min(i_args[2]+1.0, i_volume_size.z); float height(vec3 v) { float top = -1.0; for(float z = i_volume_size.z-1.0; z >= 0.0; z--) { if (top < 0.0) { if (voxel(vec3(v.x, v.y, z)) > 0.0) { top = z; if (z == floor(v.z)) return 0.0; } } else { if (z == floor(v.z)) return top - z; } } return -1.0; } float map(vec3 v) { if (voxel(v) == 0.0) return 0.0; if (floor(v.z) > top) return voxel(v); float h; if (type == 1.0) { h = top - floor(v.z) - 1.0; } else { h = height(v); } return i_color_index + sign(range) * floor((h / (top)) * abs(range)); }