Skip to content

Commit ff66405

Browse files
committed
removed cast fp64 from frisvad
1 parent e193903 commit ff66405

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

include/nbl/builtin/hlsl/math/functions.hlsl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,20 @@ void sincos(T theta, NBL_REF_ARG(T) s, NBL_REF_ARG(T) c)
103103
template <typename T NBL_FUNC_REQUIRES(vector_traits<T>::Dimension == 3)
104104
void frisvad(NBL_CONST_REF_ARG(T) normal, NBL_REF_ARG(T) tangent, NBL_REF_ARG(T) bitangent)
105105
{
106-
const typename vector_traits<T>::scalar_type a = NBL_FP64_LITERAL(1.0) / (NBL_FP64_LITERAL(1.0) + normal.z);
107-
const typename vector_traits<T>::scalar_type b = -normal.x * normal.y * a;
108-
if (normal.z < -NBL_FP64_LITERAL(0.9999999))
106+
using scalar_t = typename vector_traits<T>::scalar_type;
107+
const scalar_t unit = _static_cast<scalar_t>(1);
108+
109+
const scalar_t a = unit / (unit + normal.z);
110+
const scalar_t b = -normal.x * normal.y * a;
111+
if (normal.z < -_static_cast<scalar_t>(0.9999999))
109112
{
110113
tangent = T(0.0,-1.0,0.0);
111114
bitangent = T(-1.0,0.0,0.0);
112115
}
113116
else
114117
{
115-
tangent = T(NBL_FP64_LITERAL(1.0)-normal.x*normal.x*a, b, -normal.x);
116-
bitangent = T(b, NBL_FP64_LITERAL(1.0)-normal.y*normal.y*a, -normal.y);
118+
tangent = T(unit - normal.x * normal.x * a, b, -normal.x);
119+
bitangent = T(b, unit - normal.y * normal.y * a, -normal.y);
117120
}
118121
}
119122

0 commit comments

Comments
 (0)