NEW:add "extruder printable height render"
jira: none Change-Id: I962fa4c72c7097899f4429cb8d71fe948910cd41
This commit is contained in:
parent
00810d685d
commit
14103e6d6e
|
@ -47,7 +47,7 @@ varying vec3 clipping_planes_dots;
|
|||
varying vec2 intensity;
|
||||
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
|
||||
uniform vec3 extruder_printable_heights;
|
||||
varying vec4 model_pos;
|
||||
varying vec4 world_pos;
|
||||
varying float world_normal_z;
|
||||
|
@ -75,11 +75,11 @@ void main()
|
|||
// if the fragment is outside the print volume -> use darker color
|
||||
vec3 pv_check_min = ZERO;
|
||||
vec3 pv_check_max = ZERO;
|
||||
if (print_volume.type == 0) {
|
||||
// rectangle
|
||||
pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x);
|
||||
pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y);
|
||||
color = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color, ZERO, 0.3333) : color;
|
||||
pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x);
|
||||
pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y);
|
||||
bool is_out_print_limit =(any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO)));
|
||||
if (print_volume.type == 0) {// rectangle
|
||||
color = is_out_print_limit ? mix(color, ZERO, 0.3333) : color;
|
||||
}
|
||||
else if (print_volume.type == 1) {
|
||||
// circle
|
||||
|
@ -88,7 +88,12 @@ void main()
|
|||
pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y);
|
||||
color = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color, ZERO, 0.3333) : color;
|
||||
}
|
||||
|
||||
if(is_out_print_limit == false && extruder_printable_heights.x >= 1.0 ){
|
||||
pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, extruder_printable_heights.y);
|
||||
pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, extruder_printable_heights.z);
|
||||
bool is_out_printable_height = (all(greaterThan(pv_check_min, ZERO)) && all(lessThan(pv_check_max, ZERO))) ;
|
||||
color = is_out_printable_height ? mix(color, ZERO, 0.7) : color;
|
||||
}
|
||||
//BBS: add outline_color
|
||||
if (is_outline)
|
||||
gl_FragColor = uniform_color;
|
||||
|
@ -98,7 +103,7 @@ void main()
|
|||
#endif
|
||||
else
|
||||
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||
|
||||
|
||||
// In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already
|
||||
// rendered object. To resolved z-fighting between previously rendered object and painted triangles, values
|
||||
// inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos.
|
||||
|
|
|
@ -1558,7 +1558,8 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type,
|
|||
std::function<bool(const GLVolume &)> filter_func,
|
||||
bool with_outline,
|
||||
const std::array<float, 4> & body_color,
|
||||
bool partly_inside_enable) const
|
||||
bool partly_inside_enable,
|
||||
std::vector<double> * printable_heights) const
|
||||
{
|
||||
GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func);
|
||||
if (to_render.empty())
|
||||
|
@ -1621,12 +1622,26 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type,
|
|||
//shader->set_uniform("print_volume.type", static_cast<int>(m_render_volume.type));
|
||||
//shader->set_uniform("print_volume.xy_data", m_render_volume.data);
|
||||
//shader->set_uniform("print_volume.z_data", m_render_volume.zs);
|
||||
|
||||
if (printable_heights) {
|
||||
std::array<float, 3> extruder_printable_heights;
|
||||
if ((*printable_heights).size() > 0) {
|
||||
extruder_printable_heights[0] = 2.0f;
|
||||
extruder_printable_heights[1] = (*printable_heights)[0];
|
||||
extruder_printable_heights[2] = (*printable_heights)[1];
|
||||
shader->set_uniform("extruder_printable_heights", extruder_printable_heights);
|
||||
shader->set_uniform("print_volume.xy_data", m_print_volume.data);
|
||||
} else {
|
||||
extruder_printable_heights[0] = 0.0f;
|
||||
shader->set_uniform("extruder_printable_heights", extruder_printable_heights);
|
||||
}
|
||||
}
|
||||
if (volume.first->partly_inside && partly_inside_enable) {
|
||||
//only partly inside volume need to be painted with boundary check
|
||||
shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
|
||||
shader->set_uniform("print_volume.xy_data", m_print_volume.data);
|
||||
shader->set_uniform("print_volume.z_data", m_print_volume.zs);
|
||||
if (!printable_heights || (printable_heights && (*printable_heights).size() == 0)) {
|
||||
shader->set_uniform("print_volume.xy_data", m_print_volume.data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//use -1 ad a invalid type
|
||||
|
|
|
@ -727,11 +727,11 @@ public:
|
|||
void render(ERenderType type,
|
||||
bool disable_cullface,
|
||||
const Transform3d & view_matrix,
|
||||
std::function<bool(const GLVolume &)> filter_func = std::function<bool(const GLVolume &)>(),
|
||||
bool with_outline = true,
|
||||
const std::array<float, 4>& body_color = {1.0f, 1.0f, 1.0f, 1.0f},
|
||||
bool partly_inside_enable =true
|
||||
) const;
|
||||
std::function<bool(const GLVolume &)> filter_func = std::function<bool(const GLVolume &)>(),
|
||||
bool with_outline = true,
|
||||
const std::array<float, 4> & body_color = {1.0f, 1.0f, 1.0f, 1.0f},
|
||||
bool partly_inside_enable = true,
|
||||
std::vector<double> * printable_heights = nullptr) const;
|
||||
|
||||
// Finalize the initialization of the geometry & indices,
|
||||
// upload the geometry and indices to OpenGL VBO objects
|
||||
|
|
|
@ -7304,6 +7304,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
|
|||
std::array<float, 4> body_color = canvas_type == ECanvasType::CanvasAssembleView ? std::array<float, 4>({1.0f, 1.0f, 0.0f, 1.0f}) ://yellow
|
||||
std::array<float, 4>({1.0f, 1.0f, 1.0f, 1.0f});//white
|
||||
bool partly_inside_enable = canvas_type == ECanvasType::CanvasAssembleView ? false : true;
|
||||
auto printable_height_option = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloatsNullable>("extruder_printable_height");
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
|
||||
|
@ -7340,7 +7341,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
|
|||
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||
}
|
||||
},
|
||||
with_outline, body_color, partly_inside_enable);
|
||||
with_outline, body_color, partly_inside_enable, printable_height_option ? &printable_height_option->values : nullptr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -7374,7 +7375,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
|
|||
return true;
|
||||
}
|
||||
},
|
||||
with_outline, body_color, partly_inside_enable);
|
||||
with_outline, body_color, partly_inside_enable, printable_height_option ? &printable_height_option->values : nullptr);
|
||||
if (m_canvas_type == CanvasAssembleView && m_gizmos.m_assemble_view_data->model_objects_clipper()->get_position() > 0) {
|
||||
const GLGizmosManager& gm = get_gizmos_manager();
|
||||
shader->stop_using();
|
||||
|
|
Loading…
Reference in New Issue