-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #208 from Walther/2024-06-bvh-improvements
Surface Area Heuristic for Bounding Value Hierarchy structures
- Loading branch information
Showing
57 changed files
with
1,755 additions
and
1,100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//! Alternative rendering methods for debug visualization purposes. | ||
|
||
use clovers::{ray::Ray, scenes::Scene, Float, EPSILON_SHADOW_ACNE}; | ||
use palette::LinSrgb; | ||
use rand::rngs::SmallRng; | ||
|
||
/// Visualizes the BVH traversal count - how many BVH nodes needed to be tested for intersection? | ||
#[must_use] | ||
pub fn bvh_testcount(ray: &Ray, scene: &Scene, rng: &mut SmallRng) -> LinSrgb { | ||
let mut depth = 0; | ||
scene | ||
.bvh_root | ||
.testcount(&mut depth, ray, EPSILON_SHADOW_ACNE, Float::MAX, rng); | ||
|
||
bvh_testcount_to_color(depth) | ||
} | ||
|
||
#[must_use] | ||
pub fn bvh_testcount_to_color(depth: usize) -> LinSrgb { | ||
match depth { | ||
// under 256, grayscale | ||
0..=255 => { | ||
let depth = depth as Float / 255.0; | ||
LinSrgb::new(depth, depth, depth) | ||
} | ||
// more than 256, yellow | ||
256..=511 => LinSrgb::new(1.0, 1.0, 0.0), | ||
// more than 512, orange | ||
512..=1023 => LinSrgb::new(1.0, 0.5, 0.0), | ||
// more than 1024, red | ||
1024.. => LinSrgb::new(1.0, 0.0, 0.0), | ||
} | ||
} | ||
|
||
/// Visualizes the primitive traversal count - how many primitives needed to be tested for intersection? | ||
#[must_use] | ||
pub fn primitive_testcount(ray: &Ray, scene: &Scene, rng: &mut SmallRng) -> LinSrgb { | ||
let mut depth = 0; | ||
scene | ||
.bvh_root | ||
.primitive_testcount(&mut depth, ray, EPSILON_SHADOW_ACNE, Float::MAX, rng); | ||
|
||
primitive_testcount_to_color(depth) | ||
} | ||
|
||
#[must_use] | ||
pub fn primitive_testcount_to_color(depth: usize) -> LinSrgb { | ||
match depth { | ||
// under 256, grayscale | ||
0..=255 => { | ||
let depth = depth as Float / 255.0; | ||
LinSrgb::new(depth, depth, depth) | ||
} | ||
// more than 256, yellow | ||
256..=511 => LinSrgb::new(1.0, 1.0, 0.0), | ||
// more than 512, orange | ||
512..=1023 => LinSrgb::new(1.0, 0.5, 0.0), | ||
// more than 1024, red | ||
1024.. => LinSrgb::new(1.0, 0.0, 0.0), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
//! Runtime functions of the `clovers` renderer. | ||
|
||
use clap::Args; | ||
|
||
pub mod colorize; | ||
pub mod debug_visualizations; | ||
pub mod draw_cpu; | ||
pub mod json_scene; | ||
pub mod normals; | ||
pub mod render; | ||
pub mod sampler; | ||
pub mod scenefile; | ||
|
||
// TODO: move this into a better place - but keep rustc happy with the imports | ||
/// Global options | ||
#[derive(Args, Debug)] | ||
pub struct GlobalOptions { | ||
/// Enable some debug logging | ||
#[clap(long)] | ||
pub debug: bool, | ||
/// Suppress most of the text output | ||
#[clap(short, long)] | ||
pub quiet: bool, | ||
} |
Oops, something went wrong.