Refine stroke mix pass boundary
This commit is contained in:
173
src/canvas.cpp
173
src/canvas.cpp
@@ -390,97 +390,90 @@ void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz)
|
||||
{
|
||||
gl_state gl;
|
||||
gl.save();
|
||||
|
||||
m_mixer.bindFramebuffer();
|
||||
|
||||
apply_canvas_viewport(0, 0, m_mixer.getWidth(), m_mixer.getHeight());
|
||||
apply_canvas_capability(depth_test_state(), false);
|
||||
apply_canvas_capability(scissor_test_state(), true);
|
||||
apply_canvas_capability(blend_state(), false);
|
||||
|
||||
apply_canvas_scissor(
|
||||
static_cast<std::int32_t>(bb_min.x),
|
||||
static_cast<std::int32_t>(bb_min.y),
|
||||
static_cast<std::int32_t>(bb_sz.x),
|
||||
static_cast<std::int32_t>(bb_sz.y));
|
||||
|
||||
auto layer_index = m_current_layer_idx;
|
||||
std::array<pp::panopainter::LegacyCanvasStrokeMixPassPlane, 6> mix_planes {};
|
||||
const auto mix_mvp_base =
|
||||
glm::scale(glm::vec3(1, -1, 1)) *
|
||||
m_proj * m_mv;
|
||||
for (int plane_index = 0; plane_index < 6; ++plane_index)
|
||||
{
|
||||
mix_planes[plane_index] = pp::panopainter::LegacyCanvasStrokeMixPassPlane {
|
||||
.index = plane_index,
|
||||
.visible = m_layers[layer_index]->m_visible,
|
||||
.has_target = static_cast<bool>(m_layers[layer_index]->face(plane_index)),
|
||||
.opacity = m_layers[layer_index]->m_opacity,
|
||||
.mvp = mix_mvp_base *
|
||||
m_plane_transform[plane_index] *
|
||||
glm::translate(glm::vec3(0, 0, -1)),
|
||||
};
|
||||
}
|
||||
|
||||
const auto& b = m_current_stroke->m_brush;
|
||||
[[maybe_unused]] const auto mix_result = pp::panopainter::execute_legacy_canvas_stroke_mix_pass(
|
||||
pp::panopainter::LegacyCanvasStrokeMixPassRequest {
|
||||
.context = "Canvas::stroke_draw_mix",
|
||||
.resolution = m_size,
|
||||
.planes = mix_planes,
|
||||
.bind_mix_samplers = [&] {
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(1);
|
||||
m_sampler.bind(2);
|
||||
},
|
||||
.unbind_mix_samplers = [&] {
|
||||
m_sampler.unbind();
|
||||
},
|
||||
.setup_plane_shader = [&](int plane_index, const glm::mat4& plane_mvp_z) {
|
||||
(void)plane_index;
|
||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||
pp::panopainter::LegacyStrokeCompositeUniforms {
|
||||
.resolution = m_size,
|
||||
.mvp = plane_mvp_z,
|
||||
.pattern_texture_slot = 3,
|
||||
.layer_alpha = 1.0f,
|
||||
.alpha_lock = false, /*m_layers[layer_index]->m_alpha_locked*/
|
||||
.mask_enabled = false, /*m_smask_active*/
|
||||
.use_fragcoord = false,
|
||||
.blend_mode = b->m_blend_mode,
|
||||
.use_dual = false,
|
||||
.use_pattern = false,
|
||||
});
|
||||
},
|
||||
.bind_layer_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(0);
|
||||
m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||
},
|
||||
.bind_stroke_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(1);
|
||||
m_tmp[plane_index].bindTexture();
|
||||
},
|
||||
.bind_mask_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(2);
|
||||
m_smask.rtt(plane_index).bindTexture();
|
||||
},
|
||||
.draw_plane = [&] {
|
||||
m_node->m_face_plane.draw_fill();
|
||||
},
|
||||
.unbind_mask_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(2);
|
||||
m_smask.rtt(plane_index).unbindTexture();
|
||||
},
|
||||
.unbind_stroke_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(1);
|
||||
m_tmp[plane_index].unbindTexture();
|
||||
},
|
||||
.unbind_layer_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(0);
|
||||
m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||
},
|
||||
const auto layer_index = m_current_layer_idx;
|
||||
auto& current_layer = *m_layers[layer_index];
|
||||
const auto mix_planes = pp::panopainter::plan_legacy_canvas_stroke_mix_pass_planes(
|
||||
current_layer.m_visible,
|
||||
current_layer.m_opacity,
|
||||
glm::scale(glm::vec3(1, -1, 1)) * m_proj * m_mv,
|
||||
m_plane_transform,
|
||||
[&](int plane_index) {
|
||||
return current_layer.face(plane_index);
|
||||
});
|
||||
m_mixer.unbindFramebuffer();
|
||||
const auto& b = m_current_stroke->m_brush;
|
||||
[[maybe_unused]] const auto mix_result =
|
||||
pp::panopainter::execute_legacy_canvas_stroke_mix_pass_with_setup(
|
||||
[&] {
|
||||
m_mixer.bindFramebuffer();
|
||||
apply_canvas_viewport(0, 0, m_mixer.getWidth(), m_mixer.getHeight());
|
||||
apply_canvas_capability(depth_test_state(), false);
|
||||
apply_canvas_capability(scissor_test_state(), true);
|
||||
apply_canvas_capability(blend_state(), false);
|
||||
apply_canvas_scissor(
|
||||
static_cast<std::int32_t>(bb_min.x),
|
||||
static_cast<std::int32_t>(bb_min.y),
|
||||
static_cast<std::int32_t>(bb_sz.x),
|
||||
static_cast<std::int32_t>(bb_sz.y));
|
||||
},
|
||||
[&] {
|
||||
m_mixer.unbindFramebuffer();
|
||||
},
|
||||
pp::panopainter::LegacyCanvasStrokeMixPassRequest {
|
||||
.context = "Canvas::stroke_draw_mix",
|
||||
.resolution = m_size,
|
||||
.planes = mix_planes,
|
||||
.bind_mix_samplers = [&] {
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(1);
|
||||
m_sampler.bind(2);
|
||||
},
|
||||
.unbind_mix_samplers = [&] {
|
||||
m_sampler.unbind();
|
||||
},
|
||||
.setup_plane_shader = [&](int plane_index, const glm::mat4& plane_mvp_z) {
|
||||
(void)plane_index;
|
||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||
pp::panopainter::LegacyStrokeCompositeUniforms {
|
||||
.resolution = m_size,
|
||||
.mvp = plane_mvp_z,
|
||||
.pattern_texture_slot = 3,
|
||||
.layer_alpha = 1.0f,
|
||||
.alpha_lock = false, /*current_layer.m_alpha_locked*/
|
||||
.mask_enabled = false, /*m_smask_active*/
|
||||
.use_fragcoord = false,
|
||||
.blend_mode = b->m_blend_mode,
|
||||
.use_dual = false,
|
||||
.use_pattern = false,
|
||||
});
|
||||
},
|
||||
.bind_layer_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(0);
|
||||
current_layer.rtt(plane_index).bindTexture();
|
||||
},
|
||||
.bind_stroke_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(1);
|
||||
m_tmp[plane_index].bindTexture();
|
||||
},
|
||||
.bind_mask_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(2);
|
||||
m_smask.rtt(plane_index).bindTexture();
|
||||
},
|
||||
.draw_plane = [&] {
|
||||
m_node->m_face_plane.draw_fill();
|
||||
},
|
||||
.unbind_mask_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(2);
|
||||
m_smask.rtt(plane_index).unbindTexture();
|
||||
},
|
||||
.unbind_stroke_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(1);
|
||||
m_tmp[plane_index].unbindTexture();
|
||||
},
|
||||
.unbind_layer_texture = [&](int plane_index) {
|
||||
set_active_texture_unit(0);
|
||||
current_layer.rtt(plane_index).unbindTexture();
|
||||
},
|
||||
});
|
||||
|
||||
gl.restore();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user