Rendering lto orb barely
This commit is contained in:
parent
479cf89e8d
commit
eeae057204
4 changed files with 97 additions and 64 deletions
|
|
@ -248,12 +248,12 @@ fn parse_shape<R>(iter: &mut Tokenizer) -> Result<Statement<R>> {
|
|||
"loopsubdiv" => {
|
||||
let t = parse_dict!(iter =>
|
||||
levels, u32, 3;
|
||||
indices, Vec<usize>, Vec::new();
|
||||
indices, Vec<[usize;3]>, Vec::new();
|
||||
p, Vec<Pos3>, Vec::new();
|
||||
alpha, ShapeAlpha, ShapeAlpha::None
|
||||
=>
|
||||
levels, "integer levels", iter.parse_parameter()?;
|
||||
indices, "integer indices", iter.parse_list()?;
|
||||
indices, "integer indices", iter.parse_list_3(|a, b, c|[a, b, c])?;
|
||||
p, "point3 P", iter.parse_list_3(Pos3::new)?;
|
||||
alpha, "float alpha", ShapeAlpha::Value(iter.parse_parameter()?);
|
||||
alpha, "texture alpha", ShapeAlpha::Texture(iter.parse_parameter()?)
|
||||
|
|
@ -263,16 +263,26 @@ fn parse_shape<R>(iter: &mut Tokenizer) -> Result<Statement<R>> {
|
|||
bail!("indices are a required field")
|
||||
}
|
||||
|
||||
if t.p.is_empty() {
|
||||
bail!("p is a required field")
|
||||
if t.p.len() < 3 {
|
||||
bail!("at least 3 vertices required")
|
||||
}
|
||||
|
||||
eprintln!(
|
||||
"WARNING: loopsubdiv is bodged. No subdivisions. levels: {}",
|
||||
t.levels
|
||||
);
|
||||
|
||||
Ok(Statement::Shape(
|
||||
ShapeType::LoopSubDiv {
|
||||
levels: t.levels,
|
||||
ShapeType::TriangleMesh(Bvh::new(
|
||||
TriangleMesh {
|
||||
indices: t.indices,
|
||||
p: t.p,
|
||||
n: Vec::new(),
|
||||
s: Vec::new(),
|
||||
uv: Vec::new(),
|
||||
},
|
||||
8,
|
||||
)),
|
||||
t.alpha,
|
||||
))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,13 +70,17 @@ struct PbrtCoatedDiffuseMaterial {
|
|||
impl<R: Rng> PbrtMaterial<R> for PbrtCoatedDiffuseMaterial {
|
||||
fn eval(&self, u: Float, v: Float, w_in: Dir3, w_out: Dir3, rng: &mut R) -> Color {
|
||||
let _ = rng;
|
||||
let _ = w_out;
|
||||
let _ = w_in;
|
||||
let _ = u;
|
||||
let _ = v;
|
||||
if w_out.y() >= 0.0 {
|
||||
match &self.reflectance {
|
||||
Either::A(v) => *v,
|
||||
Either::B(t) => t.get(u, v),
|
||||
}
|
||||
} else {
|
||||
Color::black()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -202,7 +206,9 @@ pub fn parse_material<R: Rng>(
|
|||
"texture reflectance", Either::B(parse_2d_spectrum_texture(input, context)?)
|
||||
]
|
||||
))),
|
||||
"coateddiffuse" => Ok(Arc::new(parse_dict2!(input, PbrtCoatedDiffuseMaterial;
|
||||
"coateddiffuse" => Ok({
|
||||
eprintln!("WARNING: coateddiffuse has no coating");
|
||||
Arc::new(parse_dict2!(input, PbrtCoatedDiffuseMaterial;
|
||||
albedo, Either::A(Color::black()), [
|
||||
"rgb albedo", Either::A(texture::parse_rgb(input)?);
|
||||
"spectrum albedo", Either::A(texture::parse_spectrum(input)?);
|
||||
|
|
@ -245,7 +251,8 @@ pub fn parse_material<R: Rng>(
|
|||
}
|
||||
}
|
||||
]
|
||||
))),
|
||||
))
|
||||
}),
|
||||
"dielectric" => Ok(Arc::new(parse_dict2!(input, PbrtDielectricMaterial;
|
||||
eta, Either::A(Either::A(1.5)), [
|
||||
"float eta", Either::A(Either::A(input.parse_parameter()?));
|
||||
|
|
|
|||
|
|
@ -159,11 +159,6 @@ pub(crate) enum ShapeType {
|
|||
n: Vec<Dir3>,
|
||||
uv: Vec<[Float; 2]>,
|
||||
},
|
||||
LoopSubDiv {
|
||||
levels: u32,
|
||||
indices: Vec<usize>,
|
||||
p: Vec<Pos3>,
|
||||
},
|
||||
Disk {
|
||||
height: Float,
|
||||
radius: Float,
|
||||
|
|
|
|||
|
|
@ -121,8 +121,29 @@ impl Pbrt2dSpectrumTexture for SpectrumImageMapTexture {
|
|||
|
||||
let (w, h) = self.image.dimensions();
|
||||
|
||||
dbg!(u, v, w, h);
|
||||
todo!()
|
||||
let (u, v) = match self.wrap {
|
||||
ImageMapWrap::Repeat => (
|
||||
if u < 0.0 { 1.0 + u.fract() } else { u.fract() },
|
||||
if v < 0.0 { 1.0 + v.fract() } else { v.fract() },
|
||||
),
|
||||
ImageMapWrap::Black => {
|
||||
if !(0.0..=1.0).contains(&u) || !(0.0..=1.0).contains(&v) {
|
||||
return Color::black();
|
||||
}
|
||||
|
||||
(u, v)
|
||||
}
|
||||
ImageMapWrap::Clamp => (u.clamp(0.0, 1.0), v.clamp(0.0, 1.0)),
|
||||
};
|
||||
|
||||
let x = u * w as Float;
|
||||
let y = v * h as Float;
|
||||
|
||||
let c = self
|
||||
.image
|
||||
.get_pixel((x as u32).clamp(0, w - 1), (y as u32).clamp(0, h - 1));
|
||||
|
||||
Color::new(c.0[0], c.0[1], c.0[2])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue