USD: Support outputting emissiveColor in UsdPreviewSurface, mapped from Blender's Emission #107947

Merged
Michael Kowalski merged 1 commits from wave/blender_wave_Apple:emissiveColor into main 2023-05-16 15:57:33 +02:00
1 changed files with 4 additions and 0 deletions

View File

@ -39,6 +39,7 @@ namespace usdtokens {
static const pxr::TfToken clearcoat("clearcoat", pxr::TfToken::Immortal);
static const pxr::TfToken clearcoatRoughness("clearcoatRoughness", pxr::TfToken::Immortal);
static const pxr::TfToken diffuse_color("diffuseColor", pxr::TfToken::Immortal);
static const pxr::TfToken emissive_color("emissiveColor", pxr::TfToken::Immortal);
static const pxr::TfToken metallic("metallic", pxr::TfToken::Immortal);
static const pxr::TfToken preview_shader("previewShader", pxr::TfToken::Immortal);
static const pxr::TfToken preview_surface("UsdPreviewSurface", pxr::TfToken::Immortal);
@ -277,6 +278,8 @@ void create_usd_viewport_material(const USDExporterContext &usd_export_context,
shader.CreateIdAttr(pxr::VtValue(usdtokens::preview_surface));
shader.CreateInput(usdtokens::diffuse_color, pxr::SdfValueTypeNames->Color3f)
.Set(pxr::GfVec3f(material->r, material->g, material->b));
shader.CreateInput(usdtokens::emissive_color, pxr::SdfValueTypeNames->Color3f)
.Set(pxr::GfVec3f(material->r, material->g, material->b));
shader.CreateInput(usdtokens::roughness, pxr::SdfValueTypeNames->Float).Set(material->roughness);
shader.CreateInput(usdtokens::metallic, pxr::SdfValueTypeNames->Float).Set(material->metallic);
@ -289,6 +292,7 @@ static InputSpecMap &preview_surface_input_map()
{
static InputSpecMap input_map = {
{"Base Color", {usdtokens::diffuse_color, pxr::SdfValueTypeNames->Float3, true}},
{"Emission", {usdtokens::emissive_color, pxr::SdfValueTypeNames->Float3, true}},
{"Color", {usdtokens::diffuse_color, pxr::SdfValueTypeNames->Float3, true}},
{"Roughness", {usdtokens::roughness, pxr::SdfValueTypeNames->Float, true}},
{"Metallic", {usdtokens::metallic, pxr::SdfValueTypeNames->Float, true}},