Skip to content

Commit

Permalink
Moved lambda parameter into ViewDependentState.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Sep 27, 2023
1 parent bc7a064 commit 892442c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
3 changes: 3 additions & 0 deletions include/vsg/state/ViewDependentState.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ namespace vsg
// shadow map hints
double maxShadowDistance = 1e8;
double shadowMapBias = 0.005;
double lambda = 0.5;

// Shadow backend.
ref_ptr<CommandGraph> preRenderCommandGraph;
Expand All @@ -167,4 +168,6 @@ namespace vsg
};
VSG_type_name(vsg::ViewDependentState);



} // namespace vsg
21 changes: 8 additions & 13 deletions src/vsg/state/ViewDependentState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ namespace vsg
void traverse(RecordTraversal& visitor) const override { t_traverse(*this, visitor); }
};
VSG_type_name(TraverseChildrenOfNode);

inline double Cpractical(double n, double f, double i, double m, double lambda)
{
double Clog = n * std::pow((f / n), (i / m));
double Cuniform = n + (f - n) * (i / m);
return Clog * lambda + Cuniform * (1.0 - lambda);
};

} // namespace vsg

//////////////////////////////////////
Expand Down Expand Up @@ -459,18 +467,6 @@ void ViewDependentState::traverse(RecordTraversal& rt) const
return bounds;
};

auto Clog = [](double n, double f, double i, double m) -> double {
return n * std::pow((f / n), (i / m));
};

auto Cuniform = [](double n, double f, double i, double m) -> double {
return n + (f - n) * (i / m);
};

auto Cpractical = [&Clog, &Cuniform](double n, double f, double i, double m, double lambda) -> double {
return Clog(n, f, i, m) * lambda + Cuniform(n, f, i, m) * (1.0 - lambda);
};

// info("\n\nViewDependentState::traverse(", &rt, ", ", &view, ") numShadowMaps = ", numShadowMaps);

// set up the light data
Expand Down Expand Up @@ -624,7 +620,6 @@ void ViewDependentState::traverse(RecordTraversal& rt) const

if (activeNumShadowMaps > 1)
{
double lambda = 0.5;
double m = static_cast<double>(activeNumShadowMaps);
for (double i = 0; i < m; i += 1.0)
{
Expand Down

0 comments on commit 892442c

Please sign in to comment.