diff --git a/data/shaders/comp-draw.glsl b/data/shaders/comp-draw.glsl index 646ee8c..49acc43 100644 --- a/data/shaders/comp-draw.glsl +++ b/data/shaders/comp-draw.glsl @@ -64,13 +64,10 @@ void main() mediump float patt = texture(tex_pattern, uv * (1.0 / pattern_scale) * rscale + pattern_offset).r; if (pattern_invert) patt = 1.0 - patt; - //patt = patt * pattern_alpha + (1.0 - pattern_alpha); if (pattern_bright != 0.5) patt = brightness1(patt, 1.0 - pattern_bright); if (pattern_contr != 0.5) patt = contrast1(patt, pattern_contr); - //mediump float pa = (1.0 - patt) * pow(pattern_depth, 0.25) + (stroke.a * pattern_depth * 10.0); - //mediump float pa = pow((1.0 - patt), max(1.0, (1.0 - pattern_depth) * 10.0)) * pow(pattern_depth, 0.25) + (stroke.a * pattern_depth * 5.0); stroke.a = blend_stroke(stroke.a, patt, pattern_depth, patt_blend_mode); } diff --git a/src/abr.cpp b/src/abr.cpp index 3e7737f..b195095 100644 --- a/src/abr.cpp +++ b/src/abr.cpp @@ -120,12 +120,13 @@ std::vector> ABR::compute_brushes(const std::string& path b->m_tip_flow = .90f; b->m_tip_opacity = 1.f; + b->m_tip_wet = p->value("Wtdg"); + b->m_tip_noise = p->value("Nose") ? 1.f : 0.f; + b->m_tip_aspect = (1.f - samp->value("Rndn") * 0.01) * 0.5f + 0.5f; b->m_tip_size = samp->value("Dmtr"); b->m_tip_spacing = samp->value("Spcn") * 0.01f; - b->m_tip_angle = samp->value("Angl") / 360.f + 0.5f; // [-180, 180] -> [0, 1] - b->m_tip_wet = p->value("Wtdg"); - b->m_tip_noise = samp->value("Nose"); + b->m_tip_angle = samp->value("Angl") / 360.f; // [-180, 180] -> [0, 1] b->m_tip_flipx = samp->value("flipX"); b->m_tip_flipy = samp->value("flipY"); @@ -137,7 +138,10 @@ std::vector> ABR::compute_brushes(const std::string& path b->m_brush_thumb_path = path + "/brushes/thumbs/" + tip_uid + ".png"; const auto& samp_img = m_samples[tip_uid]; - b->m_tip_width = (float)samp_img->width / (float)samp_img->height; + if (samp_img->height > samp_img->width) + b->m_tip_scale = { (float)samp_img->width / (float)samp_img->height, 1.f }; + else + b->m_tip_scale = { 1.f, (float)samp_img->height / (float)samp_img->width }; } else if (samp->class_id == "computedBrush") { @@ -162,6 +166,8 @@ std::vector> ABR::compute_brushes(const std::string& path { b->m_jitter_scale = jitter_size->value("jitter") * 0.01f; // TODO: p->value("minimumDiameter") * 0.001f; // minimum size + if (jitter_size->value("bVTy") == 2) + b->m_tip_size_pressure; } auto jitter_angle = p->get("angleDynamics"); @@ -189,6 +195,30 @@ std::vector> ABR::compute_brushes(const std::string& path b->m_tip_randflipy = p->value("flipY"); } + // Transfer settings + if (p->value("usePaintDynamics")) + { + // TODO: implement this when opacity is per-sample + //auto jitter_opacity = p->get("opVr"); + //if (jitter_opacity) + //{ + // b->m_jitter_opacity = jitter_opacity->value("jitter") * 0.01f; + // // TODO: jitter_opacity->value("Mnm ") * 0.01f; // minimum size + // if (jitter_opacity->value("bVTy") == 2) + // b->m_tip_opacity_pressure; + //} + + auto jitter_flow = p->get("prVr"); + if (jitter_flow) + { + b->m_jitter_flow = jitter_flow->value("jitter") * 0.01f; + // TODO: m_jitter_flow->value("Mnm ") * 0.01f; // minimum size + if (jitter_flow->value("bVTy") == 2) + b->m_tip_flow_pressure = true; + } + + } + std::vector modes = { "normal", // normal (not in Photoshop) "Mltp", // multiply @@ -246,7 +276,7 @@ std::vector> ABR::compute_brushes(const std::string& path b->m_dual_opacity = 1.f; //b->m_tip_aspect = (1.f - samp->value("Rndn") * 0.01) * 0.5f + 0.5f; - b->m_dual_size = samp->value("Dmtr"); + b->m_dual_size = samp->value("Dmtr") / b->m_tip_size; b->m_dual_spacing = samp->value("Spcn") * 0.01f; //b->m_tip_angle = samp->value("Angl") / 360.f + 0.5f; // [-180, 180] -> [0, 1] //b->m_tip_wet = p->value("Wtdg"); @@ -408,7 +438,7 @@ std::shared_ptr ABR::parse_objc() if (!property) return nullptr; if (ret->props.find(key) != ret->props.end()) - LOG("DUPLICATE prop %d\n", key.c_str()); + LOG("DUPLICATE prop %s\n", key.c_str()); ret->props[key] = property; } return ret; diff --git a/src/brush.cpp b/src/brush.cpp index cd4d8ed..9307813 100644 --- a/src/brush.cpp +++ b/src/brush.cpp @@ -141,9 +141,9 @@ 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 = m_brush->m_tip_width * randflipx * (m_brush->m_tip_flipx ? -1.f : 1.f) * + 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 = randflipy * (m_brush->m_tip_flipy ? -1.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.angle = -curve_angle + (m_brush->m_tip_angle + rnd_neg() * m_brush->m_jitter_angle) * (float)(M_PI * 2.0); @@ -188,6 +188,8 @@ std::vector Stroke::compute_samples() m_dir_angle = -glm::orientedAngle(v, m_dir_ref); if (m_brush->m_tip_angle_delay > 0 && (glm::abs(m_dir_angle) > glm::pi() / 2.f || !m_dir_valid)) { + //if (glm::abs(m_dir_angle) > glm::radians(110.f)) + // LOG("BIG ANGLE"); auto old_dir = m_dir_ref; m_dir_ref = v; m_dir_ref_angle = -glm::orientedAngle(m_dir_ref, { 1, 0 }); @@ -256,7 +258,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 raw_size = aspect_width * m_brush->m_tip_width * m_brush->m_tip_size; + 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); if (raw_size < 2.f) @@ -301,7 +303,7 @@ void Stroke::start(const std::shared_ptr& brush) m_brush = brush; 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 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); if (raw_size < 2.f) diff --git a/src/brush.h b/src/brush.h index f8b23d9..6852879 100644 --- a/src/brush.h +++ b/src/brush.h @@ -22,14 +22,14 @@ public: std::string m_pattern_path; std::string m_pattern_thumb_path; - glm::vec4 m_tip_color{0, 0, 0, 1}; - float m_tip_width = 1.f; + glm::vec4 m_tip_color = { 0, 0, 0, 1 }; + glm::vec2 m_tip_scale = { 1.f, 1.f }; float m_tip_size = 50; float m_tip_spacing = .25; float m_tip_flow = 1.f; float m_tip_opacity = 1.f; float m_tip_angle = 0; - float m_tip_angle_delay = 0; + float m_tip_angle_delay = 0.01; float m_tip_mix = 0; float m_tip_wet = 0; float m_tip_noise = 0; @@ -55,7 +55,7 @@ public: bool m_dual_enabled = false; int m_dual_blend_mode = 1; bool m_dual_randflip = false; - float m_dual_size = 100; + float m_dual_size = .75; float m_dual_spacing = .25; float m_dual_scatter = 0; bool m_dual_scatter_axis = false; diff --git a/src/canvas.cpp b/src/canvas.cpp index 6905d5e..82ca0da 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -913,7 +913,7 @@ void Canvas::stroke_start(glm::vec3 point, float pressure) dual_brush->m_blend_mode = m_current_brush->m_dual_blend_mode; dual_brush->m_tip_randflipx = m_current_brush->m_dual_randflip; dual_brush->m_tip_randflipy = m_current_brush->m_dual_randflip; - dual_brush->m_tip_size = m_current_brush->m_dual_size; + dual_brush->m_tip_size = m_current_brush->m_dual_size * m_current_brush->m_tip_size; dual_brush->m_tip_spacing = m_current_brush->m_dual_spacing; dual_brush->m_jitter_spread = m_current_brush->m_dual_scatter; dual_brush->m_jitter_angle = m_current_brush->m_dual_rotate; diff --git a/src/canvas_modes.cpp b/src/canvas_modes.cpp index fb1b1ff..98e0405 100644 --- a/src/canvas_modes.cpp +++ b/src/canvas_modes.cpp @@ -213,7 +213,7 @@ void CanvasModePen::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const ShaderManager::u_int(kShaderUniform::Tex, 0); float tip_scale_fix = 1.f / glm::tan(glm::radians(Canvas::I->m_cam_fov * 0.5f)); float tip_angle = brush->m_tip_angle * (float)(M_PI * 2.0); - glm::vec2 tip_scale = glm::vec2(brush->m_tip_width, 1.f) * + glm::vec2 tip_scale = brush->m_tip_scale * glm::vec2(brush->m_tip_size * tip_scale_fix) * glm::vec2(brush->m_tip_flipx ? -1 : 1, brush->m_tip_flipy ? -1.f : 1.f) * glm::vec2((brush->m_tip_aspect <= 0.5 ? brush->m_tip_aspect * 2.f : 1.f), diff --git a/src/main.cpp b/src/main.cpp index ec7ae20..098d068 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -642,7 +642,8 @@ int main(int argc, char** argv) { static wchar_t title_fps[512]; swprintf_s(title_fps, L"%s - %d fps", window_title, frames); - SetWindowText(hWnd, title_fps); + if (running) + SetWindowText(hWnd, title_fps); one_sec = 0; frames = 0; } diff --git a/src/node_panel_stroke.cpp b/src/node_panel_stroke.cpp index 0ffbf11..d601bc9 100644 --- a/src/node_panel_stroke.cpp +++ b/src/node_panel_stroke.cpp @@ -536,7 +536,7 @@ void NodePanelStroke::init_controls() m_curves[m_tip_size] = curve_size5k_pix; m_curves[m_tip_spacing] = curve_size1k_perc; m_curves[m_tip_flow] = curve_quad; - m_curves[m_dual_size] = curve_size5k_pix; + m_curves[m_dual_size] = curve_size1k_perc; m_curves[m_dual_spacing] = curve_size1k_perc; m_curves[m_dual_flow] = curve_quad; m_curves[m_pattern_scale] = curve_size1k_perc; diff --git a/src/node_stroke_preview.cpp b/src/node_stroke_preview.cpp index 11ddf2d..c04b1f8 100644 --- a/src/node_stroke_preview.cpp +++ b/src/node_stroke_preview.cpp @@ -259,7 +259,7 @@ void NodeStrokePreview::draw_stroke() dual_brush->m_blend_mode = b->m_dual_blend_mode; dual_brush->m_tip_randflipx = b->m_dual_randflip; dual_brush->m_tip_randflipy = b->m_dual_randflip; - dual_brush->m_tip_size = b->m_dual_size; + dual_brush->m_tip_size = b->m_dual_size * b->m_tip_size; dual_brush->m_tip_spacing = b->m_dual_spacing; dual_brush->m_jitter_spread = b->m_dual_scatter; dual_brush->m_jitter_angle = b->m_dual_rotate;