improve brush jitter

This commit is contained in:
2019-02-02 15:10:09 +01:00
parent fe7c357bcc
commit e9ead45447
2 changed files with 6 additions and 5 deletions

View File

@@ -129,7 +129,7 @@ bool BrushMesh::create()
StrokeSample Stroke::randomize_sample(const glm::vec3& pos, float pressure, float curve_angle)
{
auto rnd_nor = [&] { return float((double)prng() / (double)prng.max()); }; // normalized [0, +1]
//auto rnd_neg = [&] { return float((double)prng() / (double)prng.max() * 2.0 - 1.0); }; // normalized [-1, +1]
auto rnd_neg = [&] { return float((double)prng() / (double)prng.max() * 2.0 - 1.0); }; // normalized [-1, +1]
auto rnd_rad = [&] { return float((double)prng() / (double)prng.max() * M_PI * 2.0); }; // normalized [0, 2pi]
auto rnd_vec = [&] { float rad = rnd_rad(); return glm::vec3(cosf(rad), sinf(rad), 0); }; // normalized direction vector
@@ -139,9 +139,9 @@ StrokeSample Stroke::randomize_sample(const glm::vec3& pos, float pressure, floa
StrokeSample s;
s.origin = pos;
s.angle = -curve_angle + (m_brush->m_tip_angle + rnd_nor() * m_brush->m_jitter_angle) * (float)(M_PI * 2.0);
s.pos = pos + (rnd_vec() * m_brush->m_jitter_spread * 100.f);
s.angle = -curve_angle + (m_brush->m_tip_angle + rnd_neg() * m_brush->m_jitter_angle) * (float)(M_PI * 2.0);
s.size = 800.f * size * (1.f - rnd_nor() * m_brush->m_jitter_scale) * size_dyn;
s.pos = pos + (rnd_vec() * m_brush->m_jitter_spread * s.size);
s.flow = m_brush->m_tip_flow * (1.f - rnd_nor() * m_brush->m_jitter_flow) * flow_dyn;
auto hsv = convert_rgb2hsv(m_brush->m_tip_color);
hsv.x = glm::clamp(glm::mix(hsv.x, (pressure - 0.5f) * 2.0f, m_brush->m_tip_hue * (float)m_brush->m_tip_hue_pressure) + (rnd_nor() - 0.5f) * m_brush->m_jitter_hue, 0.f, 1.f);

View File

@@ -151,8 +151,8 @@ void NodePanelStroke::init_controls()
if (on_brush_changed)
on_brush_changed(this, m_brush_popup->get_texture_path(index), m_brush_popup->get_thumb_path(index));
m_brush_thumb->set_image(m_brush_popup->get_thumb_path(index));
m_brush_popup->mouse_release();
m_brush_popup->parent->remove_child(m_brush_popup.get());
//m_brush_popup->mouse_release();
//m_brush_popup->parent->remove_child(m_brush_popup.get());
};
};
@@ -209,6 +209,7 @@ void NodePanelStroke::init_controls()
});
};
update_controls();
}
void NodePanelStroke::init_slider(NodeSliderH*& target, const char* id, float Brush::* prop)