Skip to content

Commit

Permalink
This PR contain fixes for bugs with aiSkyDomeLight when using Arnold …
Browse files Browse the repository at this point in the history
…Render Delegate.

1. Fixes black renders when the dome light is selected.
2. Fixes light param updates not working.
  • Loading branch information
roopavr-adsk committed Jun 10, 2024
1 parent 9b698ab commit 8c84ffd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 37 deletions.
27 changes: 18 additions & 9 deletions lib/mayaHydra/hydraExtensions/adapters/aiSkydomeLightAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class MayaHydraAiSkyDomeLightAdapter : public MayaHydraLightAdapter

// We are not using precomputed attributes here, because we don't have
// a guarantee that mtoa will be loaded before mayaHydra.
if (paramName == HdLightTokens->color) {
if (paramName == HdLightTokens->color ||
paramName == UsdLuxTokens->inputsColor) {
const auto plug = light.findPlug("color", true);
MPlugArray conns;
plug.connectedTo(conns, true, false);
Expand Down Expand Up @@ -150,23 +151,29 @@ class MayaHydraAiSkyDomeLightAdapter : public MayaHydraLightAdapter
}
}
return VtValue(GfVec3f(r,g,b));
} else if (paramName == HdLightTokens->intensity) {
} else if (paramName == HdLightTokens->intensity ||
paramName == UsdLuxTokens->inputsIntensity) {
return VtValue(light.findPlug("intensity", true).asFloat());
} else if (paramName == HdLightTokens->diffuse) {
} else if (paramName == HdLightTokens->diffuse ||
paramName == UsdLuxTokens->inputsDiffuse) {
MPlug aiDiffuse = light.findPlug("aiDiffuse", true, &status);
if (status == MS::kSuccess) {
return VtValue(aiDiffuse.asFloat());
}
} else if (paramName == HdLightTokens->specular) {
} else if (paramName == HdLightTokens->specular ||
paramName == UsdLuxTokens->inputsSpecular) {
MPlug aiSpecular = light.findPlug("aiSpecular", true, &status);
if (status == MS::kSuccess) {
return VtValue(aiSpecular.asFloat());
}
} else if (paramName == HdLightTokens->exposure) {
} else if (paramName == HdLightTokens->exposure ||
paramName == UsdLuxTokens->inputsExposure) {
return VtValue(light.findPlug("aiExposure", true).asFloat());
} else if (paramName == HdLightTokens->normalize) {
} else if (paramName == HdLightTokens->normalize ||
paramName == UsdLuxTokens->inputsNormalize) {
return VtValue(light.findPlug("aiNormalize", true).asBool());
} else if (paramName == HdLightTokens->textureFormat) {
} else if (paramName == HdLightTokens->textureFormat ||
paramName == UsdLuxTokens->inputsTextureFormat) {
const auto format = light.findPlug("format", true).asShort();
// mirrored_ball : 0
// angular : 1
Expand All @@ -178,7 +185,8 @@ class MayaHydraAiSkyDomeLightAdapter : public MayaHydraLightAdapter
} else {
return VtValue(UsdLuxTokens->automatic);
}
} else if (paramName == HdLightTokens->textureFile) {
} else if (paramName == HdLightTokens->textureFile ||
paramName == UsdLuxTokens->inputsTextureFile) {
// Be aware that dome lights in HdStorm always need a texture to work correctly,
// the color is not used if no texture is present.

Expand Down Expand Up @@ -220,7 +228,8 @@ class MayaHydraAiSkyDomeLightAdapter : public MayaHydraLightAdapter
// SdfAssetPath requires both "path" "resolvedPath"
return VtValue(SdfAssetPath(fileTextureName, fileTextureName));

} else if (paramName == HdLightTokens->enableColorTemperature) {
} else if (paramName == HdLightTokens->enableColorTemperature ||
paramName == UsdLuxTokens->inputsEnableColorTemperature) {
return VtValue(false);
}
return {};
Expand Down
13 changes: 0 additions & 13 deletions lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,12 @@ void MayaHydraRenderItemAdapter::UpdateFromDelta(const UpdateFromDeltaData& data
dirtyBits |= HdChangeTracker::DirtyPrimvar; // displayColor primVar
}

const bool displayStatusChanged = (_displayStatus != data._displayStatus);
_displayStatus = data._displayStatus;
const bool hideOnPlayback = data._ri.isHideOnPlayback();
if (hideOnPlayback != _isHideOnPlayback) {
_isHideOnPlayback = hideOnPlayback;
dirtyBits |= HdChangeTracker::DirtyVisibility;
}

//Special case for aiSkydomeLight which is visible only when it is selected
if (_isArnoldSkyDomeLightTriangleShape && displayStatusChanged){
SetVisible(IsRenderItemSelected());
dirtyBits |= HdChangeTracker::DirtyVisibility;
} else
if (visibChanged) {
SetVisible(visible);
dirtyBits |= HdChangeTracker::DirtyVisibility;
Expand Down Expand Up @@ -523,12 +516,6 @@ void MayaHydraRenderItemAdapter::SetPlaybackChanged()
}
}

