add roundness/aspect jitter

This commit is contained in:
2019-02-27 01:33:41 +01:00
parent c3c2055011
commit 2108441e77
8 changed files with 48 additions and 13 deletions

View File

@@ -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);