Skip to content

Commit 2a91a80

Browse files
Add quotient_and_pdf struct and transmit/reflect to RayDirInfo concept
1 parent 605f3c4 commit 2a91a80

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

include/nbl/builtin/hlsl/bxdf/common.hlsl

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef _NBL_BUILTIN_HLSL_BXDF_COMMON_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_BXDF_COMMON_INCLUDED_
66

7+
#include <nbl/builtin/hlsl/limits.hlsl>
8+
79
namespace nbl
810
{
911
namespace hlsl
@@ -20,6 +22,20 @@ struct Basic
2022
{
2123
float3 getDirection() {return direction;}
2224

25+
Basic transmit()
26+
{
27+
Basic retval;
28+
retval.direction = -direction;
29+
return retval;
30+
}
31+
32+
Basic reflect(const float3 N, const float directionDotN)
33+
{
34+
Basic retval;
35+
retval.direction = nbl::hlsl::reflect(direction,N,directionDotN);
36+
return retval;
37+
}
38+
2339
float3 direction;
2440
};
2541
// more to come!
@@ -211,11 +227,26 @@ struct AnisotropicMicrofacetCache : IsotropicMicrofacetCache
211227

212228

213229
// finally fixed the semantic F-up, value/pdf = quotient not remainder
214-
template<typename SpectralBuckets>
215-
SpectralBuckets quotient_to_value(const SpectralBuckets quotient, const float pdf)
230+
template<typename SpectralBins>
231+
struct quotient_and_pdf
216232
{
217-
return quotient*pdf;
218-
}
233+
quotient_and_pdf<SpectralBins> create(const SpectralBins _quotient, const float _pdf)
234+
{
235+
quotient_and_pdf<SpectralBins> retval;
236+
retval.quotient = _quotient;
237+
retval.pdf = _pdf;
238+
return retval;
239+
}
240+
241+
SpectralBins value()
242+
{
243+
return quotient*pdf;
244+
}
245+
246+
SpectralBins quotient;
247+
float pdf;
248+
};
249+
219250

220251
}
221252
}

0 commit comments

Comments
 (0)