Extract canvas mask modes, preview draw pass, and node style shell
This commit is contained in:
@@ -448,9 +448,9 @@ glm::vec4 NodeStrokePreview::stroke_draw_samples(
|
||||
copy_stroke_destination);
|
||||
}
|
||||
|
||||
std::vector<NodeStrokePreview::StrokeFrame> NodeStrokePreview::stroke_draw_compute(Stroke& stroke, float zoom) const
|
||||
std::vector<NodeStrokePreview::StrokeFrame> NodeStrokePreview::stroke_draw_compute(const Stroke& stroke, float zoom) const
|
||||
{
|
||||
auto samples = stroke.compute_samples();
|
||||
auto samples = const_cast<Stroke&>(stroke).compute_samples();
|
||||
StrokeSample previous_sample = stroke.m_prev_sample;
|
||||
previous_sample.size *= zoom;
|
||||
for (auto& sample : samples) {
|
||||
@@ -475,13 +475,13 @@ std::vector<NodeStrokePreview::StrokeFrame> NodeStrokePreview::stroke_draw_compu
|
||||
glm::vec4 color,
|
||||
float flow,
|
||||
float opacity,
|
||||
std::array<vertex_t, 4>&& shapes) {
|
||||
std::array<vertex_t, 4>&& shapes) -> StrokeFrame {
|
||||
return StrokeFrame {
|
||||
.col = color,
|
||||
.flow = flow,
|
||||
.opacity = opacity,
|
||||
.shapes = std::move(shapes),
|
||||
.m_mixer_rect = mixer_rect,
|
||||
.mixer_rect = mixer_rect,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -548,102 +548,55 @@ void NodeStrokePreview::draw_stroke_immediate()
|
||||
size,
|
||||
*b,
|
||||
ortho_proj));
|
||||
const bool copy_stroke_destination = pass_orchestration.copy_stroke_destination;
|
||||
pp::panopainter::setup_legacy_stroke_shader(pass_orchestration.stroke_shader);
|
||||
const bool sequence_ok = pp::panopainter::execute_legacy_node_stroke_preview_draw_immediate_shell<StrokeFrame>(
|
||||
*b,
|
||||
pass_orchestration,
|
||||
m_tex,
|
||||
m_rtt_mixer,
|
||||
m_rtt,
|
||||
m_tex_background,
|
||||
m_tex_dual,
|
||||
m_tex_preview,
|
||||
m_sampler_linear,
|
||||
m_sampler_linear_repeat,
|
||||
copy_stroke_destination,
|
||||
size,
|
||||
pp::panopainter::kLegacyNodeStrokePreviewStrokeTextureSlot,
|
||||
[&] {
|
||||
if (!pass_orchestration.material.dual_pass.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
pp::panopainter::setup_legacy_stroke_dual_shader(pass_orchestration.material.dual_pass.uses_pattern);
|
||||
bind_stroke_preview_dual_pass_textures(*prepared_strokes.dual_brush);
|
||||
pp::panopainter::execute_legacy_stroke_preview_live_pass(
|
||||
[&] {
|
||||
m_rtt.clear();
|
||||
},
|
||||
[&] {
|
||||
return stroke_draw_compute(prepared_strokes.dual_stroke, zoom);
|
||||
},
|
||||
[](auto& frame) {
|
||||
frame.col = { 0, 0, 0, 1 };
|
||||
},
|
||||
[&](auto& frame) {
|
||||
pp::panopainter::use_legacy_stroke_shader();
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
.color = frame.col,
|
||||
.alpha = frame.flow,
|
||||
.opacity = frame.opacity,
|
||||
});
|
||||
},
|
||||
[&](auto& frame) {
|
||||
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex_dual, copy_stroke_destination);
|
||||
},
|
||||
[&] {
|
||||
pp::panopainter::copy_legacy_node_stroke_preview_framebuffer_to_texture(
|
||||
m_tex_dual,
|
||||
size,
|
||||
pp::panopainter::kLegacyNodeStrokePreviewStrokeTextureSlot);
|
||||
});
|
||||
},
|
||||
[&] {
|
||||
execute_stroke_preview_background_capture_pass(
|
||||
size,
|
||||
pass_orchestration.background_colorize,
|
||||
m_tex_background,
|
||||
[&] {
|
||||
m_plane.draw_fill();
|
||||
});
|
||||
},
|
||||
[&] {
|
||||
return stroke_draw_compute(prepared_strokes.stroke, zoom);
|
||||
},
|
||||
[&](auto& frame) {
|
||||
if (b->m_tip_mix > 0.f)
|
||||
{
|
||||
stroke_draw_mix(xy(frame.m_mixer_rect), zw(frame.m_mixer_rect));
|
||||
}
|
||||
|
||||
frame.col = b->m_blend_mode != 0 || b->m_tip_mix > 0.f ?
|
||||
glm::vec4 { .7, .4, .1, 1 } :
|
||||
glm::vec4 { 0, 0, 0, 1 };
|
||||
frame.flow = glm::max(frame.flow, m_min_flow);
|
||||
},
|
||||
[&](auto& frame) {
|
||||
pp::panopainter::use_legacy_stroke_shader();
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
.color = frame.col,
|
||||
.alpha = frame.flow,
|
||||
.opacity = frame.opacity,
|
||||
});
|
||||
},
|
||||
[&](auto& frame) {
|
||||
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex, copy_stroke_destination);
|
||||
},
|
||||
[&] {
|
||||
set_active_texture_unit(3U);
|
||||
m_rtt_mixer.unbindTexture();
|
||||
},
|
||||
[&] {
|
||||
b->m_pattern_texture ? b->m_pattern_texture->bind() : unbind_texture_2d();
|
||||
},
|
||||
[&] {
|
||||
m_plane.draw_fill();
|
||||
const bool sequence_ok = pp::panopainter::execute_legacy_node_stroke_preview_live_render_passes(
|
||||
pp::panopainter::LegacyNodeStrokePreviewLiveRenderRequest {
|
||||
.brush = *b,
|
||||
.pass_orchestration = pass_orchestration,
|
||||
.prepared_strokes = prepared_strokes,
|
||||
.stroke_texture = m_tex,
|
||||
.mixer_rtt = m_rtt_mixer,
|
||||
.render_target = m_rtt,
|
||||
.background_texture = m_tex_background,
|
||||
.dual_texture = m_tex_dual,
|
||||
.preview_texture = m_tex_preview,
|
||||
.linear_sampler = m_sampler_linear,
|
||||
.repeat_sampler = m_sampler_linear_repeat,
|
||||
.zoom = zoom,
|
||||
.min_flow = m_min_flow,
|
||||
.copy_stroke_destination = pass_orchestration.copy_stroke_destination,
|
||||
.size = size,
|
||||
.bind_dual_pass_textures = [](const Brush& dual_brush) {
|
||||
bind_stroke_preview_dual_pass_textures(dual_brush);
|
||||
},
|
||||
.capture_background = [&](bool colorize) {
|
||||
execute_stroke_preview_background_capture_pass(
|
||||
size,
|
||||
colorize,
|
||||
m_tex_background,
|
||||
[&] {
|
||||
m_plane.draw_fill();
|
||||
});
|
||||
},
|
||||
.compute_frames = [&](const Stroke& stroke, float frame_zoom) {
|
||||
return stroke_draw_compute(stroke, frame_zoom);
|
||||
},
|
||||
.draw_samples = [&](std::array<vertex_t, 4>& shapes, Texture2D& texture, bool copy_stroke_destination) {
|
||||
return stroke_draw_samples(shapes, texture, copy_stroke_destination);
|
||||
},
|
||||
.draw_mix = [&](const glm::vec2& bb_min, const glm::vec2& bb_sz) {
|
||||
stroke_draw_mix(bb_min, bb_sz);
|
||||
},
|
||||
.unbind_mixer_texture = [&] {
|
||||
set_active_texture_unit(3U);
|
||||
m_rtt_mixer.unbindTexture();
|
||||
},
|
||||
.bind_pattern_texture = [&] {
|
||||
b->m_pattern_texture ? b->m_pattern_texture->bind() : unbind_texture_2d();
|
||||
},
|
||||
.draw_composite = [&] {
|
||||
m_plane.draw_fill();
|
||||
},
|
||||
});
|
||||
assert(sequence_ok);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user