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

@@ -44,7 +44,7 @@ bool ABR::section_samp()
auto vm = parse_vmem();
if (vm)
{
if (auto img = vm->image(true))
if (auto img = vm->image(true, true))
{
// TODO: check if uid already exists in map
m_samples[uid] = img;
@@ -91,7 +91,7 @@ bool ABR::section_patt()
LOG("PATT: image_mode (%d) and number of channels (%d) not matching\n",
image_mode, vm->channels.size());
}
if (auto img = vm->image(true))
if (auto img = vm->image(true, false))
{
// TODO: check if uid already exists in map
m_patterns[uid] = img;
@@ -111,45 +111,65 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
continue;
auto b = std::make_shared<Brush>();
b->m_name = wstr2str(p->value<String>("Nm "));
//b->m_tip_color = i.m_tip_color;
b->m_tip_size = samp->value<UnitFloat>("Dmtr") / 800.f;
b->m_tip_spacing = samp->value<UnitFloat>("Spcn") * 0.01f;
// default values
b->m_tip_color = { 0, 0, 0, 1 };
b->m_tip_flow = .25f;
b->m_tip_opacity = 1.f;
b->m_tip_angle = samp->value<UnitFloat>("Angl") / 360.f + 0.5f; // [-180,180] -> [0, 1]
b->m_tip_aspect = (1.f - samp->value<UnitFloat>("Rndn") * 0.01) * 0.5f + 0.5f;
b->m_tip_size = samp->value<UnitFloat>("Dmtr");
b->m_tip_spacing = samp->value<UnitFloat>("Spcn") * 0.01f;
b->m_tip_angle = samp->value<UnitFloat>("Angl") / 360.f + 0.5f; // [-180, 180] -> [0, 1]
//b->m_tip_mix = i.m_tip_mix;
//b->m_tip_stencil = i.m_tip_stencil;
b->m_tip_wet = p->value<UnitFloat>("Wtdg");
b->m_tip_noise = (float)samp->value<UnitFloat>("Nose");
//b->m_tip_hue = i.m_tip_hue;
//b->m_tip_sat = i.m_tip_sat;
//b->m_tip_val = i.m_tip_val;
//b->m_tip_angle_follow = i.m_tip_angle_follow;
//b->m_tip_flow_pressure = i.m_tip_flow_pressure;
//b->m_tip_size_pressure = i.m_tip_size_pressure;
//b->m_tip_hue_pressure = i.m_tip_hue_pressure;
//b->m_tip_sat_pressure = i.m_tip_sat_pressure;
//b->m_tip_val_pressure = i.m_tip_val_pressure;
//b->m_jitter_scale = i.m_jitter_scale;
//b->m_jitter_angle = i.m_jitter_angle;
//b->m_jitter_spread = i.m_jitter_spread;
//b->m_jitter_flow = i.m_jitter_flow;
//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_name.resize(i.m_name_len);
//b->m_texture_path.resize(i.m_stencil_path_len);
// brush sample
auto tip_uid = wstr2str(samp->value<String>("sampledData"));
LOG("tip uid %d %s", tip_uid.size(), tip_uid.c_str());
b->m_brush_path = path + "/brushes/" + tip_uid + ".png";
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;
// pattern
if (auto patt = p->get<Descriptor>("Txtr"))
{
auto patt_uid = wstr2str(patt->value<String>("Idnt"));
b->m_pattern_path = path + "/patterns/" + patt_uid + ".png";
b->m_pattern_thumb_path = path + "/patterns/thumbs/" + patt_uid + ".png";
b->m_pattern_depth = p->value<UnitFloat>("textureDepth") * 0.01f;
b->m_pattern_invert = p->value<Boolean>("InvT");
b->m_pattern_eachsample = p->value<Boolean>("TxtC");
b->m_pattern_depth = p->value<UnitFloat>("textureDepth") * 0.01f; // [0, 100] -> [0, 1]
b->m_pattern_scale = p->value<UnitFloat>("textureScale") * 0.01f; // [0, 1000] -> [0, 1]
b->m_pattern_brightness = (float)(p->value<Integer>("textureBrightness") + 150) / 300.f; // [-150, 150] -> [0, 1]
int raw_contrast = p->value<Integer>("textureContrast"); // [-50, 0, 100] -> [0, 1]
b->m_pattern_contrast = raw_contrast / (raw_contrast < 0 ? 100.f : 200.f) + 0.5f;
// blending mode
std::string blend_mode = p->value<Enum>("textureBlendMode");
std::vector<std::string> modes = {
"normal", // normal (not in Photoshop)
"Mltp", // multiply
"Sbtr", // subtract
"Drkn", // darken
"Ovrl", // overlay
"CDdg", // color dodge
"CBrn", // color burn
"linearBurn", // linear burn
"hardMix", // hard mix
"linearHeight", // linear height
"Hght", // height
};
auto bm_it = std::find(modes.begin(), modes.end(), blend_mode);
if (bm_it != modes.end())
b->m_pattern_blend_mode = std::distance(modes.begin(), bm_it);
b->m_pattern_enabled = true;
}
ret.push_back(b);