pixel based brush size, Photoshop slider curve, improve abr import

This commit is contained in:
2019-02-23 20:46:20 +01:00
parent e1f82373c6
commit 3a1a48a0d0
15 changed files with 218 additions and 104 deletions

View File

@@ -141,13 +141,13 @@ StrokeSample Stroke::randomize_sample(const glm::vec3& pos, float pressure, floa
float randflipy = m_brush->m_tip_randflipy ? rnd_bneg() : 1.f;
StrokeSample s;
s.scale.x = randflipx * (m_brush->m_tip_flipx ? -1.f : 1.f) *
s.scale.x = m_brush->m_tip_width * 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 = 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.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.size = 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);
@@ -255,8 +255,22 @@ void Stroke::add_point(glm::vec3 pos, float pressure)
if (m_brush->m_tip_size_pressure)
{
float size = glm::min(m_brush->m_tip_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), m_max_size);
m_step = glm::max(m_brush->m_tip_spacing * size * pressure * 800.f, 0.1f);
float aspect_width = glm::min(1.f, m_brush->m_tip_aspect * 2.f);
float raw_size = aspect_width * m_brush->m_tip_width * 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);
if (raw_size < 2.f)
m_step = glm::max(0.5f, m_brush->m_tip_spacing) * size;
else if (raw_size < 10.f)
m_step = glm::max(0.2f, m_brush->m_tip_spacing) * size;
else if (raw_size < 30.f)
m_step = glm::max(0.1f, m_brush->m_tip_spacing) * size;
else if (raw_size < 50.f)
m_step = glm::max(0.05f, m_brush->m_tip_spacing) * size;
else if (raw_size < 200.f)
m_step = glm::max(0.01f, m_brush->m_tip_spacing) * size;
else
m_step = m_brush->m_tip_spacing * size;
}
float dist = m_keypoints.empty() ? m_step :
@@ -285,8 +299,24 @@ void Stroke::start(const std::shared_ptr<Brush>& brush)
m_dir_valid = false;
m_dir_dist = 0;
m_brush = brush;
float size = glm::min(m_brush->m_tip_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), m_max_size);
m_step = glm::max(m_brush->m_tip_spacing * size * 800.f, 1.f);
float aspect_width = glm::min(1.f, m_brush->m_tip_aspect * 2.f);
float raw_size = aspect_width * m_brush->m_tip_width * 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);
if (raw_size < 2.f)
m_step = glm::max(0.5f, m_brush->m_tip_spacing) * size;
else if (raw_size < 10.f)
m_step = glm::max(0.2f, m_brush->m_tip_spacing) * size;
else if (raw_size < 30.f)
m_step = glm::max(0.1f, m_brush->m_tip_spacing) * size;
else if (raw_size < 50.f)
m_step = glm::max(0.05f, m_brush->m_tip_spacing) * size;
else if (raw_size < 200.f)
m_step = glm::max(0.01f, m_brush->m_tip_spacing) * size;
else
m_step = m_brush->m_tip_spacing * size;
m_direction.resize(std::max<int>(1, m_brush->m_tip_angle_delay * 200.f / m_step));
prng.seed(0);
}