Fix Cycles Hydra render delegate ignoring the light falloff property

If the falloff is defined with a supported value, a LightFalloffNode is added
to the graph, instead of the default EmissionNode.

Pull Request: https://projects.blender.org/blender/blender/pulls/110690
This commit is contained in:
Nicolas Sourd 2023-08-11 17:24:08 +02:00 committed by Brecht Van Lommel
parent 23ce783f8d
commit 092251b1fd

@ -216,7 +216,23 @@ void HdCyclesLight::PopulateShaderGraph(HdSceneDelegate *sceneDelegate)
outputNode = bgNode;
}
else {
else if (sceneDelegate != nullptr) {
VtValue value;
const SdfPath &id = GetId();
value = sceneDelegate->GetLightParamValue(id, TfToken("falloff"));
if (!value.IsEmpty()) {
std::string strVal = value.Get<string>();
if (strVal == "Constant" || strVal == "Linear" || strVal == "Quadratic") {
LightFalloffNode *lfoNode = graph->create_node<LightFalloffNode>();
lfoNode->set_strength(1.f);
graph->add(lfoNode);
graph->connect(lfoNode->output(strVal.c_str()), graph->output()->input("Surface"));
outputNode = lfoNode;
}
}
}
if (outputNode == nullptr) {
EmissionNode *emissionNode = graph->create_node<EmissionNode>();
emissionNode->set_color(one_float3());
emissionNode->set_strength(1.0f);