Skip to content

Commit

Permalink
Add parameters to standard material
Browse files Browse the repository at this point in the history
  • Loading branch information
dictoon committed Dec 20, 2015
1 parent 557d225 commit baccd48
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 4 deletions.
Binary file modified src/appleseed-stdmtl/appleseed-stdmtl.rc
Binary file not shown.
66 changes: 62 additions & 4 deletions src/appleseed-stdmtl/appleseedstdmtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ namespace

enum
{
ParamIdBaseColor
ParamIdBaseColor,
ParamIdMetallic,
ParamIdSpecular,
ParamIdSpecularTint,
ParamIdAnisotropic,
ParamIdRoughness,
ParamIdClearcoat,
ParamIdClearcoatGloss
};

ParamBlockDesc2 g_block_desc(
const ParamBlockDesc2 g_block_desc(
// --- Required arguments ---
ParamBlockIdStdMtl, // parameter block's ID
_T("appleseedStdMtlParams"), // internal parameter block's name
Expand All @@ -94,11 +101,47 @@ namespace
nullptr, // user dialog procedure

// --- Parameters specifications ---
ParamIdBaseColor, _T("base_color"), TYPE_RGBA, 0, IDS_BASE_COLOR,

ParamIdBaseColor, _T("base_color"), TYPE_RGBA, P_ANIMATABLE, IDS_BASE_COLOR,
p_default, Color(0.9f, 0.9f, 0.9f),
p_ui, TYPE_COLORSWATCH, IDC_COLOR_BASE,
p_end,

ParamIdMetallic, _T("metallic"), TYPE_FLOAT, P_ANIMATABLE, IDS_METALLIC,
p_default, 0.0f,
p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_TEXT_METALLIC, IDC_SPINNER_METALLIC, 0.1f,
p_end,

ParamIdSpecular, _T("specular"), TYPE_FLOAT, P_ANIMATABLE, IDS_SPECULAR,
p_default, 0.0f,
p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_TEXT_SPECULAR, IDC_SPINNER_SPECULAR, 0.1f,
p_end,

ParamIdSpecularTint, _T("specular_tint"), TYPE_FLOAT, P_ANIMATABLE, IDS_SPECULAR_TINT,
p_default, 0.0f,
p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_TEXT_SPECULARTINT, IDC_SPINNER_SPECULARTINT, 0.1f,
p_end,

ParamIdAnisotropic, _T("anisotropic"), TYPE_FLOAT, P_ANIMATABLE, IDS_ANISOTROPIC,
p_default, 0.0f,
p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_TEXT_ANISOTROPIC, IDC_SPINNER_ANISOTROPIC, 0.1f,
p_end,

ParamIdRoughness, _T("roughness"), TYPE_FLOAT, P_ANIMATABLE, IDS_ROUGHNESS,
p_default, 0.0f,
p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_TEXT_ROUGHNESS, IDC_SPINNER_ROUGHNESS, 0.1f,
p_end,

ParamIdClearcoat, _T("clearcoat"), TYPE_FLOAT, P_ANIMATABLE, IDS_CLEARCOAT,
p_default, 0.0f,
p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_TEXT_CLEARCOAT, IDC_SPINNER_CLEARCOAT, 0.1f,
p_end,

ParamIdClearcoatGloss, _T("clearcoat_gloss"), TYPE_FLOAT, P_ANIMATABLE, IDS_CLEARCOAT_GLOSS,
p_default, 0.0f,
p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_TEXT_CLEARCOATGLOSS, IDC_SPINNER_CLEARCOATGLOSS, 0.1f,
p_end,

// --- The end ---
p_end);
}
Expand Down Expand Up @@ -218,6 +261,13 @@ RefTargetHandle AppleseedStdMtl::Clone(RemapDir &remap)
void AppleseedStdMtl::Update(TimeValue t, Interval& valid)
{
m_pblock->GetValue(ParamIdBaseColor, t, m_base_color, valid);
m_pblock->GetValue(ParamIdMetallic, t, m_metallic, valid);
m_pblock->GetValue(ParamIdSpecular, t, m_specular, valid);
m_pblock->GetValue(ParamIdSpecularTint, t, m_specular_tint, valid);
m_pblock->GetValue(ParamIdAnisotropic, t, m_anisotropic, valid);
m_pblock->GetValue(ParamIdRoughness, t, m_roughness, valid);
m_pblock->GetValue(ParamIdClearcoat, t, m_clearcoat, valid);
m_pblock->GetValue(ParamIdClearcoatGloss, t, m_clearcoat_gloss, valid);
}

void AppleseedStdMtl::Reset()
Expand Down Expand Up @@ -342,10 +392,18 @@ void AppleseedStdMtl::Shade(ShadeContext& sc)
asf::auto_release_ptr<asr::Material> AppleseedStdMtl::create_material(const char* name)
{
auto material = asr::DisneyMaterialFactory().create(name, asr::ParamArray());
auto disney_material = static_cast<asr::DisneyMaterial*>(material.get());

auto values = asr::DisneyMaterialLayer::get_default_values();
values.insert("base_color", fmt_color_expr(to_color3f(m_base_color)));
values.insert("metallic", m_metallic);
values.insert("specular", m_specular);
values.insert("specular_tint", m_specular_tint);
values.insert("anisotropic", m_anisotropic);
values.insert("roughness", m_roughness);
values.insert("clearcoat", m_clearcoat);
values.insert("clearcoat_gloss", m_clearcoat_gloss);

auto disney_material = static_cast<asr::DisneyMaterial*>(material.get());
disney_material->add_layer(values);

return material;
Expand Down
7 changes: 7 additions & 0 deletions src/appleseed-stdmtl/appleseedstdmtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ class AppleseedStdMtl
private:
IParamBlock2* m_pblock;
Color m_base_color;
float m_metallic;
float m_specular;
float m_specular_tint;
float m_anisotropic;
float m_roughness;
float m_clearcoat;
float m_clearcoat_gloss;
};


Expand Down
Binary file modified src/appleseed-stdmtl/resource.h
Binary file not shown.

0 comments on commit baccd48

Please sign in to comment.