@@ -144,29 +144,29 @@ void BakeCPURenderThread::RenderEyeSample(const BakeMapInfo &mapInfo, PathTracer
144144
145145 // Pick a scene object to sample
146146 float sceneObjPickPdf;
147- const u_int currentSceneObjIndex = engine->currentSceneObjsDist ->SampleDiscrete (state.eyeSampler -> GetSample (0 ), &sceneObjPickPdf);
147+ const u_int currentSceneObjIndex = engine->currentSceneObjsDist ->SampleDiscrete (state.GetEyeSampler (). GetSample (0 ), &sceneObjPickPdf);
148148 auto & sceneObj = *engine->currentSceneObjsToBake [currentSceneObjIndex];
149149 auto & mesh = sceneObj.GetExtMesh ();
150150
151151 // Pick a triangle to sample
152152 float triPickPdf;
153- const u_int triangleIndex = engine->currentSceneObjDist [currentSceneObjIndex]->SampleDiscrete (state.eyeSampler -> GetSample (1 ), &triPickPdf);
153+ const u_int triangleIndex = engine->currentSceneObjDist [currentSceneObjIndex]->SampleDiscrete (state.GetEyeSampler (). GetSample (1 ), &triPickPdf);
154154
155- const float timeSample = state.eyeSampler -> GetSample (4 );
155+ const float timeSample = state.GetEyeSampler (). GetSample (4 );
156156 Transform localToWorld;
157157 mesh.GetLocal2World (timeSample, localToWorld);
158158
159159 // Origin
160160 Point samplePoint;
161161 float b0, b1, b2;
162- mesh.Sample (localToWorld, triangleIndex, state.eyeSampler -> GetSample (2 ), state.eyeSampler -> GetSample (3 ),
162+ mesh.Sample (localToWorld, triangleIndex, state.GetEyeSampler (). GetSample (2 ), state.GetEyeSampler (). GetSample (3 ),
163163 &samplePoint, &b0, &b1, &b2);
164164
165165 const u_int sceneObjIndex = state.scene .GetObjects ().GetSceneObjectIndex (sceneObj);
166166 const PathVolumeInfo volInfo;
167167 BSDF bsdf (state.scene , sceneObjIndex, triangleIndex,
168168 samplePoint, b1, b2,
169- timeSample, state.eyeSampler -> GetSample (pathTracer.eyeSampleSize ), &volInfo);
169+ timeSample, state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize ), &volInfo);
170170
171171 // --------------------------------------------------------------------------
172172 // Set up the sample result
@@ -191,11 +191,11 @@ void BakeCPURenderThread::RenderEyeSample(const BakeMapInfo &mapInfo, PathTracer
191191
192192 const PathTracer::DirectLightResult directLightResult = pathTracer.DirectLightSampling (state.device , state.scene ,
193193 timeSample,
194- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 3 ),
195- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 4 ),
196- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 5 ),
197- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 6 ),
198- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 7 ),
194+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 3 ),
195+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 4 ),
196+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 5 ),
197+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 6 ),
198+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 7 ),
199199 pathInfo,
200200 Spectrum (1 .f ), bsdf, &sampleResult);
201201
@@ -216,8 +216,8 @@ void BakeCPURenderThread::RenderEyeSample(const BakeMapInfo &mapInfo, PathTracer
216216 float bsdfPdfW;
217217 BSDFEvent bsdfEvent;
218218 const Spectrum bsdfSample = bsdf.Sample (&sampledDir,
219- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 1 ),
220- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 2 ),
219+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 1 ),
220+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 2 ),
221221 &bsdfPdfW, &cosSampledDir, &bsdfEvent);
222222
223223 pathInfo.AddVertex (bsdf, bsdfEvent, bsdfPdfW, pathTracer.hybridBackForwardGlossinessThreshold );
@@ -235,7 +235,7 @@ void BakeCPURenderThread::RenderEyeSample(const BakeMapInfo &mapInfo, PathTracer
235235
236236 pathTracer.RenderEyePath (
237237 state.device , state.scene ,
238- * state.eyeSampler ,
238+ state.GetEyeSampler () ,
239239 pathInfo,
240240 eyeRay,
241241 bsdfSample,
@@ -259,11 +259,11 @@ void BakeCPURenderThread::RenderEyeSample(const BakeMapInfo &mapInfo, PathTracer
259259
260260 const PathTracer::DirectLightResult directLightResult = pathTracer.DirectLightSampling (state.device , state.scene ,
261261 timeSample,
262- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 3 ),
263- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 4 ),
264- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 5 ),
265- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 6 ),
266- state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 7 ),
262+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 3 ),
263+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 4 ),
264+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 5 ),
265+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 6 ),
266+ state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 7 ),
267267 pathInfo,
268268 Spectrum (1 .f ), bsdf, &sampleResult,
269269 false );
@@ -280,8 +280,8 @@ void BakeCPURenderThread::RenderEyeSample(const BakeMapInfo &mapInfo, PathTracer
280280 // --------------------------------------------------------------
281281
282282 // Ray direction
283- const float u1 = state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 1 );
284- const float u2 = state.eyeSampler -> GetSample (pathTracer.eyeSampleSize + 2 );
283+ const float u1 = state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 1 );
284+ const float u2 = state.GetEyeSampler (). GetSample (pathTracer.eyeSampleSize + 2 );
285285 const Vector localSampledDir = UniformSampleHemisphere (u1, u2);
286286 const Vector sampledDir = bsdf.GetFrame ().ToWorld (localSampledDir);
287287
@@ -301,7 +301,7 @@ void BakeCPURenderThread::RenderEyeSample(const BakeMapInfo &mapInfo, PathTracer
301301
302302 const float NdotL = Dot (bsdf.hitPoint .shadeN , sampledDir);
303303 pathTracer.RenderEyePath (state.device , state.scene ,
304- * state.eyeSampler , pathInfo, eyeRay, Spectrum (NdotL * INV_PI / samplePdf),
304+ state.GetEyeSampler () , pathInfo, eyeRay, Spectrum (NdotL * INV_PI / samplePdf),
305305 state.GetEyeSampleResults ());
306306 }
307307 break ;
@@ -365,7 +365,7 @@ void BakeCPURenderThread::RenderLightSample(const BakeMapInfo &mapInfo, PathTrac
365365 const PathTracer::ConnectToEyeCallBackType connectToEyeCallBack = std::bind (
366366 &BakeCPURenderThread::RenderConnectToEyeCallBack, this , mapInfo, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
367367
368- pathTracer.RenderLightSample (state.device , state.scene , state.GetFilm (), * state.lightSampler ,
368+ pathTracer.RenderLightSample (state.device , state.scene , state.GetFilm (), state.GetLightSampler () ,
369369 state.GetLightSampleResults (), connectToEyeCallBack);
370370}
371371
@@ -374,21 +374,22 @@ void BakeCPURenderThread::RenderSample(const BakeMapInfo &mapInfo, PathTracerThr
374374 const PathTracer &pathTracer = engine->pathTracer ;
375375
376376 // Check if I have to trace an eye or light path
377- const SamplerUPtr& sampler =
378- pathTracer.HasToRenderEyeSample (state) ? state.eyeSampler : state.lightSampler ;
377+ bool eyeSampling = pathTracer.HasToRenderEyeSample (state);
378+ SamplerRef sampler =
379+ eyeSampling ? state.GetEyeSampler () : state.GetLightSampler ();
379380
380- std::vector<SampleResult>& sampleResults = pathTracer. HasToRenderEyeSample (state) ?
381+ std::vector<SampleResult>& sampleResults = eyeSampling ?
381382 state.GetEyeSampleResults () : state.GetLightSampleResults ();
382383
383- if (sampler == state. eyeSampler )
384+ if (eyeSampling )
384385 RenderEyeSample (mapInfo, state);
385386 else
386387 RenderLightSample (mapInfo, state);
387388
388389 // Variance clamping
389390 pathTracer.ApplyVarianceClamp (state, sampleResults);
390391
391- sampler-> NextSample (sampleResults);
392+ sampler. NextSample (sampleResults);
392393}
393394
394395void BakeCPURenderThread::RenderFunc (std::stop_token stop_token) {
0 commit comments