bool MayaHydraRenderItemAdapter::IsRenderItemSelected() const
{
return (MHWRender::DisplayStatus::kActive == _displayStatus) ||
(MHWRender::DisplayStatus::kLead == _displayStatus);
}

HdCullStyle MayaHydraRenderItemAdapter::GetCullStyle() const
{
// HdCullStyleNothing means no culling, HdCullStyledontCare means : let the renderer choose
Expand Down
12 changes: 1 addition & 11 deletions lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ class MayaHydraRenderItemAdapter : public MayaHydraAdapter
MAYAHYDRALIB_API
const MColor& GetWireframeColor() const { return _wireframeColor; }

MAYAHYDRALIB_API
MHWRender::DisplayStatus GetDisplayStatus() const { return _displayStatus; }

MAYAHYDRALIB_API
GfMatrix4d GetTransform() override { return _transform[0]; }

Expand All @@ -139,19 +136,16 @@ class MayaHydraRenderItemAdapter : public MayaHydraAdapter
UpdateFromDeltaData(
MRenderItem& ri,
unsigned int flags,
const MColor& wireframeColor,
MHWRender::DisplayStatus displayStatus)
const MColor& wireframeColor)
: _ri(ri)
, _flags(flags)
, _wireframeColor(wireframeColor)
, _displayStatus(displayStatus)
{
}

MRenderItem& _ri;
unsigned int _flags;
const MColor& _wireframeColor;
MHWRender::DisplayStatus _displayStatus;
};

/// We receive in that function the changes made in the Maya viewport between the last frame
Expand Down Expand Up @@ -192,9 +186,6 @@ class MayaHydraRenderItemAdapter : public MayaHydraAdapter
MAYAHYDRALIB_API
bool GetIsRenderITemAnaiSkydomeLightTriangleShape() const {return _isArnoldSkyDomeLightTriangleShape;}

MAYAHYDRALIB_API
bool IsRenderItemSelected() const;

private:
MAYAHYDRALIB_API
void _RemoveRprim();
Expand All @@ -216,7 +207,6 @@ class MayaHydraRenderItemAdapter : public MayaHydraAdapter
bool _visible = false;
MColor _wireframeColor = { 1.f, 1.f, 1.f, 1.f };
bool _isHideOnPlayback = false;
MHWRender::DisplayStatus _displayStatus = MHWRender::DisplayStatus::kNoStatus;
bool _isArnoldSkyDomeLightTriangleShape = false;
GfBBox3d _bounds;//Bounding box
};
Expand Down
19 changes: 15 additions & 4 deletions lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ namespace {
return mayaPath;
}

bool IsTexturedSkyDomeRenderItem(const SdfPath& name)
{
static const std::string _aiTexturedSkyDome("texturedSkyDome");
if (name.GetString().find(_aiTexturedSkyDome) != std::string::npos) {
// This render item is an texturedDomeLighnt
return true;
}
return false;
}

SdfPath _GetPrimPath(const SdfPath& base, const MDagPath& dg)
{
return base.AppendPath(GetMayaPrimPath(dg));
Expand Down Expand Up @@ -474,7 +484,10 @@ void MayaHydraSceneIndex::HandleCompleteViewportScene(const MDataServerOperation
MayaHydraRenderItemAdapterPtr ria = nullptr;
if (!_GetRenderItem(fastId, ria)) {
const SdfPath slowId = _GetRenderItemPrimPath(ri);
if (slowId.IsEmpty()) {

// Maya/MtoA adds texturedSkyDome mesh object for VP2.
// We do not want that to be translated to Hydra
if (slowId.IsEmpty() || IsTexturedSkyDomeRenderItem(slowId)) {
continue;
}
// MAYA-128021: We do not currently support maya instances.
Expand All @@ -500,18 +513,16 @@ void MayaHydraSceneIndex::HandleCompleteViewportScene(const MDataServerOperation
}

MColor wireframeColor;
MHWRender::DisplayStatus displayStatus = MHWRender::kNoStatus;

MDagPath dagPath = ri.sourceDagPath();
if (dagPath.isValid()) {
wireframeColor = MGeometryUtilities::wireframeColor(
dagPath); // This is a color managed VP2 color, it will need to be unmanaged at some
// point
displayStatus = MGeometryUtilities::displayStatus(dagPath);
}

const MayaHydraRenderItemAdapter::UpdateFromDeltaData data(
ri, flags, wireframeColor, displayStatus);
ri, flags, wireframeColor);
ria->UpdateFromDelta(data);
if (flags & MDataServerOperation::MViewportScene::MVS_changedMatrix) {
ria->UpdateTransform(ri);
Expand Down

0 comments on commit 8c84ffd

Please sign in to comment.