Skip to content

Commit

Permalink
fix for unorm vertex position remap aabb zero axis precision problem …
Browse files Browse the repository at this point in the history
…with raytracing
  • Loading branch information
turanszkij committed Feb 17, 2024
1 parent 3e8fef2 commit a659741
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions WickedEngine/wiScene_Components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,20 +633,22 @@ namespace wi::scene
{
// This is done to avoid 0 scaling on any axis of the UNORM remap matrix of the AABB
// It specifically solves a problem with hardware raytracing which treats AABB with zero axis as invisible
if (aabb._max.x - aabb._min.x < std::numeric_limits<float>::epsilon())
// Also there was problem with using float epsilon value, it did not enough precision for raytracing
constexpr float min_dim = 0.01f;
if (aabb._max.x - aabb._min.x < min_dim)
{
aabb._max.x += std::numeric_limits<float>::epsilon();
aabb._min.x -= std::numeric_limits<float>::epsilon();
aabb._max.x += min_dim;
aabb._min.x -= min_dim;
}
if (aabb._max.y - aabb._min.y < std::numeric_limits<float>::epsilon())
if (aabb._max.y - aabb._min.y < min_dim)
{
aabb._max.y += std::numeric_limits<float>::epsilon();
aabb._min.y -= std::numeric_limits<float>::epsilon();
aabb._max.y += min_dim;
aabb._min.y -= min_dim;
}
if (aabb._max.z - aabb._min.z < std::numeric_limits<float>::epsilon())
if (aabb._max.z - aabb._min.z < min_dim)
{
aabb._max.z += std::numeric_limits<float>::epsilon();
aabb._min.z -= std::numeric_limits<float>::epsilon();
aabb._max.z += min_dim;
aabb._min.z -= min_dim;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/wiVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 380;
const int revision = 381;

const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);

Expand Down

0 comments on commit a659741

Please sign in to comment.