Extract node events, transform mode, and preview pass shells
This commit is contained in:
@@ -599,88 +599,79 @@ void NodeStrokePreview::draw_stroke_immediate()
|
||||
ortho_proj));
|
||||
const bool copy_stroke_destination = pass_orchestration.copy_stroke_destination;
|
||||
pp::panopainter::setup_legacy_stroke_shader(pass_orchestration.stroke_shader);
|
||||
execute_stroke_draw_immediate_pass_sequence(
|
||||
prepared_strokes.stroke,
|
||||
prepared_strokes.dual_stroke,
|
||||
const bool sequence_ok = pp::panopainter::execute_legacy_node_stroke_preview_draw_immediate_shell<StrokeFrame>(
|
||||
*b,
|
||||
std::move(prepared_strokes.dual_brush),
|
||||
pass_orchestration,
|
||||
copy_stroke_destination,
|
||||
zoom,
|
||||
size);
|
||||
|
||||
m_rtt.unbindFramebuffer();
|
||||
|
||||
apply_stroke_preview_viewport(vp.x, vp.y, vp.width, vp.height);
|
||||
apply_stroke_preview_clear_color(cc);
|
||||
}
|
||||
|
||||
NodeStrokePreview::StrokeMainLivePassRequest
|
||||
NodeStrokePreview::make_stroke_draw_immediate_main_live_pass_request(
|
||||
Stroke& stroke,
|
||||
const Brush& brush,
|
||||
const pp::panopainter::LegacyNodeStrokePreviewPassOrchestrationPlan& pass_orchestration,
|
||||
bool copy_stroke_destination,
|
||||
float zoom,
|
||||
const glm::vec2& size)
|
||||
{
|
||||
return pp::panopainter::make_legacy_node_stroke_preview_main_live_pass_request<StrokeFrame>(
|
||||
brush,
|
||||
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,
|
||||
[&] {
|
||||
return stroke_draw_compute(stroke, zoom);
|
||||
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 (brush.m_tip_mix > 0.f)
|
||||
if (b->m_tip_mix > 0.f)
|
||||
{
|
||||
stroke_draw_mix(xy(frame.m_mixer_rect), zw(frame.m_mixer_rect));
|
||||
}
|
||||
|
||||
frame.col = brush.m_blend_mode != 0 || brush.m_tip_mix > 0.f ?
|
||||
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) {
|
||||
execute_stroke_draw_immediate_main_live_sample_pass(
|
||||
brush,
|
||||
copy_stroke_destination,
|
||||
frame,
|
||||
size);
|
||||
},
|
||||
[&](auto& frame) {
|
||||
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex, copy_stroke_destination);
|
||||
},
|
||||
[&] { set_active_texture_unit(stroke_preview_live_slots::kMixer); m_rtt_mixer.unbindTexture(); });
|
||||
}
|
||||
|
||||
void NodeStrokePreview::execute_stroke_draw_immediate_dual_pass(
|
||||
Stroke& dual_stroke,
|
||||
const Brush& brush,
|
||||
const pp::panopainter::LegacyNodeStrokePreviewPassOrchestrationPlan& pass_orchestration,
|
||||
std::shared_ptr<Brush> dual_brush,
|
||||
bool copy_stroke_destination,
|
||||
float zoom,
|
||||
const glm::vec2& size)
|
||||
{
|
||||
(void)pass_orchestration;
|
||||
(void)dual_brush;
|
||||
pp::panopainter::execute_legacy_stroke_preview_live_pass(
|
||||
[&] {
|
||||
m_rtt.clear();
|
||||
},
|
||||
[&] {
|
||||
return stroke_draw_compute(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(
|
||||
@@ -691,104 +682,24 @@ void NodeStrokePreview::execute_stroke_draw_immediate_dual_pass(
|
||||
});
|
||||
},
|
||||
[&](auto& frame) {
|
||||
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex_dual, copy_stroke_destination);
|
||||
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex, copy_stroke_destination);
|
||||
},
|
||||
[&] {
|
||||
pp::panopainter::copy_legacy_node_stroke_preview_framebuffer_to_texture(
|
||||
m_tex_dual,
|
||||
size,
|
||||
stroke_preview_composite_slots::kStroke);
|
||||
});
|
||||
}
|
||||
|
||||
void NodeStrokePreview::execute_stroke_draw_immediate_pass_sequence(
|
||||
Stroke& stroke,
|
||||
Stroke& dual_stroke,
|
||||
const Brush& brush,
|
||||
std::shared_ptr<Brush> dual_brush,
|
||||
const pp::panopainter::LegacyNodeStrokePreviewPassOrchestrationPlan& pass_orchestration,
|
||||
bool copy_stroke_destination,
|
||||
float zoom,
|
||||
const glm::vec2& size)
|
||||
{
|
||||
const auto& material = pass_orchestration.material;
|
||||
const bool sequence_ok = pp::panopainter::execute_legacy_node_stroke_preview_immediate_pass_sequence(
|
||||
pp::panopainter::LegacyNodeStrokePreviewImmediatePassSequenceRequest {
|
||||
.execute_dual_pass = [&] {
|
||||
if (!material.dual_pass.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
pp::panopainter::setup_legacy_stroke_dual_shader(
|
||||
material.dual_pass.uses_pattern);
|
||||
bind_stroke_preview_dual_pass_textures(*dual_brush);
|
||||
execute_stroke_draw_immediate_dual_pass(
|
||||
dual_stroke,
|
||||
brush,
|
||||
pass_orchestration,
|
||||
std::move(dual_brush),
|
||||
copy_stroke_destination,
|
||||
zoom,
|
||||
size);
|
||||
},
|
||||
.capture_background = [&] {
|
||||
execute_stroke_preview_background_capture_pass(
|
||||
size,
|
||||
pass_orchestration.background_colorize,
|
||||
m_tex_background,
|
||||
[&] {
|
||||
m_plane.draw_fill();
|
||||
});
|
||||
},
|
||||
.execute_main_live_pass = [&]() -> bool {
|
||||
return pp::panopainter::execute_legacy_node_stroke_preview_main_live_pass(
|
||||
make_stroke_draw_immediate_main_live_pass_request(
|
||||
stroke,
|
||||
brush,
|
||||
pass_orchestration,
|
||||
copy_stroke_destination,
|
||||
zoom,
|
||||
size));
|
||||
},
|
||||
.execute_final_composite = [&]() -> bool {
|
||||
return pp::panopainter::execute_legacy_node_stroke_preview_final_composite(
|
||||
size,
|
||||
glm::vec2(brush.m_pattern_scale),
|
||||
brush,
|
||||
material.composite_pass,
|
||||
m_tex_background,
|
||||
m_tex,
|
||||
m_tex_dual,
|
||||
m_tex_preview,
|
||||
m_sampler_linear,
|
||||
m_sampler_linear_repeat,
|
||||
[&] {
|
||||
brush.m_pattern_texture ? brush.m_pattern_texture->bind() : unbind_texture_2d();
|
||||
},
|
||||
[&] {
|
||||
m_plane.draw_fill();
|
||||
});
|
||||
},
|
||||
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();
|
||||
});
|
||||
assert(sequence_ok);
|
||||
}
|
||||
|
||||
void NodeStrokePreview::execute_stroke_draw_immediate_main_live_sample_pass(
|
||||
const Brush& brush,
|
||||
bool copy_stroke_destination,
|
||||
const StrokeFrame& frame,
|
||||
const glm::vec2& size)
|
||||
{
|
||||
(void)brush;
|
||||
(void)copy_stroke_destination;
|
||||
(void)size;
|
||||
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,
|
||||
});
|
||||
m_rtt.unbindFramebuffer();
|
||||
|
||||
apply_stroke_preview_viewport(vp.x, vp.y, vp.width, vp.height);
|
||||
apply_stroke_preview_clear_color(cc);
|
||||
}
|
||||
|
||||
Image NodeStrokePreview::render_to_image()
|
||||
|
||||
Reference in New Issue
Block a user