Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/vsg/vk/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ namespace vsg
value_type f = -proj[1][1];
value_type sc = f * std::sqrt(square(mv[0][0]) + square(mv[1][0]) + square(mv[2][0]) + square(mv[0][1]) + square(mv[1][1]) + square(mv[2][1])) * 0.5;
value_type inv_scale = value_type(1.0) / sc;

// For an orthographic projection the projected size of a bounding sphere is independent of
// its distance from the eye (proj[2][3] == 0: there is no perspective divide). Using the
// eye-space depth as done below for perspective would make LOD selection and small-feature
// culling vary with distance, which is wrong for ortho, so use a constant lod distance
// derived purely from the projection scale.
if (proj[2][3] == value_type(0.0))
{
lodScale.set(value_type(0.0), value_type(0.0), value_type(0.0), inv_scale);
return;
}

lodScale.set(mv[0][2] * inv_scale,
mv[1][2] * inv_scale,
mv[2][2] * inv_scale,
Expand Down
Loading