Own runtime threads and thin platform/canvas seams
This commit is contained in:
@@ -468,12 +468,6 @@ void NodeCanvas::draw()
|
||||
m_canvas->m_layers[layer_index]->m_opacity == .0f || !faces))
|
||||
continue;
|
||||
|
||||
if (use_blend)
|
||||
{
|
||||
m_blender_rtt.bindFramebuffer();
|
||||
m_blender_rtt.clear();
|
||||
}
|
||||
|
||||
int z = (int)(m_canvas->m_layers.size() - i);
|
||||
auto plane_mvp_z = proj * camera *
|
||||
glm::scale(glm::vec3(z + 1)) *
|
||||
@@ -481,174 +475,177 @@ void NodeCanvas::draw()
|
||||
m_canvas->m_plane_transform[plane_index] *
|
||||
glm::translate(glm::vec3(0, 0, -1));
|
||||
|
||||
if (m_canvas->m_current_stroke && m_canvas->m_current_mode == kCanvasMode::Erase && m_canvas->m_show_tmp && m_canvas->m_current_layer_idx == layer_index)
|
||||
{
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(1);
|
||||
m_sampler.bind(2);
|
||||
|
||||
//ShaderManager::u_vec2(kShaderUniform::Resolution, zw(m_canvas->m_box) / zoom);
|
||||
//ShaderManager::u_int(kShaderUniform::Lock, m_canvas->m_layers[layer_index]->m_alpha_locked);
|
||||
pp::panopainter::setup_legacy_stroke_erase_shader(
|
||||
pp::panopainter::LegacyStrokeEraseUniforms {
|
||||
.mvp = plane_mvp_z,
|
||||
.texture_slot = 0,
|
||||
.stroke_texture_slot = 1,
|
||||
.mask_texture_slot = 2,
|
||||
.mask_enabled = m_canvas->m_smask_active,
|
||||
});
|
||||
set_active_texture_unit(1);
|
||||
m_canvas->m_tmp[plane_index].bindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_canvas->m_smask.rtt(plane_index).bindTexture();
|
||||
for (int frame = onion_range.first_frame; frame <= onion_range.last_frame; frame++)
|
||||
{
|
||||
const float onion_alpha = pp::app::animation_onion_frame_alpha(onion_range, frame);
|
||||
ShaderManager::u_float(kShaderUniform::Alpha, m_canvas->m_layers[layer_index]->m_opacity* onion_alpha);
|
||||
set_active_texture_unit(0);
|
||||
m_canvas->m_layers[layer_index]->rtt(plane_index, frame).bindTexture();
|
||||
m_face_plane.draw_fill();
|
||||
set_active_texture_unit(0);
|
||||
m_canvas->m_layers[layer_index]->rtt(plane_index, frame).unbindTexture();
|
||||
}
|
||||
set_active_texture_unit(2);
|
||||
m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
||||
set_active_texture_unit(1);
|
||||
m_canvas->m_tmp[plane_index].unbindTexture();
|
||||
}
|
||||
else if(m_canvas->m_current_stroke && m_canvas->m_show_tmp && m_canvas->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);
|
||||
|
||||
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 = plane_mvp_z,
|
||||
.layer_alpha = 1.0f,
|
||||
.alpha_lock = m_canvas->m_layers[layer_index]->m_alpha_locked,
|
||||
.mask_enabled = m_canvas->m_smask_active,
|
||||
.use_fragcoord = false,
|
||||
.blend_mode = b->m_blend_mode,
|
||||
.use_dual = b->m_dual_enabled,
|
||||
.dual_blend_mode = b->m_dual_blend_mode,
|
||||
.dual_alpha = b->m_dual_opacity,
|
||||
.use_pattern = b->m_pattern_enabled && !b->m_pattern_eachsample,
|
||||
});
|
||||
|
||||
set_active_texture_unit(1);
|
||||
m_canvas->m_tmp[plane_index].bindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_canvas->m_smask.rtt(plane_index).bindTexture();
|
||||
set_active_texture_unit(3);
|
||||
if (b->m_dual_enabled)
|
||||
m_canvas->m_tmp_dual[plane_index].bindTexture();
|
||||
set_active_texture_unit(4);
|
||||
b->m_pattern_texture ?
|
||||
b->m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
for (int frame = onion_range.first_frame; frame <= onion_range.last_frame; frame++)
|
||||
{
|
||||
const float onion_alpha = pp::app::animation_onion_frame_alpha(onion_range, frame);
|
||||
ShaderManager::u_float(kShaderUniform::Alpha, m_canvas->m_layers[layer_index]->m_opacity * onion_alpha);
|
||||
set_active_texture_unit(0);
|
||||
m_canvas->m_layers[layer_index]->rtt(plane_index, frame).bindTexture();
|
||||
m_face_plane.draw_fill();
|
||||
set_active_texture_unit(0);
|
||||
m_canvas->m_layers[layer_index]->rtt(plane_index, frame).unbindTexture();
|
||||
}
|
||||
set_active_texture_unit(3);
|
||||
if (b->m_dual_enabled)
|
||||
m_canvas->m_tmp_dual[plane_index].unbindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
||||
set_active_texture_unit(1);
|
||||
m_canvas->m_tmp[plane_index].unbindTexture();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_canvas->m_cam_fov < 20.f ? m_sampler_nearest.bind(0) : m_sampler.bind(0);
|
||||
pp::panopainter::setup_legacy_canvas_draw_merge_texture_alpha_shader(
|
||||
pp::panopainter::LegacyCanvasDrawMergeTextureAlphaUniforms {
|
||||
.mvp = plane_mvp_z,
|
||||
.texture_slot = 0,
|
||||
.alpha = 1.f,
|
||||
.highlight = m_canvas->m_layers[layer_index]->m_hightlight,
|
||||
});
|
||||
|
||||
for (int frame = onion_range.first_frame; frame <= onion_range.last_frame; frame++)
|
||||
{
|
||||
const float onion_alpha = pp::app::animation_onion_frame_alpha(onion_range, frame);
|
||||
ShaderManager::u_float(kShaderUniform::Alpha, m_canvas->m_layers[layer_index]->m_opacity * onion_alpha);
|
||||
set_active_texture_unit(0);
|
||||
m_canvas->m_layers[layer_index]->rtt(plane_index, frame).bindTexture();
|
||||
m_face_plane.draw_fill();
|
||||
m_canvas->m_layers[layer_index]->rtt(plane_index, frame).unbindTexture();
|
||||
}
|
||||
}
|
||||
|
||||
if (use_blend)
|
||||
{
|
||||
m_blender_rtt.unbindFramebuffer();
|
||||
}
|
||||
|
||||
// draw the blended
|
||||
if (use_blend)
|
||||
{
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(2);
|
||||
|
||||
pp::panopainter::setup_legacy_canvas_draw_merge_texture_blend_shader(
|
||||
pp::panopainter::LegacyCanvasDrawMergeTextureBlendUniforms {
|
||||
.mvp = glm::ortho(-1, 1, -1, 1),
|
||||
.texture_slot = 0,
|
||||
.destination_texture_slot = 2,
|
||||
.use_destination_texture = copy_blend_destination,
|
||||
.blend_mode = m_canvas->m_layers[layer_index]->m_blend_mode,
|
||||
.alpha = 1.f,
|
||||
});
|
||||
|
||||
const auto draw_layer_frame = [&](int frame, float onion_alpha) {
|
||||
ShaderManager::u_float(kShaderUniform::Alpha, m_canvas->m_layers[layer_index]->m_opacity * onion_alpha);
|
||||
set_active_texture_unit(0);
|
||||
m_blender_rtt.bindTexture();
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
set_active_texture_unit(2);
|
||||
m_blender_bg.bind();
|
||||
copy_framebuffer_to_texture_2d(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
m_blender_bg.size().x,
|
||||
m_blender_bg.size().y);
|
||||
}
|
||||
|
||||
m_canvas->m_layers[layer_index]->rtt(plane_index, frame).bindTexture();
|
||||
m_face_plane.draw_fill();
|
||||
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
set_active_texture_unit(2);
|
||||
m_blender_bg.unbind();
|
||||
}
|
||||
set_active_texture_unit(0);
|
||||
m_blender_rtt.unbindTexture();
|
||||
}
|
||||
m_canvas->m_layers[layer_index]->rtt(plane_index, frame).unbindTexture();
|
||||
};
|
||||
|
||||
pp::panopainter::execute_legacy_canvas_draw_merge_layer_plane(
|
||||
m_canvas->m_current_stroke && m_canvas->m_current_mode == kCanvasMode::Erase && m_canvas->m_show_tmp && m_canvas->m_current_layer_idx == layer_index,
|
||||
m_canvas->m_current_stroke && m_canvas->m_show_tmp && m_canvas->m_current_layer_idx == layer_index,
|
||||
use_blend,
|
||||
onion_range.first_frame,
|
||||
onion_range.last_frame,
|
||||
[&](int frame) {
|
||||
return pp::app::animation_onion_frame_alpha(onion_range, frame);
|
||||
},
|
||||
{
|
||||
.bind_blender_framebuffer = [&] {
|
||||
m_blender_rtt.bindFramebuffer();
|
||||
},
|
||||
.clear_blender_framebuffer = [&] {
|
||||
m_blender_rtt.clear();
|
||||
},
|
||||
.unbind_blender_framebuffer = [&] {
|
||||
m_blender_rtt.unbindFramebuffer();
|
||||
},
|
||||
.prepare_temporary_erase = [&] {
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(1);
|
||||
m_sampler.bind(2);
|
||||
|
||||
//ShaderManager::u_vec2(kShaderUniform::Resolution, zw(m_canvas->m_box) / zoom);
|
||||
//ShaderManager::u_int(kShaderUniform::Lock, m_canvas->m_layers[layer_index]->m_alpha_locked);
|
||||
pp::panopainter::setup_legacy_stroke_erase_shader(
|
||||
pp::panopainter::LegacyStrokeEraseUniforms {
|
||||
.mvp = plane_mvp_z,
|
||||
.texture_slot = 0,
|
||||
.stroke_texture_slot = 1,
|
||||
.mask_texture_slot = 2,
|
||||
.mask_enabled = m_canvas->m_smask_active,
|
||||
});
|
||||
set_active_texture_unit(1);
|
||||
m_canvas->m_tmp[plane_index].bindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_canvas->m_smask.rtt(plane_index).bindTexture();
|
||||
},
|
||||
.draw_temporary_erase_frame = [&](int frame, float onion_alpha) {
|
||||
draw_layer_frame(frame, onion_alpha);
|
||||
},
|
||||
.cleanup_temporary_erase = [&] {
|
||||
set_active_texture_unit(2);
|
||||
m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
||||
set_active_texture_unit(1);
|
||||
m_canvas->m_tmp[plane_index].unbindTexture();
|
||||
},
|
||||
.prepare_temporary_paint = [&] {
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(1);
|
||||
m_sampler.bind(2);
|
||||
m_sampler.bind(3);
|
||||
m_sampler_stencil.bind(4);
|
||||
|
||||
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 = plane_mvp_z,
|
||||
.layer_alpha = 1.0f,
|
||||
.alpha_lock = m_canvas->m_layers[layer_index]->m_alpha_locked,
|
||||
.mask_enabled = m_canvas->m_smask_active,
|
||||
.use_fragcoord = false,
|
||||
.blend_mode = b->m_blend_mode,
|
||||
.use_dual = b->m_dual_enabled,
|
||||
.dual_blend_mode = b->m_dual_blend_mode,
|
||||
.dual_alpha = b->m_dual_opacity,
|
||||
.use_pattern = b->m_pattern_enabled && !b->m_pattern_eachsample,
|
||||
});
|
||||
|
||||
set_active_texture_unit(1);
|
||||
m_canvas->m_tmp[plane_index].bindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_canvas->m_smask.rtt(plane_index).bindTexture();
|
||||
set_active_texture_unit(3);
|
||||
if (b->m_dual_enabled)
|
||||
m_canvas->m_tmp_dual[plane_index].bindTexture();
|
||||
set_active_texture_unit(4);
|
||||
b->m_pattern_texture ?
|
||||
b->m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
.draw_temporary_paint_frame = [&](int frame, float onion_alpha) {
|
||||
draw_layer_frame(frame, onion_alpha);
|
||||
},
|
||||
.cleanup_temporary_paint = [&] {
|
||||
set_active_texture_unit(3);
|
||||
if (b->m_dual_enabled)
|
||||
m_canvas->m_tmp_dual[plane_index].unbindTexture();
|
||||
set_active_texture_unit(2);
|
||||
m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
||||
set_active_texture_unit(1);
|
||||
m_canvas->m_tmp[plane_index].unbindTexture();
|
||||
},
|
||||
.prepare_layer_texture = [&] {
|
||||
m_canvas->m_cam_fov < 20.f ? m_sampler_nearest.bind(0) : m_sampler.bind(0);
|
||||
pp::panopainter::setup_legacy_canvas_draw_merge_texture_alpha_shader(
|
||||
pp::panopainter::LegacyCanvasDrawMergeTextureAlphaUniforms {
|
||||
.mvp = plane_mvp_z,
|
||||
.texture_slot = 0,
|
||||
.alpha = 1.f,
|
||||
.highlight = m_canvas->m_layers[layer_index]->m_hightlight,
|
||||
});
|
||||
},
|
||||
.draw_layer_texture_frame = [&](int frame, float onion_alpha) {
|
||||
draw_layer_frame(frame, onion_alpha);
|
||||
},
|
||||
.cleanup_layer_texture = [&] {
|
||||
},
|
||||
.draw_blend = [&] {
|
||||
m_sampler.bind(0);
|
||||
m_sampler.bind(2);
|
||||
|
||||
pp::panopainter::setup_legacy_canvas_draw_merge_texture_blend_shader(
|
||||
pp::panopainter::LegacyCanvasDrawMergeTextureBlendUniforms {
|
||||
.mvp = glm::ortho(-1, 1, -1, 1),
|
||||
.texture_slot = 0,
|
||||
.destination_texture_slot = 2,
|
||||
.use_destination_texture = copy_blend_destination,
|
||||
.blend_mode = m_canvas->m_layers[layer_index]->m_blend_mode,
|
||||
.alpha = 1.f,
|
||||
});
|
||||
|
||||
set_active_texture_unit(0);
|
||||
m_blender_rtt.bindTexture();
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
set_active_texture_unit(2);
|
||||
m_blender_bg.bind();
|
||||
copy_framebuffer_to_texture_2d(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
m_blender_bg.size().x,
|
||||
m_blender_bg.size().y);
|
||||
}
|
||||
|
||||
m_face_plane.draw_fill();
|
||||
|
||||
if (copy_blend_destination)
|
||||
{
|
||||
set_active_texture_unit(2);
|
||||
m_blender_bg.unbind();
|
||||
}
|
||||
set_active_texture_unit(0);
|
||||
m_blender_rtt.unbindTexture();
|
||||
},
|
||||
});
|
||||
|
||||
#ifdef _DEBUG
|
||||
// draw dirty area
|
||||
|
||||
Reference in New Issue
Block a user