Skip to content

Commit f6987fb

Browse files
committed
path tracer doesn't store a ray gen, instead takes a generated ray for sampleMeasure
1 parent 82ee23c commit f6987fb

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

include/nbl/builtin/hlsl/path_tracing/unidirectional.hlsl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ namespace hlsl
1919
namespace path_tracing
2020
{
2121

22-
template<class RandGen, class RayGen, class Intersector, class MaterialSystem, /* class PathGuider, */ class NextEventEstimator, class Accumulator, class Scene
23-
NBL_PRIMARY_REQUIRES(concepts::RandGenerator<RandGen> && concepts::RayGenerator<RayGen> &&
22+
template<class RandGen, class Ray, class Intersector, class MaterialSystem, /* class PathGuider, */ class NextEventEstimator, class Accumulator, class Scene
23+
NBL_PRIMARY_REQUIRES(concepts::RandGenerator<RandGen> && concepts::Ray<Ray> &&
2424
concepts::Intersector<Intersector> && concepts::MaterialSystem<MaterialSystem> &&
2525
concepts::NextEventEstimator<NextEventEstimator> && concepts::Accumulator<Accumulator> &&
2626
concepts::Scene<Scene>)
2727
struct Unidirectional
2828
{
29-
using this_t = Unidirectional<RandGen, RayGen, Intersector, MaterialSystem, NextEventEstimator, Accumulator, Scene>;
29+
using this_t = Unidirectional<RandGen, Ray, Intersector, MaterialSystem, NextEventEstimator, Accumulator, Scene>;
3030
using randgen_type = RandGen;
31-
using raygen_type = RayGen;
3231
using intersector_type = Intersector;
3332
using material_system_type = MaterialSystem;
3433
using nee_type = NextEventEstimator;
@@ -40,7 +39,7 @@ struct Unidirectional
4039
using measure_type = typename MaterialSystem::measure_type;
4140
using sample_type = typename NextEventEstimator::sample_type;
4241
using ray_dir_info_type = typename sample_type::ray_dir_info_type;
43-
using ray_type = typename RayGen::ray_type;
42+
using ray_type = Ray;
4443
using object_handle_type = typename Intersector::object_handle_type;
4544
using closest_hit_type = typename Intersector::closest_hit_type;
4645
using bxdfnode_type = typename MaterialSystem::bxdfnode_type;
@@ -180,14 +179,10 @@ struct Unidirectional
180179
}
181180

182181
// Li
183-
void sampleMeasure(uint32_t sampleIndex, uint32_t maxDepth, NBL_REF_ARG(Accumulator) accumulator)
182+
void sampleMeasure(NBL_REF_ARG(ray_type) ray, uint32_t sampleIndex, uint32_t maxDepth, NBL_REF_ARG(Accumulator) accumulator)
184183
{
185-
//scalar_type meanLumaSq = 0.0;
186-
vector3_type uvw = randGen(0u, sampleIndex);
187-
ray_type ray = rayGen.generate(uvw);
188-
ray.initPayload();
189-
190184
// bounces
185+
// note do 1-based indexing because we expect first dimension was consumed to generate the ray
191186
bool continuePath = true;
192187
for (uint16_t d = 1; (d <= maxDepth) && continuePath; d++)
193188
{
@@ -210,7 +205,6 @@ struct Unidirectional
210205
}
211206

212207
randgen_type randGen;
213-
raygen_type rayGen;
214208
material_system_type materialSystem;
215209
nee_type nee;
216210
scene_type scene;

0 commit comments

Comments
 (0)