From 84b62470932b9d04f6aa05ceebfb4edd296b599e Mon Sep 17 00:00:00 2001 From: tigertang <491506913@qq.com> Date: Tue, 28 Aug 2018 11:25:04 +0800 Subject: [PATCH] Modify glm::refract according to GLSL man page: return vector zero when full reflection happens #806 --- glm/detail/func_geometric.inl | 5 ++--- glm/geometric.hpp | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/glm/detail/func_geometric.inl b/glm/detail/func_geometric.inl index b3590152..9cde28fe 100644 --- a/glm/detail/func_geometric.inl +++ b/glm/detail/func_geometric.inl @@ -114,11 +114,10 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& I, vec const& N, T eta) { - assert(eta >= static_cast(-1) && eta <= static_cast(1)); - T const dotValue(dot(N, I)); T const k(static_cast(1) - eta * eta * (static_cast(1) - dotValue * dotValue)); - vec const Result = (eta * I - (eta * dotValue + std::sqrt(k)) * N) * static_cast(k >= static_cast(0)); + vec const Result = + (k >= static_cast(0)) ? (eta * I - (eta * dotValue + std::sqrt(k)) * N) : vec(0); return Result; } }; diff --git a/glm/geometric.hpp b/glm/geometric.hpp index 28d76199..e0380830 100644 --- a/glm/geometric.hpp +++ b/glm/geometric.hpp @@ -99,8 +99,6 @@ namespace glm /// and the ratio of indices of refraction eta, /// return the refraction vector. /// - /// @param eta Indice of refraction. Must be a value between -1 and 1 inclusively. - /// /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// @tparam T Floating-point scalar types. ///