Free as in Freedom: Codeberg.org. Create your repos!
Browse Source

We can see the first photons contributing. Investigate the loop!

tags/v0.5.1
Jan Walter 2 months ago
parent
commit
069a859a53
1 changed files with 38 additions and 38 deletions
  1. 38
    38
      src/integrators/sppm.rs

+ 38
- 38
src/integrators/sppm.rs View File

@@ -408,7 +408,7 @@ pub fn render_sppm(
408 408
                 // TODO: ProfilePhase _(Prof::SPPMPhotonPass);
409 409
                 // TODO: ParallelFor([&](int photon_index) { ... }, photonsPerIteration, 8192);
410 410
                 println!("Trace photons and accumulate contributions ...");
411
-                for photon_index in pbr::PbIter::new(0..integrator.photons_per_iteration as usize) {
411
+                for photon_index in 0..integrator.photons_per_iteration as usize {
412 412
                     // MemoryArena &arena = photonShootArenas[ThreadIndex];
413 413
                     // follow photon path for _photon_index_
414 414
                     let halton_index: u64 =
@@ -487,43 +487,43 @@ pub fn render_sppm(
487 487
                                             photon_grid_index,
488 488
                                             hash_size
489 489
                                         );
490
-                                        // if let Some(root) = grid[h].get() {
491
-                                        //     let mut node: &SPPMPixelListNode = root;
492
-                                        //     loop {
493
-                                        //         // TODO: ++visiblePointsChecked;
494
-                                        //         let pixel = node.pixel.clone();
495
-                                        //         let radius: Float = pixel.radius;
496
-                                        //         if pnt3_distance_squared(&pixel.vp.p, &isect.p)
497
-                                        //             > radius * radius
498
-                                        //         {
499
-                                        //             if let Some(next_node) = node.next.get() {
500
-                                        //                 node = next_node;
501
-                                        //             } else {
502
-                                        //                 break;
503
-                                        //             }
504
-                                        //             continue;
505
-                                        //         }
506
-                                        //         // update _pixel_ $\phi$ and $m$ for nearby photon
507
-                                        //         let wi: Vector3f = -photon_ray.d;
508
-                                        //         if let Some(ref bsdf) = pixel.vp.bsdf {
509
-                                        //             let bsdf_flags: u8 = BxdfType::BsdfAll as u8;
510
-                                        //             let phi: Spectrum = beta
511
-                                        //                 * bsdf.f(&pixel.vp.wo, &wi, bsdf_flags);
512
-                                        //             for i in 0..3 {
513
-                                        //                 pixel.phi[i].add(phi[i]);
514
-                                        //             }
515
-                                        //             pixel.m.fetch_add(
516
-                                        //                 1_i32,
517
-                                        //                 atomic::Ordering::Relaxed,
518
-                                        //             );
519
-                                        //         }
520
-                                        //         if let Some(next_node) = node.next.get() {
521
-                                        //             node = next_node;
522
-                                        //         } else {
523
-                                        //             break;
524
-                                        //         }
525
-                                        //     }
526
-                                        // }
490
+                                        if !grid[h].is_none() {
491
+                                            let mut node = grid[h].take().unwrap();
492
+                                            loop {
493
+                                                // TODO: ++visiblePointsChecked;
494
+                                                let pixel = node.pixel.clone();
495
+                                                let radius: Float = pixel.radius;
496
+                                                if pnt3_distance_squared(&pixel.vp.p, &isect.p)
497
+                                                    > radius * radius
498
+                                                {
499
+                                                    if !node.next.is_none() {
500
+                                                        node = node.next.take().unwrap();
501
+                                                    } else {
502
+                                                        break;
503
+                                                    }
504
+                                                    continue;
505
+                                                }
506
+                                                // update _pixel_ $\phi$ and $m$ for nearby photon
507
+                                                let wi: Vector3f = -photon_ray.d;
508
+                                                if let Some(ref bsdf) = pixel.vp.bsdf {
509
+                                                    let bsdf_flags: u8 = BxdfType::BsdfAll as u8;
510
+                                                    let phi: Spectrum = beta
511
+                                                        * bsdf.f(&pixel.vp.wo, &wi, bsdf_flags);
512
+                                                    for i in 0..3 {
513
+                                                        pixel.phi[i].add(phi[i]);
514
+                                                    }
515
+                                                    pixel.m.fetch_add(
516
+                                                        1_i32,
517
+                                                        atomic::Ordering::Relaxed,
518
+                                                    );
519
+                                                }
520
+                                                if !node.next.is_none() {
521
+                                                    node = node.next.take().unwrap();
522
+                                                } else {
523
+                                                    break;
524
+                                                }
525
+                                            }
526
+                                        }
527 527
                                     }
528 528
                                 }
529 529
                                 // sample new photon ray direction

Loading…
Cancel
Save