From 4e5710fa49824a1e277ac5164e926d3b3621a0ff Mon Sep 17 00:00:00 2001 From: Pal Mezei Date: Tue, 20 Oct 2020 23:25:35 +1100 Subject: [PATCH] Add support for treatAsPoint on the sphere light. (#578) Fixes #577 --- render_delegate/constant_strings.h | 1 + render_delegate/light.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/render_delegate/constant_strings.h b/render_delegate/constant_strings.h index 0b7a1a7757..2c9d5aec73 100644 --- a/render_delegate/constant_strings.h +++ b/render_delegate/constant_strings.h @@ -223,6 +223,7 @@ ASTR(node_idxs); ASTR(nodes); ASTR(none); ASTR(normal); +ASTR(normalize); ASTR(normal_nonexistant_rename); ASTR(nsides); ASTR(opacity); diff --git a/render_delegate/light.cpp b/render_delegate/light.cpp index e5b800e987..943a001e51 100644 --- a/render_delegate/light.cpp +++ b/render_delegate/light.cpp @@ -61,6 +61,7 @@ TF_DEFINE_PRIVATE_TOKENS( (barndoorrightedge) (barndoortop) (barndoortopedge) + (treatAsPoint) ); // clang-format on @@ -207,7 +208,13 @@ auto spotLightSync = [](AtNode* light, AtNode** filter, const AtNodeEntry* nentr auto pointLightSync = [](AtNode* light, AtNode** filter, const AtNodeEntry* nentry, const SdfPath& id, HdSceneDelegate* delegate) { TF_UNUSED(filter); - iterateParams(light, nentry, id, delegate, pointParams); + const auto treatAsPointValue = delegate->GetLightParamValue(id, _tokens->treatAsPoint); + if (treatAsPointValue.IsHolding() && treatAsPointValue.UncheckedGet()) { + AiNodeSetFlt(light, str::radius, 0.0f); + AiNodeSetBool(light, str::normalize, true); + } else { + iterateParams(light, nentry, id, delegate, pointParams); + } }; auto photometricLightSync = [](AtNode* light, AtNode** filter, const AtNodeEntry* nentry, const SdfPath& id,