Skip to content

Commit b1633b1

Browse files
Make gauss and box-mueller not mix precision with float16_t
1 parent 4a1422f commit b1633b1

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

include/nbl/builtin/hlsl/path_tracing/gaussian_filter.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ struct GaussianFilter
2121
static this_t create(const scalar_type gaussianFilterCutoff, const scalar_type stddev)
2222
{
2323
this_t retval;
24-
retval.truncation = hlsl::exp(-0.5 * gaussianFilterCutoff * gaussianFilterCutoff);
24+
retval.truncation = hlsl::exp(-scalar_type(0.5) * gaussianFilterCutoff * gaussianFilterCutoff);
2525
retval.boxMuller.stddev = stddev;
2626
return retval;
2727
}
2828

2929
vector2_type sample(const vector2_type randVec)
3030
{
3131
vector2_type remappedRand = randVec;
32-
remappedRand.x *= 1.0 - truncation;
32+
remappedRand.x *= scalar_type(1) - truncation;
3333
remappedRand.x += truncation;
3434
return boxMuller(remappedRand);
3535
}

include/nbl/builtin/hlsl/sampling/box_muller_transform.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ struct BoxMullerTransform
2424
vector2_type operator()(const vector2_type xi)
2525
{
2626
scalar_type sinPhi, cosPhi;
27-
math::sincos<scalar_type>(2.0 * numbers::pi<scalar_type> * xi.y - numbers::pi<scalar_type>, sinPhi, cosPhi);
28-
return vector2_type(cosPhi, sinPhi) * nbl::hlsl::sqrt(-2.0 * nbl::hlsl::log(xi.x)) * stddev;
27+
math::sincos<scalar_type>(scalar_type(2) * numbers::pi<scalar_type> * xi.y - numbers::pi<scalar_type>, sinPhi, cosPhi);
28+
return vector2_type(cosPhi, sinPhi) * nbl::hlsl::sqrt(scalar_type(-2) * nbl::hlsl::log(xi.x)) * stddev;
2929
}
3030

3131
vector2_type backwardPdf(const vector2_type outPos)

0 commit comments

Comments
 (0)