Extract retained stroke preview pass orchestration plan
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "../libs/glm/glm/glm.hpp"
|
||||
#include "../libs/glm/glm/ext/matrix_clip_space.hpp"
|
||||
|
||||
#include "legacy_canvas_stroke_shader_services.h"
|
||||
#include "legacy_canvas_stroke_services.h"
|
||||
#include "paint_renderer/compositor.h"
|
||||
|
||||
@@ -224,6 +225,98 @@ struct LegacyNodeStrokePreviewPassSequenceRequest {
|
||||
return true;
|
||||
}
|
||||
|
||||
struct LegacyNodeStrokePreviewPassOrchestrationPlan {
|
||||
pp::paint_renderer::CanvasStrokeFeedbackPlan feedback {};
|
||||
pp::paint_renderer::CanvasStrokeMaterialPlan material {};
|
||||
pp::paint_renderer::StrokePreviewCompositePlan composite {};
|
||||
LegacyStrokeShaderSetupUniforms stroke_shader {};
|
||||
bool copy_stroke_destination = false;
|
||||
bool background_colorize = false;
|
||||
};
|
||||
|
||||
struct LegacyNodeStrokePreviewPassOrchestrationRequest {
|
||||
pp::renderer::RenderDeviceFeatures features {};
|
||||
glm::vec2 preview_size {};
|
||||
float pattern_scale = 0.0f;
|
||||
bool pattern_flipx = false;
|
||||
bool pattern_flipy = false;
|
||||
bool pattern_invert = false;
|
||||
float pattern_brightness = 0.0f;
|
||||
float pattern_contrast = 0.0f;
|
||||
float pattern_depth = 0.0f;
|
||||
bool pattern_rand_offset = false;
|
||||
bool pattern_enabled = false;
|
||||
bool pattern_eachsample = false;
|
||||
float tip_mix = 0.0f;
|
||||
float tip_wet = 0.0f;
|
||||
float tip_noise = 0.0f;
|
||||
bool dual_enabled = false;
|
||||
int dual_blend_mode = 0;
|
||||
float dual_opacity = 0.0f;
|
||||
int pattern_blend_mode = 0;
|
||||
int blend_mode = 0;
|
||||
glm::mat4 mvp { 1.0f };
|
||||
};
|
||||
|
||||
[[nodiscard]] inline LegacyNodeStrokePreviewPassOrchestrationPlan
|
||||
plan_legacy_node_stroke_preview_pass_orchestration(
|
||||
const LegacyNodeStrokePreviewPassOrchestrationRequest& request) noexcept
|
||||
{
|
||||
LegacyNodeStrokePreviewPassOrchestrationPlan plan;
|
||||
plan.feedback = plan_legacy_node_stroke_preview_feedback(
|
||||
request.features,
|
||||
static_cast<int>(request.preview_size.x),
|
||||
static_cast<int>(request.preview_size.y));
|
||||
plan.copy_stroke_destination = !plan.feedback.reads_destination_color;
|
||||
plan.material = plan_legacy_canvas_stroke_material(
|
||||
pp::paint_renderer::CanvasStrokeMaterialRequest {
|
||||
.destination_feedback_needed = plan.copy_stroke_destination,
|
||||
.pattern_enabled = request.pattern_enabled,
|
||||
.pattern_eachsample = request.pattern_eachsample,
|
||||
.wet_blend = request.tip_wet > 0.0f,
|
||||
.mix_blend = request.tip_mix > 0.0f,
|
||||
.noise_enabled = request.tip_noise > 0.0f,
|
||||
.dual_brush_enabled = request.dual_enabled,
|
||||
.dual_blend_mode = request.dual_blend_mode,
|
||||
.pattern_blend_mode = request.pattern_blend_mode,
|
||||
.dual_alpha = request.dual_opacity,
|
||||
});
|
||||
plan.composite = plan_legacy_node_stroke_preview_composite(
|
||||
request.tip_mix > 0.0f,
|
||||
plan.material.composite_pass.use_dual,
|
||||
plan.material.composite_pass.use_pattern);
|
||||
|
||||
glm::vec2 preview_pattern_scale(request.pattern_scale);
|
||||
if (request.pattern_flipx) {
|
||||
preview_pattern_scale.x *= -1.0f;
|
||||
}
|
||||
if (request.pattern_flipy) {
|
||||
preview_pattern_scale.y *= -1.0f;
|
||||
}
|
||||
|
||||
plan.stroke_shader = LegacyStrokeShaderSetupUniforms {
|
||||
.resolution = request.preview_size,
|
||||
.pattern = {
|
||||
.scale = preview_pattern_scale,
|
||||
.invert = static_cast<float>(request.pattern_invert),
|
||||
.brightness = request.pattern_brightness,
|
||||
.contrast = request.pattern_contrast,
|
||||
.depth = request.pattern_depth,
|
||||
.blend_mode = request.pattern_blend_mode,
|
||||
.offset = glm::vec2(request.pattern_rand_offset ? 0.5f : 0.0f),
|
||||
},
|
||||
.mvp = request.mvp,
|
||||
.uses_destination_feedback = plan.copy_stroke_destination,
|
||||
.uses_pattern = false,
|
||||
.mix_alpha = 0.0f,
|
||||
.wet = 0.0f,
|
||||
.noise = 0.0f,
|
||||
.set_opacity = false,
|
||||
};
|
||||
plan.background_colorize = request.tip_mix > 0.0f || request.blend_mode != 0;
|
||||
return plan;
|
||||
}
|
||||
|
||||
struct LegacyNodeStrokePreviewStrokePoint {
|
||||
glm::vec3 position {};
|
||||
float pressure = 0.0f;
|
||||
|
||||
Reference in New Issue
Block a user