Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add emissive color for previewsurface #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions hdOSPRay/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ HdOSPRayMaterial::_ProcessUsdPreviewSurfaceNode(HdMaterialNode node)
const auto& value = param->second;
if (name == HdOSPRayMaterialTokens->diffuseColor) {
diffuseColor = value.Get<GfVec3f>();
} else if (name == HdOSPRayMaterialTokens->emissiveColor) {
emissiveColor = value.Get<GfVec3f>();
} else if (name == HdOSPRayMaterialTokens->specularColor) {
specularColor = value.Get<GfVec3f>();
} else if (name == HdOSPRayMaterialTokens->metallic) {
Expand Down Expand Up @@ -621,6 +623,7 @@ HdOSPRayMaterial::UpdatePrincipledMaterial(const std::string& rendererType)
bool hasMetallicTex = false;
bool hasRoughnessTex = false;
bool hasOpacityTex = false;
bool hasEmissiveTex = false;
// set texture maps
// TODO: we can skip the name mapping if we require them to be in ospray nomenclature
for (const auto& [key, value] : _textures) {
Expand Down Expand Up @@ -680,6 +683,9 @@ HdOSPRayMaterial::UpdatePrincipledMaterial(const std::string& rendererType)
|| key == HdOSPRayMaterialTokens->map_roughness) {
name = "map_roughness";
hasRoughnessTex = true;
} else if (key == HdOSPRayMaterialTokens->emissiveColor) {
name = "map_emissiveColor";
hasEmissiveTex = true;
}

if (name != "") {
Expand Down Expand Up @@ -735,6 +741,8 @@ HdOSPRayMaterial::UpdatePrincipledMaterial(const std::string& rendererType)
_ospMaterial.setParam("sheenColor", GfToOSP(sheenColor));
_ospMaterial.setParam("sheenTint", sheenTint);
_ospMaterial.setParam("sheenRoughness", sheenRoughness);
_ospMaterial.setParam("emissiveColor",
(hasEmissiveTex ? vec3f( 1.f, 1.f, 1.f) : GfToOSP(emissiveColor)));
}

void
Expand Down
1 change: 1 addition & 0 deletions hdOSPRay/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class HdOSPRayMaterial final : public HdMaterial {
GfVec3f sheenColor { 1.f, 1.f, 1.f };
float sheenTint { 0.f };
float sheenRoughness { 0.2f };
GfVec3f emissiveColor { 0.f, 0.f, 0.f };
TfToken type;
bool hasPtex { false };

Expand Down