Extract preview mix request helper
This commit is contained in:
@@ -149,6 +149,62 @@ pp::panopainter::LegacyStrokeCompositeUniforms make_stroke_preview_mix_composite
|
||||
};
|
||||
}
|
||||
|
||||
pp::panopainter::LegacyNodeStrokePreviewMixExecutionRequest make_stroke_preview_mix_execution_request(
|
||||
const pp::panopainter::LegacyNodeStrokePreviewMixPassPlan::ShaderPlan& shader,
|
||||
RTT& mixer_rtt,
|
||||
const Brush& brush,
|
||||
Sampler& linear_sampler,
|
||||
Texture2D& background_texture,
|
||||
Texture2D& stroke_texture,
|
||||
Texture2D& dual_texture,
|
||||
gl_state& gl,
|
||||
const glm::vec2& bb_min,
|
||||
const glm::vec2& bb_sz,
|
||||
std::function<void()> draw_mix)
|
||||
{
|
||||
return pp::panopainter::LegacyNodeStrokePreviewMixExecutionRequest {
|
||||
.shader = shader,
|
||||
.mixer_width = mixer_rtt.getWidth(),
|
||||
.mixer_height = mixer_rtt.getHeight(),
|
||||
.scissor_x = static_cast<int>(bb_min.x),
|
||||
.scissor_y = static_cast<int>(bb_min.y),
|
||||
.scissor_width = static_cast<int>(bb_sz.x),
|
||||
.scissor_height = static_cast<int>(bb_sz.y),
|
||||
.save_state = [&] { gl.save(); },
|
||||
.setup_mix_shader = [&](const pp::panopainter::LegacyNodeStrokePreviewMixPassPlan::ShaderPlan& shader_plan) {
|
||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||
make_stroke_preview_mix_composite_uniforms(shader_plan));
|
||||
},
|
||||
.bind_mixer_framebuffer = [&] { mixer_rtt.bindFramebuffer(); },
|
||||
.configure_mix_target_state = [&](int mixer_width,
|
||||
int mixer_height,
|
||||
int scissor_x,
|
||||
int scissor_y,
|
||||
int scissor_width,
|
||||
int scissor_height) {
|
||||
apply_stroke_preview_viewport(0, 0, mixer_width, mixer_height);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::depth_test_state(), false);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::scissor_test_state(), true);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::blend_state(), false);
|
||||
apply_stroke_preview_scissor(scissor_x, scissor_y, scissor_width, scissor_height);
|
||||
},
|
||||
.bind_mix_inputs = [&] {
|
||||
linear_sampler.bind(stroke_preview_composite_slots::kBackground);
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kBackground);
|
||||
background_texture.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kStroke);
|
||||
stroke_texture.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kDual);
|
||||
dual_texture.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kPattern);
|
||||
brush.m_pattern_texture ? brush.m_pattern_texture->bind() : unbind_texture_2d();
|
||||
},
|
||||
.draw_mix = std::move(draw_mix),
|
||||
.unbind_mixer_framebuffer = [&] { mixer_rtt.unbindFramebuffer(); },
|
||||
.restore_state = [&] { gl.restore(); },
|
||||
};
|
||||
}
|
||||
|
||||
void execute_stroke_preview_final_composite_pass(const StrokePreviewCompositePassInputs& inputs)
|
||||
{
|
||||
[[maybe_unused]] const bool composite_ok =
|
||||
@@ -915,64 +971,20 @@ NodeStrokePreview::make_stroke_draw_mix_execution_request(
|
||||
const glm::vec2& bb_min,
|
||||
const glm::vec2& bb_sz)
|
||||
{
|
||||
return pp::panopainter::LegacyNodeStrokePreviewMixExecutionRequest {
|
||||
.shader = mix_pass.shader,
|
||||
.mixer_width = m_rtt_mixer.getWidth(),
|
||||
.mixer_height = m_rtt_mixer.getHeight(),
|
||||
.scissor_x = static_cast<int>(bb_min.x),
|
||||
.scissor_y = static_cast<int>(bb_min.y),
|
||||
.scissor_width = static_cast<int>(bb_sz.x),
|
||||
.scissor_height = static_cast<int>(bb_sz.y),
|
||||
.save_state = [&] {
|
||||
gl.save();
|
||||
},
|
||||
.setup_mix_shader = [&](const pp::panopainter::LegacyNodeStrokePreviewMixPassPlan::ShaderPlan& shader_plan) {
|
||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||
make_stroke_preview_mix_composite_uniforms(shader_plan));
|
||||
},
|
||||
.bind_mixer_framebuffer = [&] {
|
||||
m_rtt_mixer.bindFramebuffer();
|
||||
},
|
||||
.configure_mix_target_state = [&](
|
||||
int mixer_width,
|
||||
int mixer_height,
|
||||
int scissor_x,
|
||||
int scissor_y,
|
||||
int scissor_width,
|
||||
int scissor_height) {
|
||||
apply_stroke_preview_viewport(0, 0, mixer_width, mixer_height);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::depth_test_state(), false);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::scissor_test_state(), true);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::blend_state(), false);
|
||||
apply_stroke_preview_scissor(
|
||||
scissor_x,
|
||||
scissor_y,
|
||||
scissor_width,
|
||||
scissor_height);
|
||||
},
|
||||
.bind_mix_inputs = [&] {
|
||||
m_sampler_linear.bind(stroke_preview_composite_slots::kBackground);
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kBackground);
|
||||
m_tex_background.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kStroke);
|
||||
m_rtt.bindTexture();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kDual);
|
||||
m_tex_dual.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kPattern);
|
||||
m_brush->m_pattern_texture ?
|
||||
m_brush->m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
.draw_mix = [&] {
|
||||
return make_stroke_preview_mix_execution_request(
|
||||
mix_pass.shader,
|
||||
m_rtt_mixer,
|
||||
*m_brush,
|
||||
m_sampler_linear,
|
||||
m_tex_background,
|
||||
m_rtt,
|
||||
m_tex_dual,
|
||||
gl,
|
||||
bb_min,
|
||||
bb_sz,
|
||||
[this] {
|
||||
m_plane.draw_fill();
|
||||
},
|
||||
.unbind_mixer_framebuffer = [&] {
|
||||
m_rtt_mixer.unbindFramebuffer();
|
||||
},
|
||||
.restore_state = [&] {
|
||||
gl.restore();
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Image NodeStrokePreview::render_to_image()
|
||||
|
||||
Reference in New Issue
Block a user