Route stroke mixer composite setup through helper

This commit is contained in:
2026-06-13 05:01:31 +02:00
parent 65d084ad8e
commit 0a01523212
4 changed files with 33 additions and 20 deletions

View File

@@ -437,21 +437,19 @@ void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz)
m_sampler.bind(1);
m_sampler.bind(2);
const auto& b = m_current_stroke->m_brush;
ShaderManager::use(kShader::CompDraw);
ShaderManager::u_int(kShaderUniform::Tex, 0);
//ShaderManager::u_int(kShaderUniform::TexA, 0);
ShaderManager::u_int(kShaderUniform::TexStroke, 1);
ShaderManager::u_int(kShaderUniform::TexMask, 2);
ShaderManager::u_vec2(kShaderUniform::Resolution, m_size);
ShaderManager::u_int(kShaderUniform::TexPattern, 3);
ShaderManager::u_float(kShaderUniform::Alpha, 1);
ShaderManager::u_int(kShaderUniform::Lock, false/*m_layers[layer_index]->m_alpha_locked*/);
ShaderManager::u_int(kShaderUniform::Mask, false/*m_smask_active*/);
ShaderManager::u_int(kShaderUniform::UseFragcoord, false);
ShaderManager::u_int(kShaderUniform::UseDual, false);
ShaderManager::u_int(kShaderUniform::UsePattern, false);
ShaderManager::u_int(kShaderUniform::BlendMode, b->m_blend_mode);
ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp_z);
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,
});
set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).bindTexture();
set_active_texture_unit(1);

View File

@@ -21,6 +21,11 @@ struct LegacyStrokeCompositeUniforms {
glm::vec2 resolution {};
LegacyStrokeCompositePatternUniforms pattern;
glm::mat4 mvp { 1.0f };
int texture_slot = 0;
int stroke_texture_slot = 1;
int mask_texture_slot = 2;
int dual_texture_slot = 3;
int pattern_texture_slot = 4;
float layer_alpha = 1.0f;
bool alpha_lock = false;
bool mask_enabled = false;
@@ -69,11 +74,11 @@ inline void setup_legacy_stroke_composite_shader(
const LegacyStrokeCompositeShaderExecution& execution) noexcept
{
execution.use_shader(kShader::CompDraw);
execution.set_int(kShaderUniform::Tex, 0);
execution.set_int(kShaderUniform::TexStroke, 1);
execution.set_int(kShaderUniform::TexMask, 2);
execution.set_int(kShaderUniform::TexDual, 3);
execution.set_int(kShaderUniform::TexPattern, 4);
execution.set_int(kShaderUniform::Tex, uniforms.texture_slot);
execution.set_int(kShaderUniform::TexStroke, uniforms.stroke_texture_slot);
execution.set_int(kShaderUniform::TexMask, uniforms.mask_texture_slot);
execution.set_int(kShaderUniform::TexDual, uniforms.dual_texture_slot);
execution.set_int(kShaderUniform::TexPattern, uniforms.pattern_texture_slot);
execution.set_vec2(kShaderUniform::Resolution, uniforms.resolution);
execution.set_float(kShaderUniform::Alpha, uniforms.layer_alpha);
execution.set_int(kShaderUniform::Lock, uniforms.alpha_lock);