add roundness/aspect jitter
This commit is contained in:
@@ -561,6 +561,9 @@
|
||||
<node height="20" justify="center">
|
||||
<text text="Angle"/>
|
||||
</node>
|
||||
<node height="20" justify="center" margin="0 0 20 0">
|
||||
<text text="Aspect"/>
|
||||
</node>
|
||||
<node height="20" justify="center" margin="0 0 25 0">
|
||||
<text text="Scatter"/>
|
||||
</node>
|
||||
@@ -593,6 +596,13 @@
|
||||
<node height="20" pad="1" width="100%">
|
||||
<slider-h id="jitter-angle"/>
|
||||
</node>
|
||||
<node height="40" pad="1" width="100%" dir="col">
|
||||
<slider-h id="jitter-aspect" height="19" value="0"/>
|
||||
<node align="center" dir="row">
|
||||
<checkbox width="20" height="19" id="jitter-aspect-bothaxis"/>
|
||||
<text text="both axis"/>
|
||||
</node>
|
||||
</node>
|
||||
<node height="40" pad="1" width="100%" dir="col" margin="0 0 5 0">
|
||||
<slider-h id="jitter-scatter" height="19" value="0"/>
|
||||
<node align="center" dir="row">
|
||||
|
||||
12
src/abr.cpp
12
src/abr.cpp
@@ -161,12 +161,12 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
|
||||
}
|
||||
}
|
||||
|
||||
// Shape dynamics
|
||||
if (p->value<Boolean>("useTipDynamics"))
|
||||
{
|
||||
// other properties 'brushProjection', 'minimumRoundness', 'roundnessDynamics', 'tiltScale'
|
||||
|
||||
auto jitter_size = p->get<Descriptor>("szVr");
|
||||
if (jitter_size)
|
||||
if (auto jitter_size = p->get<Descriptor>("szVr"))
|
||||
{
|
||||
b->m_jitter_scale = jitter_size->value<UnitFloat>("jitter") * 0.01f;
|
||||
// TODO: p->value<UnitFloat>("minimumDiameter") * 0.001f; // minimum size
|
||||
@@ -174,8 +174,7 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
|
||||
b->m_tip_size_pressure = true;
|
||||
}
|
||||
|
||||
auto jitter_angle = p->get<Descriptor>("angleDynamics");
|
||||
if (jitter_angle)
|
||||
if (auto jitter_angle = p->get<Descriptor>("angleDynamics"))
|
||||
{
|
||||
auto mode = jitter_angle->value<Integer>("bVTy");
|
||||
if (mode == 0)
|
||||
@@ -194,6 +193,11 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
|
||||
}
|
||||
}
|
||||
|
||||
if (auto roundness = p->get<Descriptor>("roundnessDynamics"))
|
||||
{
|
||||
b->m_jitter_aspect = (1.f - roundness->value<UnitFloat>("jitter") * 0.01) * 0.5f + 0.5f;
|
||||
}
|
||||
|
||||
b->m_tip_randflipx = p->value<Boolean>("flipX");
|
||||
b->m_tip_randflipy = p->value<Boolean>("flipY");
|
||||
}
|
||||
|
||||
@@ -140,15 +140,22 @@ StrokeSample Stroke::randomize_sample(const glm::vec3& pos, float pressure, floa
|
||||
float size = glm::min(m_brush->m_tip_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), m_max_size);
|
||||
float randflipx = m_brush->m_tip_randflipx ? rnd_bneg() : 1.f;
|
||||
float randflipy = m_brush->m_tip_randflipy ? rnd_bneg() : 1.f;
|
||||
|
||||
glm::vec2 scatter_axis = m_brush->m_jitter_scatter_bothaxis ? glm::vec2(1.f, 1.f) : glm::vec2(0.f, 1.f);
|
||||
auto scatter_scale = glm::vec3(scatter_axis * glm::orientate2(-dir_angle), 1.f);
|
||||
|
||||
|
||||
float aspect_jitter = m_brush->m_jitter_aspect_bothaxis ?
|
||||
rnd_neg() * 0.5f * m_brush->m_jitter_aspect :
|
||||
rnd_nor() * 0.5f * m_brush->m_jitter_aspect;
|
||||
float aspect = glm::clamp(m_brush->m_tip_aspect + aspect_jitter, 0.1f, 0.9f);
|
||||
glm::vec2 aspect_scale = {
|
||||
(aspect <= 0.5 ? aspect * 2.f : 1.f),
|
||||
(aspect > 0.5 ? 1.f - (aspect - .5f) * 2.f : 1.f)
|
||||
};
|
||||
|
||||
StrokeSample s;
|
||||
s.scale.x = m_brush->m_tip_scale.x * randflipx * (m_brush->m_tip_flipx ? -1.f : 1.f) *
|
||||
(m_brush->m_tip_aspect <= 0.5 ? m_brush->m_tip_aspect * 2.f : 1.f);
|
||||
s.scale.y = m_brush->m_tip_scale.y * randflipy * (m_brush->m_tip_flipy ? -1.f : 1.f) *
|
||||
(m_brush->m_tip_aspect > 0.5 ? 1.f - (m_brush->m_tip_aspect - .5f) * 2.f : 1.f);
|
||||
s.origin = pos;
|
||||
s.scale = m_brush->m_tip_scale * randflipx * (m_brush->m_tip_flipx ? -1.f : 1.f) * aspect_scale;
|
||||
s.angle = (m_brush->m_tip_angle + rnd_neg() * m_brush->m_jitter_angle) * (float)(M_PI * 2.0);
|
||||
s.size = size * (1.f - rnd_nor() * m_brush->m_jitter_scale) * size_dyn;
|
||||
s.pos = pos + (scatter_scale * rnd_vec() * m_brush->m_jitter_scatter * s.size);
|
||||
@@ -272,7 +279,7 @@ void Stroke::add_point(glm::vec3 pos, float pressure)
|
||||
|
||||
if (m_brush->m_tip_size_pressure)
|
||||
{
|
||||
float aspect_width = glm::min(1.f, m_brush->m_tip_aspect * 2.f);
|
||||
float aspect_width = glm::min(1.f, glm::clamp(m_brush->m_tip_aspect, .1f, .9f) * 2.f);
|
||||
float raw_size = aspect_width * glm::min(m_brush->m_tip_scale.x, m_brush->m_tip_scale.y) * m_brush->m_tip_size;
|
||||
float size = glm::clamp(raw_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), 1.f, m_max_size);
|
||||
|
||||
@@ -317,7 +324,7 @@ void Stroke::start(const std::shared_ptr<Brush>& brush)
|
||||
m_dir_dist = 0;
|
||||
m_brush = brush;
|
||||
|
||||
float aspect_width = glm::min(1.f, m_brush->m_tip_aspect * 2.f);
|
||||
float aspect_width = glm::min(1.f, glm::clamp(m_brush->m_tip_aspect, .1f, .9f) * 2.f);
|
||||
float raw_size = aspect_width * glm::min(m_brush->m_tip_scale.x, m_brush->m_tip_scale.y) * m_brush->m_tip_size;
|
||||
float size = glm::clamp(raw_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), 1.f, m_max_size);
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
float m_jitter_hue = 0;
|
||||
float m_jitter_sat = 0;
|
||||
float m_jitter_val = 0;
|
||||
float m_jitter_aspect = 0;
|
||||
bool m_jitter_aspect_bothaxis = false;
|
||||
int m_blend_mode = 0;
|
||||
|
||||
bool m_tip_invert = false;
|
||||
|
||||
@@ -512,6 +512,8 @@ bool NodePanelBrushPreset::save()
|
||||
i.m_jitter_hue = b->m_jitter_hue;
|
||||
i.m_jitter_sat = b->m_jitter_sat;
|
||||
i.m_jitter_val = b->m_jitter_val;
|
||||
i.m_jitter_aspect = b->m_jitter_aspect;
|
||||
i.m_jitter_aspect_bothaxis = b->m_jitter_aspect_bothaxis;
|
||||
i.m_blend_mode = b->m_blend_mode;
|
||||
|
||||
i.m_tip_invert = b->m_tip_invert;
|
||||
@@ -617,7 +619,9 @@ bool NodePanelBrushPreset::restore()
|
||||
b->m_jitter_hue = i.m_jitter_hue;
|
||||
b->m_jitter_sat = i.m_jitter_sat;
|
||||
b->m_jitter_val = i.m_jitter_val;
|
||||
b->m_blend_mode = i.m_blend_mode;
|
||||
b->m_jitter_aspect = i.m_jitter_aspect;
|
||||
b->m_jitter_aspect_bothaxis = i.m_jitter_aspect_bothaxis;
|
||||
b->m_blend_mode = i.m_blend_mode;
|
||||
|
||||
b->m_tip_invert = i.m_tip_invert;
|
||||
b->m_tip_flipx = i.m_tip_flipx;
|
||||
|
||||
@@ -132,7 +132,8 @@ class NodePanelBrushPreset : public Node
|
||||
float m_jitter_hue = 0;
|
||||
float m_jitter_sat = 0;
|
||||
float m_jitter_val = 0;
|
||||
float m_dual_aspect = 0.5f;
|
||||
float m_jitter_aspect = 0;
|
||||
bool m_jitter_aspect_bothaxis = false;
|
||||
int m_blend_mode = 0;
|
||||
|
||||
bool m_tip_invert = false;
|
||||
@@ -156,6 +157,7 @@ class NodePanelBrushPreset : public Node
|
||||
float m_dual_opacity = 1.f;
|
||||
float m_dual_rotate = .25f;
|
||||
float m_dual_angle = 0;
|
||||
float m_dual_aspect = 0.5f;
|
||||
int m_dual_count = 1;
|
||||
|
||||
bool m_pattern_eachsample = false;
|
||||
|
||||
@@ -164,9 +164,11 @@ void NodePanelStroke::update_controls()
|
||||
m_jitter_hue->m_value.x = b->m_jitter_hue;
|
||||
m_jitter_sat->m_value.x = b->m_jitter_sat;
|
||||
m_jitter_val->m_value.x = b->m_jitter_val;
|
||||
m_jitter_aspect->m_value.x = b->m_jitter_aspect;
|
||||
m_tip_angle_follow->checked = b->m_tip_angle_follow;
|
||||
m_tip_flow_pressure->checked = b->m_tip_flow_pressure;
|
||||
m_tip_size_pressure->checked = b->m_tip_size_pressure;
|
||||
m_jitter_aspect_bothaxis->checked = b->m_jitter_aspect_bothaxis;
|
||||
|
||||
m_tip_invert->checked = b->m_tip_invert;
|
||||
m_tip_flipx->checked = b->m_tip_flipx;
|
||||
@@ -441,6 +443,7 @@ void NodePanelStroke::init_controls()
|
||||
init_slider(m_jitter_hue, "jitter-hue", &Brush::m_jitter_hue);
|
||||
init_slider(m_jitter_sat, "jitter-sat", &Brush::m_jitter_sat);
|
||||
init_slider(m_jitter_val, "jitter-val", &Brush::m_jitter_val);
|
||||
init_slider(m_jitter_aspect, "jitter-aspect", &Brush::m_jitter_aspect);
|
||||
|
||||
init_checkbox(m_tip_angle_init, "tip-angle-init", &Brush::m_tip_angle_init);
|
||||
init_checkbox(m_tip_angle_follow, "tip-angle-follow", &Brush::m_tip_angle_follow);
|
||||
@@ -448,6 +451,7 @@ void NodePanelStroke::init_controls()
|
||||
init_checkbox(m_tip_opacity_pressure, "tip-opacity-pressure", &Brush::m_tip_opacity_pressure);
|
||||
init_checkbox(m_tip_size_pressure, "tip-size-pressure", &Brush::m_tip_size_pressure);
|
||||
init_checkbox(m_jitter_scatter_bothaxis, "jitter-scatter-bothaxis", &Brush::m_jitter_scatter_bothaxis);
|
||||
init_checkbox(m_jitter_aspect_bothaxis, "jitter-aspect-bothaxis", &Brush::m_jitter_aspect_bothaxis);
|
||||
|
||||
init_checkbox(m_tip_invert, "tip-invert", &Brush::m_tip_invert);
|
||||
init_checkbox(m_tip_flipx, "tip-flipx", &Brush::m_tip_flipx);
|
||||
|
||||
@@ -34,12 +34,14 @@ public:
|
||||
NodeSliderH* m_jitter_hue;
|
||||
NodeSliderH* m_jitter_sat;
|
||||
NodeSliderH* m_jitter_val;
|
||||
NodeSliderH* m_jitter_aspect;
|
||||
NodeCheckBox* m_tip_angle_init;
|
||||
NodeCheckBox* m_tip_angle_follow;
|
||||
NodeCheckBox* m_tip_flow_pressure;
|
||||
NodeCheckBox* m_tip_opacity_pressure;
|
||||
NodeCheckBox* m_tip_size_pressure;
|
||||
NodeCheckBox* m_jitter_scatter_bothaxis;
|
||||
NodeCheckBox* m_jitter_aspect_bothaxis;
|
||||
NodeButtonCustom* m_brush_button;
|
||||
NodeButtonCustom* m_dual_brush_button;
|
||||
NodeButtonCustom* m_pattern_button;
|
||||
|
||||
Reference in New Issue
Block a user