-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
156 additions
and
45 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 +1,13 @@ | ||
{ | ||
"img_width": 600.0, | ||
"img_height": 600.0, | ||
"samples": 8, | ||
"max_depth": 12, | ||
"samples": 12, | ||
"max_depth": 8, | ||
"sky_color": { | ||
"r": 0.3, | ||
"g": 0.5, | ||
"b": 0.9 | ||
}, | ||
"bvh_split_method": "Mid" | ||
"pixel_radius": 2.0, | ||
"bvh_split_method": "SAH" | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
/// Enum for different filter classes | ||
#[derive(Debug, Clone)] | ||
pub enum Filter { | ||
MitchellNetravali(MitchellNetravali), | ||
} | ||
|
||
impl Filter { | ||
pub fn evaluate(&self, sample_x: f64, sample_y: f64) -> f64 { | ||
match self { | ||
Filter::MitchellNetravali(filter) => filter.evaluate(sample_x, sample_y), | ||
} | ||
} | ||
pub fn get_radius(&self) -> (f64, f64) { | ||
match self { | ||
Filter::MitchellNetravali(filter) => filter.get_radius(), | ||
} | ||
} | ||
} | ||
|
||
/// Struct for MitchellNetravali filter | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct MitchellNetravali { | ||
width: f64, | ||
height: f64, | ||
inv_width: f64, | ||
inv_height: f64, | ||
b: f64, | ||
c: f64, | ||
} | ||
|
||
impl MitchellNetravali { | ||
|
||
/// Returns a new MN filter | ||
pub fn new(w: f64, h: f64, b: f64, c: f64) -> Self { | ||
MitchellNetravali { | ||
width: w, | ||
height: h, | ||
inv_width: 1.0 / w, | ||
inv_height: 1.0 / h, | ||
b, | ||
c, | ||
} | ||
} | ||
|
||
#[inline(always)] | ||
fn mitchell_1d(&self, x: f64) -> f64 { | ||
let fx = x.abs() * 2.0; | ||
if fx < 1.0 { | ||
((12.0 - 9.0 * self.b - 6.0 * self.c) * fx * fx * fx | ||
+ (-18.0 + 12.0 * self.b + 6.0 * self.c) * fx * fx | ||
+ (6.0 - 2.0 * self.b)) | ||
* (1.0 / 6.0) | ||
} else if fx < 2.0 { | ||
((-self.b - 6.0 * self.c) * fx * fx * fx | ||
+ (6.0 * self.b + 30.0 * self.c) * fx * fx | ||
+ (-12.0 * self.b - 48.0 * self.c) * fx | ||
+ (8.0 * self.b + 24.0 * self.c)) | ||
* (1.0 / 6.0) | ||
} else { | ||
0.0 | ||
} | ||
} | ||
|
||
/// Evaluates the MN filter for a given sample position | ||
#[inline(always)] | ||
pub fn evaluate(&self, sample_x: f64, sample_y: f64) -> f64 { | ||
self.mitchell_1d(sample_x * self.inv_width) * self.mitchell_1d(sample_y * self.inv_height) | ||
} | ||
|
||
/// Returns the radius set for the MN filter | ||
#[inline(always)] | ||
pub fn get_radius(&self) -> (f64, f64) { | ||
(self.width, self.height) | ||
} | ||
|
||
} |
Oops, something went wrong.