Skip to content

Commit

Permalink
Fix light intensity overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
iaomw committed Sep 26, 2023
1 parent a0570ff commit d31777b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion projects/FBX/MayaCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,15 @@ struct LightNode : INode {

auto exposure = get_input2<float>("exposure");
auto intensity = get_input2<float>("intensity");
intensity *= pow(2.0, exposure);

auto scaler = powf(2.0f, exposure);

if (std::isnan(scaler) || std::isinf(scaler) || scaler < 0.0f) {
scaler = 1.0f;
printf("Light exposure = %f is invalid, fallback to 0.0 \n", exposure);
}

intensity *= scaler;

auto prim = std::make_shared<zeno::PrimitiveObject>();
auto &verts = prim->verts;
Expand Down Expand Up @@ -301,6 +309,14 @@ struct LightNode : INode {

auto &clr = prim->verts.add_attr<zeno::vec3f>("clr");
auto c = color * intensity;

for (size_t i=0; i<c.size(); ++i) {
if (std::isnan(c[i]) || std::isinf(c[i]) || c[i] < 0.0f) {
c[i] = 1.0f;
printf("Light color component %llu is invalid, fallback to 1.0 \n", i);
}
}

for(int i=0; i<verts.size(); i++){
clr[i] = c;
}
Expand Down

0 comments on commit d31777b

Please sign in to comment.