f3d6bd3e0 Add option to convert existing color data to raw offset values when projecting a raw offset atlas image
This commit is contained in:
@@ -2002,7 +2002,6 @@ namespace DoExport {
|
||||
}
|
||||
} // namespace DoExport
|
||||
|
||||
static bool print_has_raw_offset_texture_data_without_raw_zone_for_gcode(const Print &print);
|
||||
static bool print_has_raw_offset_texture_zone_without_raw_data_for_gcode(const Print &print);
|
||||
|
||||
bool GCode::is_BBL_Printer()
|
||||
@@ -2043,12 +2042,6 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
||||
GCodeProcessor::s_IsBBLPrinter = print->is_BBL_printer();
|
||||
m_writer.set_is_bbl_machine(print->is_BBL_printer());
|
||||
print->set_started(psGCodeExport);
|
||||
if (print_has_raw_offset_texture_data_without_raw_zone_for_gcode(*print)) {
|
||||
print->active_step_add_warning(
|
||||
PrintStateBase::WarningLevel::NON_CRITICAL,
|
||||
_(L("An object contains raw filament offset texture data, but it is not assigned to a texture mapping zone "
|
||||
"set to Raw filament offset mode. Slicing will use the preview texture instead of the raw offsets for that object.")));
|
||||
}
|
||||
if (print_has_raw_offset_texture_zone_without_raw_data_for_gcode(*print)) {
|
||||
print->active_step_add_warning(
|
||||
PrintStateBase::WarningLevel::NON_CRITICAL,
|
||||
@@ -6887,8 +6880,7 @@ static std::vector<size_t> raw_component_source_channels_for_gcode(const std::st
|
||||
for (size_t component_idx = 0; component_idx < mapping.size(); ++component_idx) {
|
||||
if (mapping[component_idx] != sentinel)
|
||||
continue;
|
||||
while (next_source < source_keys.size() &&
|
||||
(used[next_source] != 0 || (!target_keys.empty() && !source_keys[next_source].empty())))
|
||||
while (next_source < source_keys.size() && used[next_source] != 0)
|
||||
++next_source;
|
||||
if (next_source >= source_keys.size())
|
||||
continue;
|
||||
@@ -6931,29 +6923,6 @@ static bool model_volume_has_raw_offset_texture_data_for_gcode(const ModelVolume
|
||||
size_t(volume->imported_texture_raw_channels);
|
||||
}
|
||||
|
||||
static bool print_has_raw_offset_texture_data_without_raw_zone_for_gcode(const Print &print)
|
||||
{
|
||||
const TextureMappingManager &texture_mgr = print.texture_mapping_manager();
|
||||
for (const PrintObject *print_object : print.objects()) {
|
||||
if (print_object == nullptr || print_object->model_object() == nullptr)
|
||||
continue;
|
||||
|
||||
for (const ModelVolume *volume : print_object->model_object()->volumes) {
|
||||
if (volume == nullptr ||
|
||||
!volume->is_model_part() ||
|
||||
!model_volume_has_raw_offset_texture_data_for_gcode(volume))
|
||||
continue;
|
||||
|
||||
const unsigned int filament_id = unsigned(std::max(0, volume->extruder_id()));
|
||||
const TextureMappingZone *zone = texture_mgr.zone_from_id(filament_id);
|
||||
if (zone == nullptr ||
|
||||
zone->texture_mapping_mode != int(TextureMappingZone::TextureMappingRawValues))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool print_has_raw_offset_texture_zone_without_raw_data_for_gcode(const Print &print)
|
||||
{
|
||||
const TextureMappingManager &texture_mgr = print.texture_mapping_manager();
|
||||
@@ -7549,7 +7518,6 @@ static VertexColorOverhangWeightField build_vertex_color_weight_field_for_gcode(
|
||||
filament_color_mode,
|
||||
component_count);
|
||||
const bool use_raw_uv_texture =
|
||||
raw_values_mode &&
|
||||
raw_component_source_channels.size() == component_count &&
|
||||
volume->imported_texture_raw_filament_offsets.size() >=
|
||||
size_t(volume->imported_texture_width) *
|
||||
@@ -7767,10 +7735,15 @@ static VertexColorOverhangWeightField build_vertex_color_weight_field_for_gcode(
|
||||
|
||||
std::vector<float> desired(component_count, 0.f);
|
||||
size_t mapped_component_count = component_count;
|
||||
const bool has_raw_component_weights = raw_values_mode && sample.raw_component_weights.size() == component_count;
|
||||
const bool has_raw_component_weights = sample.raw_component_weights.size() == component_count;
|
||||
if (has_raw_component_weights) {
|
||||
float raw_activity = 0.f;
|
||||
for (size_t component_idx = 0; component_idx < component_count; ++component_idx)
|
||||
desired[component_idx] = clamp01f_for_gcode(sample.raw_component_weights[component_idx]);
|
||||
for (const float value : desired)
|
||||
raw_activity = std::max(raw_activity, value);
|
||||
if (raw_activity <= EPSILON)
|
||||
std::fill(desired.begin(), desired.end(), 1.f);
|
||||
} else {
|
||||
std::array<float, 3> target = {
|
||||
clamp01f_for_gcode(sample.rgba[0]),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -360,6 +360,7 @@ private:
|
||||
float m_projection_opacity = 1.f;
|
||||
bool m_apply_transparency_as_background = false;
|
||||
bool m_pass_through_model = false;
|
||||
bool m_convert_existing_colors_to_raw_offsets = true;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -632,8 +632,7 @@ std::vector<size_t> raw_component_source_channels_for_texture_preview(const std:
|
||||
for (size_t component_idx = 0; component_idx < mapping.size(); ++component_idx) {
|
||||
if (mapping[component_idx] != sentinel)
|
||||
continue;
|
||||
while (next_source < source_keys.size() &&
|
||||
(used[next_source] != 0 || (!target_keys.empty() && !source_keys[next_source].empty())))
|
||||
while (next_source < source_keys.size() && used[next_source] != 0)
|
||||
++next_source;
|
||||
if (next_source >= source_keys.size())
|
||||
continue;
|
||||
@@ -1579,7 +1578,6 @@ TexturePreviewSimulationResult build_simulated_texture_preview_result(size_t sig
|
||||
prepare_texture_preview_simulation_settings(settings);
|
||||
const bool use_generic_solver = !settings.generic_mix_candidates.empty();
|
||||
const bool use_raw_offsets =
|
||||
settings.mapping_mode == int(TextureMappingZone::TextureMappingRawValues) &&
|
||||
source_raw_component_channels.size() == settings.component_colors.size() &&
|
||||
source_raw_offsets.size() >= size_t(width) * size_t(height) * size_t(source_raw_channels);
|
||||
|
||||
@@ -1640,6 +1638,10 @@ TexturePreviewSimulationResult build_simulated_texture_preview_result(size_t sig
|
||||
float activity = 0.f;
|
||||
for (const float weight : component_weights)
|
||||
activity = std::max(activity, clamp01(weight));
|
||||
if (use_raw_offsets && activity <= k_epsilon && !component_weights.empty()) {
|
||||
std::fill(component_weights.begin(), component_weights.end(), 1.f);
|
||||
activity = 1.f;
|
||||
}
|
||||
|
||||
const std::array<float, 3> simulated_rgb = activity > k_epsilon ?
|
||||
mix_component_colors_with_filament_mixer(settings.component_colors, component_weights) :
|
||||
|
||||
Reference in New Issue
Block a user