-
-
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.
Material, Medium and State structures
- Loading branch information
1 parent
ba781d2
commit 6e1b885
Showing
6 changed files
with
158 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::prelude::*; | ||
|
||
// State | ||
|
||
#[derive(PartialEq, Clone, Debug)] | ||
pub struct State { | ||
|
||
pub depth : u16, | ||
pub eta : PTF, | ||
|
||
pub hit_dist : PTF, | ||
|
||
pub fhp : PTF3, | ||
pub normal : PTF3, | ||
pub ffnormal : PTF3, | ||
pub tangent : PTF3, | ||
pub bitangent : PTF3, | ||
|
||
pub is_emitter : bool, | ||
|
||
pub mat : Material, | ||
pub medium : Medium, | ||
} | ||
|
||
impl State { | ||
pub fn new() -> Self { | ||
Self { | ||
depth : 0, | ||
eta : 0.0, | ||
|
||
hit_dist : -1.0, | ||
|
||
fhp : PTF3::new(0.0, 0.0, 0.0), | ||
normal : PTF3::new(0.0, 0.0, 0.0), | ||
ffnormal : PTF3::new(0.0, 0.0, 0.0), | ||
tangent : PTF3::new(0.0, 0.0, 0.0), | ||
bitangent : PTF3::new(0.0, 0.0, 0.0), | ||
|
||
is_emitter : false, | ||
|
||
mat : Material::new(PTF3::new(1.0, 1.0, 1.0)), | ||
medium : Medium::new(), | ||
} | ||
} | ||
} |
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,98 @@ | ||
use crate::prelude::*; | ||
|
||
// Medium | ||
|
||
#[derive(PartialEq, Clone, Debug)] | ||
pub enum MediumType { | ||
None, | ||
Absorb, | ||
Scatter, | ||
Emissive | ||
} | ||
|
||
#[derive(PartialEq, Clone, Debug)] | ||
pub struct Medium { | ||
pub medium_type : MediumType, | ||
pub density : PTF, | ||
pub color : PTF3, | ||
pub anisotropy : PTF, | ||
} | ||
|
||
impl Medium { | ||
|
||
pub fn new() -> Self { | ||
Self { | ||
medium_type : MediumType::None, | ||
density : 0.0, | ||
color : PTF3::new(0.0, 0.0, 0.0), | ||
anisotropy : 0.0, | ||
} | ||
} | ||
} | ||
|
||
// Material | ||
|
||
#[derive(PartialEq, Clone, Debug)] | ||
pub enum AlphaMode | ||
{ | ||
Opaque, | ||
Blend, | ||
Mask | ||
} | ||
|
||
#[derive(PartialEq, Clone, Debug)] | ||
pub struct Material { | ||
pub base_color : PTF3, | ||
pub anisotropic : PTF, | ||
pub emission : PTF3, | ||
|
||
pub metallic : PTF, | ||
pub roughness : PTF, | ||
pub subsurface : PTF, | ||
pub specular_tint : PTF, | ||
|
||
pub sheen : PTF, | ||
pub sheen_tint : PTF, | ||
pub clearcoat : PTF, | ||
pub clearcoat_gloss : PTF, | ||
|
||
pub spec_trans : PTF, | ||
pub ior : PTF, | ||
|
||
pub opacity : PTF, | ||
pub alpha_mode : AlphaMode, | ||
pub alpha_cutoff : PTF, | ||
|
||
pub medium : Medium | ||
} | ||
|
||
impl Material { | ||
|
||
pub fn new(base_color: PTF3) -> Self { | ||
Self { | ||
base_color, | ||
emission : PTF3::new(0.0, 0.0, 0.0), | ||
|
||
anisotropic : 0.0, | ||
metallic : 0.0, | ||
roughness : 0.5, | ||
subsurface : 0.0, | ||
specular_tint : 0.0, | ||
|
||
sheen : 0.0, | ||
sheen_tint : 0.0, | ||
|
||
clearcoat : 0.0, | ||
clearcoat_gloss : 0.0, | ||
spec_trans : 0.0, | ||
ior : 1.5, | ||
|
||
opacity : 1.0, | ||
alpha_mode : AlphaMode::Opaque, | ||
alpha_cutoff : 0.0, | ||
|
||
medium : Medium::new() | ||
} | ||
} | ||
|
||
} |
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