Share retained stroke temporary composite helper
This commit is contained in:
113
src/canvas.cpp
113
src/canvas.cpp
@@ -1438,64 +1438,73 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
|
||||
}
|
||||
else if (m_current_stroke && m_show_tmp && m_current_layer_idx == layer_index)
|
||||
{
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(1);
|
||||
m_sampler.bind(2);
|
||||
m_sampler.bind(3);
|
||||
m_sampler_stencil.bind(4);
|
||||
|
||||
const auto stroke_material = canvas_stroke_material_plan(*b, false);
|
||||
glm::vec2 patt_scale = glm::vec2(b->m_pattern_scale);
|
||||
if (b->m_pattern_flipx) patt_scale.x *= -1.f;
|
||||
if (b->m_pattern_flipy) patt_scale.y *= -1.f;
|
||||
|
||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||
pp::panopainter::LegacyStrokeCompositeUniforms {
|
||||
.resolution = Canvas::I->m_size,
|
||||
.pattern = {
|
||||
.scale = patt_scale,
|
||||
.invert = static_cast<float>(b->m_pattern_invert),
|
||||
.brightness = b->m_pattern_brightness,
|
||||
.contrast = b->m_pattern_contrast,
|
||||
.depth = b->m_pattern_depth,
|
||||
.blend_mode = b->m_pattern_blend_mode,
|
||||
.offset = Canvas::I->m_pattern_offset,
|
||||
},
|
||||
.mvp = ortho,
|
||||
.layer_alpha = m_layers[layer_index]->m_opacity,
|
||||
.alpha_lock = m_layers[layer_index]->m_alpha_locked,
|
||||
.mask_enabled = m_smask_active,
|
||||
.use_fragcoord = false,
|
||||
.blend_mode = b->m_blend_mode,
|
||||
.use_dual = stroke_material.composite_pass.use_dual,
|
||||
.dual_blend_mode = stroke_material.composite_pass.dual_blend_mode,
|
||||
.dual_alpha = stroke_material.composite_pass.dual_alpha,
|
||||
.use_pattern = stroke_material.composite_pass.use_pattern,
|
||||
pp::panopainter::execute_legacy_canvas_stroke_temporary_composite(
|
||||
[&] {
|
||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||
pp::panopainter::LegacyStrokeCompositeUniforms {
|
||||
.resolution = Canvas::I->m_size,
|
||||
.pattern = {
|
||||
.scale = patt_scale,
|
||||
.invert = static_cast<float>(b->m_pattern_invert),
|
||||
.brightness = b->m_pattern_brightness,
|
||||
.contrast = b->m_pattern_contrast,
|
||||
.depth = b->m_pattern_depth,
|
||||
.blend_mode = b->m_pattern_blend_mode,
|
||||
.offset = Canvas::I->m_pattern_offset,
|
||||
},
|
||||
.mvp = ortho,
|
||||
.layer_alpha = m_layers[layer_index]->m_opacity,
|
||||
.alpha_lock = m_layers[layer_index]->m_alpha_locked,
|
||||
.mask_enabled = m_smask_active,
|
||||
.use_fragcoord = false,
|
||||
.blend_mode = b->m_blend_mode,
|
||||
.use_dual = stroke_material.composite_pass.use_dual,
|
||||
.dual_blend_mode = stroke_material.composite_pass.dual_blend_mode,
|
||||
.dual_alpha = stroke_material.composite_pass.dual_alpha,
|
||||
.use_pattern = stroke_material.composite_pass.use_pattern,
|
||||
});
|
||||
},
|
||||
[&] {
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(1);
|
||||
m_sampler.bind(2);
|
||||
m_sampler.bind(3);
|
||||
m_sampler_stencil.bind(4);
|
||||
},
|
||||
[&] {
|
||||
set_active_texture_unit(0);
|
||||
m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||
set_active_texture_unit(1);
|
||||
m_tmp[plane_index].bindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_smask.rtt(plane_index).bindTexture();
|
||||
set_active_texture_unit(3);
|
||||
if (stroke_material.composite_pass.use_dual)
|
||||
m_tmp_dual[plane_index].bindTexture();
|
||||
set_active_texture_unit(4);
|
||||
b->m_pattern_texture ?
|
||||
b->m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
[&] {
|
||||
m_plane.draw_fill();
|
||||
},
|
||||
[&] {
|
||||
set_active_texture_unit(3);
|
||||
if (stroke_material.composite_pass.use_dual)
|
||||
m_tmp_dual[plane_index].unbindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_smask.rtt(plane_index).unbindTexture();
|
||||
set_active_texture_unit(1);
|
||||
m_tmp[plane_index].unbindTexture();
|
||||
set_active_texture_unit(0);
|
||||
m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||
});
|
||||
|
||||
set_active_texture_unit(0);
|
||||
m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||
set_active_texture_unit(1);
|
||||
m_tmp[plane_index].bindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_smask.rtt(plane_index).bindTexture();
|
||||
set_active_texture_unit(3);
|
||||
if (stroke_material.composite_pass.use_dual)
|
||||
m_tmp_dual[plane_index].bindTexture();
|
||||
set_active_texture_unit(4);
|
||||
b->m_pattern_texture ?
|
||||
b->m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
m_plane.draw_fill();
|
||||
set_active_texture_unit(3);
|
||||
if (stroke_material.composite_pass.use_dual)
|
||||
m_tmp_dual[plane_index].unbindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_smask.rtt(plane_index).unbindTexture();
|
||||
set_active_texture_unit(1);
|
||||
m_tmp[plane_index].unbindTexture();
|
||||
set_active_texture_unit(0);
|
||||
m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user