Fix all warnings
This commit is contained in:
parent
2bc5ec93fe
commit
ae4dc2c21a
26 changed files with 249 additions and 185 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use crate::prelude::*;
|
||||
use std::fmt::Debug;
|
||||
use std::{fmt::Debug, ops::Deref};
|
||||
|
||||
/// Trait to model bxdf.
|
||||
///
|
||||
|
|
@ -55,6 +55,20 @@ impl<R: Rng, M: Material<R>> Material<R> for &M {
|
|||
}
|
||||
}
|
||||
|
||||
impl<R: Rng> Material<R> for std::sync::Arc<dyn Material<R>> {
|
||||
fn eval(&self, w_in: Dir3, w_out: Dir3, rng: &mut R) -> Color {
|
||||
self.deref().eval(w_in, w_out, rng)
|
||||
}
|
||||
|
||||
fn sample(&self, w_in: Dir3, rng: &mut R) -> SampleResult {
|
||||
self.deref().sample(w_in, rng)
|
||||
}
|
||||
|
||||
fn pdf(&self, w_in: Dir3, w_out: Dir3) -> Float {
|
||||
self.deref().pdf(w_in, w_out)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SampleResult {
|
||||
w_out: Dir3,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
use core::panic;
|
||||
use std::ops::{Add, Index, Mul, Sub};
|
||||
use std::ops::{Add, Index, Sub};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Pos3 {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
use std::sync::{
|
||||
mpsc::{Receiver, Sender},
|
||||
Arc,
|
||||
};
|
||||
|
||||
use rand::{rngs::SmallRng, SeedableRng};
|
||||
use ray_tracing_core::{
|
||||
camera::{BasicCamera, Camera},
|
||||
prelude::*,
|
||||
renderer::ClassicalRenderer,
|
||||
scene::Scene,
|
||||
camera::BasicCamera, prelude::*, renderer::ClassicalRenderer, scene::Scene,
|
||||
};
|
||||
use ray_tracing_renderer::{
|
||||
depth_renderer::DepthRenderer, mis::MIS, next_event_estimation::NextEventEstimation,
|
||||
|
|
@ -19,6 +11,10 @@ use rayon::{
|
|||
iter::{IndexedParallelIterator, ParallelIterator},
|
||||
slice::ParallelSliceMut,
|
||||
};
|
||||
use std::sync::{
|
||||
mpsc::{Receiver, Sender},
|
||||
Arc,
|
||||
};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
memory::allocator::{AllocationCreateInfo, MemoryAllocator, MemoryTypeFilter},
|
||||
|
|
@ -62,7 +58,7 @@ fn render_pass<
|
|||
(x + y * settings.width) as u64
|
||||
+ (settings.width as u64 * settings.height as u64 * samples as u64),
|
||||
);
|
||||
let r = renderer.render_pixel(&scene, &camera, x, y, &mut rng);
|
||||
let r = renderer.render_pixel(scene, camera, x, y, &mut rng);
|
||||
c[0] += r.r();
|
||||
c[1] += r.g();
|
||||
c[2] += r.b();
|
||||
|
|
@ -159,6 +155,9 @@ pub fn render_thread(
|
|||
examples::ExampleSceneEnum::TriangleBVH(s) => {
|
||||
render_pass_renderer(&settings, s, &camera, samples, &mut buffer)
|
||||
}
|
||||
examples::ExampleSceneEnum::BasicScene(s) => {
|
||||
render_pass_renderer(&settings, s, &camera, samples, &mut buffer)
|
||||
}
|
||||
}
|
||||
samples += 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,5 +66,8 @@ fn main() -> ImageResult<()> {
|
|||
ray_tracing_scene::examples::ExampleSceneEnum::TriangleBVH(s) => {
|
||||
render_image(&r, s, &c, "test.exr", 1048)
|
||||
}
|
||||
ray_tracing_scene::examples::ExampleSceneEnum::BasicScene(s) => {
|
||||
render_image(&r, s, &c, "test.exr", 1048)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ impl Iridescent {
|
|||
let phi = 2.0 * f32::consts::PI * self.n2 * self.d2 * theta2.cos() / l;
|
||||
|
||||
let num_real = r12 * (1.0 - f32::cos(-2.0 * phi));
|
||||
let num_imag = r12 * (-1.0 * f32::sin(-2.0 * phi));
|
||||
let num_imag = r12 * -f32::sin(-2.0 * phi);
|
||||
|
||||
let denom_real = 1.0 - r12 * r12 * f32::cos(-2.0 * phi);
|
||||
let denom_imag = 0.0 - r12 * r12 * f32::sin(-2.0 * phi);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct Args {
|
|||
fn main() -> Result<(), miette::Error> {
|
||||
let args = Args::parse();
|
||||
|
||||
let t = parse_pbrt_v4(args.filename)?;
|
||||
let _t = parse_pbrt_v4(args.filename)?;
|
||||
|
||||
// dbg!(t);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ pub enum Either<A, B> {
|
|||
}
|
||||
|
||||
impl<A, B> Either<A, B> {
|
||||
pub fn map_a<C>(self, f: impl FnOnce(A) -> C) -> Either<C, B> {
|
||||
match self {
|
||||
Either::A(a) => Either::A(f(a)),
|
||||
Either::B(b) => Either::B(b),
|
||||
}
|
||||
}
|
||||
// pub fn map_a<C>(self, f: impl FnOnce(A) -> C) -> Either<C, B> {
|
||||
// match self {
|
||||
// Either::A(a) => Either::A(f(a)),
|
||||
// Either::B(b) => Either::B(b),
|
||||
// }
|
||||
// }
|
||||
pub fn map_b<C>(self, f: impl FnOnce(B) -> C) -> Either<A, C> {
|
||||
match self {
|
||||
Either::A(a) => Either::A(a),
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
use crate::{
|
||||
scene::PbrtScene,
|
||||
shape::{Shape, ShapeAlpha, ShapeType},
|
||||
texture::Pbrt_2d_float_texture,
|
||||
tokenizer::Tokenizer,
|
||||
};
|
||||
use error::SourceFile;
|
||||
use material::PbrtMaterial;
|
||||
use miette::{Diagnostic, IntoDiagnostic, Result, SourceSpan, bail, miette};
|
||||
use miette::{IntoDiagnostic, Result, bail, miette};
|
||||
use ray_tracing_core::{
|
||||
affine_transform::AffineTransform,
|
||||
math::{Dir3, Pos3},
|
||||
|
|
@ -18,7 +16,6 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
use texture::PbrtTexture;
|
||||
use thiserror::Error;
|
||||
|
||||
#[macro_use]
|
||||
mod tokenizer;
|
||||
|
|
@ -43,6 +40,7 @@ impl Lexer {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
enum CameraType {
|
||||
Orthographic {
|
||||
frame_aspect_ratio: Option<Float>,
|
||||
|
|
@ -60,6 +58,7 @@ enum CameraType {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct PbrtCamera {
|
||||
camera_type: CameraType,
|
||||
shutter_open: Float,
|
||||
|
|
@ -465,8 +464,8 @@ fn parse_transform(input: &mut Tokenizer) -> Result<AffineTransform> {
|
|||
|
||||
let mut v = [0.0; 16];
|
||||
|
||||
for i in 0..16 {
|
||||
v[i] = input
|
||||
for i in &mut v {
|
||||
*i = input
|
||||
.next()
|
||||
.ok_or(miette!("value expected"))??
|
||||
.parse::<Float>()
|
||||
|
|
@ -618,7 +617,8 @@ impl Pbrt {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct PbrtWorldSettings {
|
||||
#[allow(dead_code)]
|
||||
pub struct PbrtWorldSettings {
|
||||
camera: PbrtCamera,
|
||||
camera_ctm: AffineTransform,
|
||||
}
|
||||
|
|
@ -747,7 +747,7 @@ fn inner_parse_pbrt(path: impl AsRef<Path> + std::fmt::Debug) -> Result<Pbrt> {
|
|||
match p {
|
||||
Statement::AttributeBegin => context.push(),
|
||||
Statement::AttributeEnd => {
|
||||
context.pop();
|
||||
context.pop()?;
|
||||
}
|
||||
Statement::Include(_) => unreachable!(),
|
||||
Statement::ConcatTransform(affine_transform) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use ray_tracing_core::color::Color;
|
|||
|
||||
use crate::{
|
||||
either::Either,
|
||||
texture::{Pbrt_2d_float_texture, Pbrt_2d_spectrum_texture, parse_rgb},
|
||||
texture::{Pbrt2dFloatTexture, Pbrt2dSpectrumTexture, parse_rgb},
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
|
@ -24,40 +24,45 @@ pub fn parse_make_named_material(
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct PbrtCoatedDiffuseMaterial {
|
||||
albedo: Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>,
|
||||
g: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
albedo: Either<Color, Arc<dyn Pbrt2dSpectrumTexture>>,
|
||||
g: Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
maxdepth: usize,
|
||||
nsamples: usize,
|
||||
thickness: Float,
|
||||
roughness: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
uroughness: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
vroughness: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
reflectance: Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>,
|
||||
roughness: Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
uroughness: Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
vroughness: Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
reflectance: Either<Color, Arc<dyn Pbrt2dSpectrumTexture>>,
|
||||
#[allow(clippy::type_complexity)]
|
||||
eta: Either<
|
||||
Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>,
|
||||
Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
Either<Color, Arc<dyn Pbrt2dSpectrumTexture>>,
|
||||
>,
|
||||
}
|
||||
|
||||
impl PbrtMaterial for PbrtCoatedDiffuseMaterial {}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct PbrtDielectricMaterial {
|
||||
#[allow(clippy::type_complexity)]
|
||||
eta: Either<
|
||||
Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>,
|
||||
Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
Either<Color, Arc<dyn Pbrt2dSpectrumTexture>>,
|
||||
>,
|
||||
roughness: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
uroughness: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
vroughness: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
roughness: Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
uroughness: Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
vroughness: Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
}
|
||||
|
||||
impl PbrtMaterial for PbrtDielectricMaterial {}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct PbrtDiffuseMaterial {
|
||||
reflectance: Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>,
|
||||
reflectance: Either<Color, Arc<dyn Pbrt2dSpectrumTexture>>,
|
||||
}
|
||||
|
||||
impl PbrtMaterial for PbrtDiffuseMaterial {}
|
||||
|
|
@ -65,7 +70,7 @@ impl PbrtMaterial for PbrtDiffuseMaterial {}
|
|||
fn parse_2d_float_texture(
|
||||
input: &mut Tokenizer,
|
||||
context: &PbrtContext,
|
||||
) -> Result<Arc<dyn Pbrt_2d_float_texture>> {
|
||||
) -> Result<Arc<dyn Pbrt2dFloatTexture>> {
|
||||
let n = input.parse_parameter()?;
|
||||
|
||||
context
|
||||
|
|
@ -77,7 +82,7 @@ fn parse_2d_float_texture(
|
|||
fn parse_2d_spectrum_texture(
|
||||
input: &mut Tokenizer,
|
||||
context: &PbrtContext,
|
||||
) -> Result<Arc<dyn Pbrt_2d_spectrum_texture>> {
|
||||
) -> Result<Arc<dyn Pbrt2dSpectrumTexture>> {
|
||||
let n = input.parse_parameter()?;
|
||||
|
||||
context
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ impl<R: Rng> Scene<R> for PbrtScene {
|
|||
R: 'a;
|
||||
|
||||
fn intersect(
|
||||
&self,
|
||||
&'_ self,
|
||||
ray: ray_tracing_core::prelude::Ray,
|
||||
min: ray_tracing_core::prelude::Float,
|
||||
max: ray_tracing_core::prelude::Float,
|
||||
) -> Option<ray_tracing_core::scene::Intersection<R, Self::Mat<'_>>> {
|
||||
) -> Option<ray_tracing_core::scene::Intersection<'_, R, Self::Mat<'_>>> {
|
||||
let mut i = None;
|
||||
for s in &self.shapes {
|
||||
if let Some(new_i) = s.intersect::<R>(ray, min, max)
|
||||
|
|
@ -40,9 +40,9 @@ impl<R: Rng> Scene<R> for PbrtScene {
|
|||
|
||||
fn sample_light<'b>(
|
||||
&self,
|
||||
w_in: ray_tracing_core::prelude::Dir3,
|
||||
intersection: &ray_tracing_core::scene::Intersection<'_, R, Self::Mat<'b>>,
|
||||
rng: &mut R,
|
||||
_w_in: ray_tracing_core::prelude::Dir3,
|
||||
_intersection: &ray_tracing_core::scene::Intersection<'_, R, Self::Mat<'b>>,
|
||||
_rng: &mut R,
|
||||
) -> Option<ray_tracing_core::scene::LightSample<'_, R>>
|
||||
where
|
||||
Self: 'b,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use ray_tracing_core::{affine_transform::AffineTransform, prelude::*, scene::Int
|
|||
use crate::material::PbrtMaterial;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) struct Shape {
|
||||
pub(crate) ctm: AffineTransform,
|
||||
pub(crate) material: Arc<dyn PbrtMaterial>,
|
||||
|
|
@ -13,6 +14,7 @@ pub(crate) struct Shape {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum ShapeAlpha {
|
||||
None,
|
||||
Value(Float),
|
||||
|
|
@ -20,6 +22,7 @@ pub(crate) enum ShapeAlpha {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum ShapeType {
|
||||
Sphere {
|
||||
radius: Float,
|
||||
|
|
@ -115,7 +118,7 @@ fn bilinear_intersection(
|
|||
.into_iter()
|
||||
.flatten()
|
||||
.filter(|&u| {
|
||||
if 0.0 <= u && u <= 1.0 {
|
||||
if (0.0..=1.0).contains(&u) {
|
||||
return true;
|
||||
}
|
||||
false
|
||||
|
|
@ -146,7 +149,7 @@ fn bilinear_intersection(
|
|||
- ud.x() * deltao.y() * perp.z()
|
||||
- perp.x() * ud.y() * deltao.z();
|
||||
|
||||
if t1 > 0.0 && 0.0 < v1 && v1 <= p2 {
|
||||
if t1 >= min && t1 <= max && 0.0 < v1 && v1 <= p2 {
|
||||
Some((t1 / p2, u, v1 / p2))
|
||||
} else {
|
||||
None
|
||||
|
|
@ -157,11 +160,11 @@ fn bilinear_intersection(
|
|||
|
||||
impl Shape {
|
||||
pub(crate) fn intersect<R: Rng>(
|
||||
&self,
|
||||
&'_ self,
|
||||
ray: Ray,
|
||||
min: Float,
|
||||
max: Float,
|
||||
) -> Option<Intersection<R, &'_ dyn Material<R>>> {
|
||||
) -> Option<Intersection<'_, R, &'_ dyn Material<R>>> {
|
||||
let ray = self.ctm.transform_ray(ray);
|
||||
|
||||
match &self.obj {
|
||||
|
|
@ -220,14 +223,13 @@ impl Shape {
|
|||
}
|
||||
}
|
||||
}
|
||||
ShapeType::TriangleMesh {
|
||||
ShapeType::TriangleMesh { .. } => (),
|
||||
ShapeType::BilinearMesh {
|
||||
indices,
|
||||
p,
|
||||
n,
|
||||
s,
|
||||
uv,
|
||||
} => (),
|
||||
ShapeType::BilinearMesh { indices, p, n, uv } => {
|
||||
n: _,
|
||||
uv: _,
|
||||
} => {
|
||||
if indices.is_empty()
|
||||
&& let Some((t, _u, _v)) =
|
||||
bilinear_intersection(ray, min, max, [p[0], p[1], p[2], p[3]])
|
||||
|
|
@ -235,18 +237,9 @@ impl Shape {
|
|||
return Some(Intersection::new(t, Dir3::up(), None, None, 0.0));
|
||||
}
|
||||
}
|
||||
ShapeType::LoopSubDiv { levels, indices, p } => todo!(),
|
||||
ShapeType::Disk {
|
||||
height,
|
||||
radius,
|
||||
innerradius,
|
||||
phimax,
|
||||
} => (),
|
||||
ShapeType::PlyMesh {
|
||||
filename,
|
||||
displacement,
|
||||
edgelength,
|
||||
} => (),
|
||||
ShapeType::LoopSubDiv { .. } => todo!(),
|
||||
ShapeType::Disk { .. } => (),
|
||||
ShapeType::PlyMesh { .. } => (),
|
||||
}
|
||||
|
||||
None
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use crate::{PbrtContext, either::Either, tokenizer::Tokenizer};
|
||||
use imagemap::{ImageMapEncoding, ImageMapWrap, SpectrumImageMapTexture};
|
||||
use miette::{Result, miette};
|
||||
use ray_tracing_core::{affine_transform::AffineTransform, color::Color, prelude::Float};
|
||||
use ray_tracing_core::{color::Color, prelude::Float};
|
||||
use scale::SpectrumScaleTexture2d;
|
||||
use std::{collections::HashMap, ops::Deref, sync::Arc};
|
||||
|
||||
use crate::{PbrtContext, either::Either, tokenizer::Tokenizer};
|
||||
use std::sync::Arc;
|
||||
|
||||
mod checkerboard;
|
||||
mod imagemap;
|
||||
|
|
@ -12,20 +11,20 @@ mod scale;
|
|||
|
||||
pub trait PbrtTexture: std::fmt::Debug + Send + Sync {
|
||||
fn get_dimension(&self) -> TextureDimension;
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_float_texture>>;
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_spectrum_texture>>;
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dFloatTexture>>;
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dSpectrumTexture>>;
|
||||
}
|
||||
|
||||
pub trait Pbrt_2d_float_texture: std::fmt::Debug + Sync + Send {
|
||||
pub trait Pbrt2dFloatTexture: std::fmt::Debug + Sync + Send {
|
||||
fn get(&self, u: Float, v: Float) -> Float;
|
||||
}
|
||||
|
||||
pub trait Pbrt_2d_spectrum_texture: std::fmt::Debug + Sync + Send {
|
||||
pub trait Pbrt2dSpectrumTexture: std::fmt::Debug + Sync + Send {
|
||||
fn get(&self, u: Float, v: Float) -> Color;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum TextureDimension {
|
||||
pub enum TextureDimension {
|
||||
D2,
|
||||
D3,
|
||||
}
|
||||
|
|
@ -57,6 +56,7 @@ impl TextureMapping {
|
|||
}
|
||||
|
||||
pub fn parse_spectrum(input: &mut Tokenizer) -> Result<Color> {
|
||||
let _ = input;
|
||||
todo!()
|
||||
}
|
||||
|
||||
|
|
@ -71,8 +71,67 @@ fn parse_float_texture(
|
|||
) -> Result<Arc<dyn PbrtTexture>> {
|
||||
let texture_class: String = input.parse_next()?;
|
||||
|
||||
dbg!(texture_class);
|
||||
todo!()
|
||||
match texture_class.as_str() {
|
||||
"\"checkerboard\"" => {
|
||||
let t = parse_dict!(input =>
|
||||
mapping, TextureMapping, TextureMapping::UV;
|
||||
uscale, Float, 1.0;
|
||||
vscale, Float, 1.0;
|
||||
udelta, Float, 0.0;
|
||||
vdelta, Float, 0.0;
|
||||
dimension, TextureDimension, TextureDimension::D2;
|
||||
tex1, Either<Float, String>, Either::A(1.0);
|
||||
tex2, Either<Float, String>, Either::A(0.0)
|
||||
=>
|
||||
mapping, "\"string mapping\"", TextureMapping::new(input.parse_parameter()?)?;
|
||||
uscale, "\"float uscale\"", input.parse_parameter()?;
|
||||
vscale, "\"float vscale\"", input.parse_parameter()?;
|
||||
udelta, "\"float udelta\"", input.parse_parameter()?;
|
||||
vdelta, "\"float vdelta\"", input.parse_parameter()?;
|
||||
dimension, "\"integer dimension\"", TextureDimension::new(input.parse_parameter()?)?;
|
||||
tex1, "\"float tex1\"", Either::A(input.parse_parameter()?);
|
||||
tex1, "\"texture tex1\"", Either::B(input.parse_parameter()?);
|
||||
tex2, "\"float tex2\"", Either::A(input.parse_parameter()?);
|
||||
tex2, "\"texture tex2\"", Either::B(input.parse_parameter()?)
|
||||
|
||||
);
|
||||
|
||||
let mapping = UVMapping::new(t.mapping, t.uscale, t.vscale, t.udelta, t.vdelta);
|
||||
|
||||
match t.dimension {
|
||||
TextureDimension::D2 => Ok(Arc::new(checkerboard::FloatCheckerboardTexture2d {
|
||||
mapping,
|
||||
tex: [
|
||||
t.tex1
|
||||
.map_b(|name| {
|
||||
Arc::clone(
|
||||
context
|
||||
.get_texture(&name)
|
||||
.ok_or_else(|| miette!("unable to find texture"))?,
|
||||
)
|
||||
.get_2d_float_texture()
|
||||
})
|
||||
.transpose_b()?,
|
||||
t.tex2
|
||||
.map_b(|name| {
|
||||
Arc::clone(
|
||||
context
|
||||
.get_texture(&name)
|
||||
.ok_or_else(|| miette!("unable to find texture"))?,
|
||||
)
|
||||
.get_2d_float_texture()
|
||||
})
|
||||
.transpose_b()?,
|
||||
],
|
||||
})),
|
||||
TextureDimension::D3 => {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ => Err(miette!("unknown error {texture_class}")),
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_spectrum_texture(
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use super::*;
|
|||
#[derive(Debug)]
|
||||
pub(super) struct FloatCheckerboardTexture2d {
|
||||
pub(super) mapping: UVMapping,
|
||||
pub(super) tex: [Either<Float, Arc<dyn Pbrt_2d_float_texture>>; 2],
|
||||
pub(super) tex: [Either<Float, Arc<dyn Pbrt2dFloatTexture>>; 2],
|
||||
}
|
||||
|
||||
impl Pbrt_2d_float_texture for FloatCheckerboardTexture2d {
|
||||
impl Pbrt2dFloatTexture for FloatCheckerboardTexture2d {
|
||||
fn get(&self, u: Float, v: Float) -> Float {
|
||||
let (u, v) = self.mapping.map(u, v);
|
||||
|
||||
|
|
@ -28,11 +28,11 @@ impl Pbrt_2d_float_texture for FloatCheckerboardTexture2d {
|
|||
}
|
||||
|
||||
impl PbrtTexture for FloatCheckerboardTexture2d {
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_float_texture>> {
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dFloatTexture>> {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_spectrum_texture>> {
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dSpectrumTexture>> {
|
||||
Err(miette!("Unable to use this texture as a spectrum texture"))
|
||||
}
|
||||
|
||||
|
|
@ -43,10 +43,10 @@ impl PbrtTexture for FloatCheckerboardTexture2d {
|
|||
#[derive(Debug)]
|
||||
pub(super) struct SpectrumCheckerboardTexture2d {
|
||||
pub(super) mapping: UVMapping,
|
||||
pub(super) tex: [Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>; 2],
|
||||
pub(super) tex: [Either<Color, Arc<dyn Pbrt2dSpectrumTexture>>; 2],
|
||||
}
|
||||
|
||||
impl Pbrt_2d_spectrum_texture for SpectrumCheckerboardTexture2d {
|
||||
impl Pbrt2dSpectrumTexture for SpectrumCheckerboardTexture2d {
|
||||
fn get(&self, u: Float, v: Float) -> Color {
|
||||
let (u, v) = self.mapping.map(u, v);
|
||||
|
||||
|
|
@ -68,11 +68,11 @@ impl Pbrt_2d_spectrum_texture for SpectrumCheckerboardTexture2d {
|
|||
}
|
||||
|
||||
impl PbrtTexture for SpectrumCheckerboardTexture2d {
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_float_texture>> {
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dFloatTexture>> {
|
||||
Err(miette!("Unable to use this texture as a float texture"))
|
||||
}
|
||||
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_spectrum_texture>> {
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dSpectrumTexture>> {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ impl ImageMapWrap {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub(super) enum ImageMapEncoding {
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
SRGB,
|
||||
Linear,
|
||||
Gamma(Float),
|
||||
|
|
@ -118,22 +119,23 @@ impl SpectrumImageMapTexture {
|
|||
}
|
||||
}
|
||||
|
||||
impl Pbrt_2d_spectrum_texture for SpectrumImageMapTexture {
|
||||
impl Pbrt2dSpectrumTexture for SpectrumImageMapTexture {
|
||||
fn get(&self, u: Float, v: Float) -> Color {
|
||||
let (u, v) = self.mapping.map(u, v);
|
||||
|
||||
let (w, h) = self.image.dimensions();
|
||||
|
||||
dbg!(u, v, w, h);
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PbrtTexture for SpectrumImageMapTexture {
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_float_texture>> {
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dFloatTexture>> {
|
||||
Err(miette!("Unable to use this texture as a float texture"))
|
||||
}
|
||||
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_spectrum_texture>> {
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dSpectrumTexture>> {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use super::*;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct SpectrumScaleTexture2d {
|
||||
pub(super) tex: Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>,
|
||||
pub(super) scale: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
|
||||
pub(super) tex: Either<Color, Arc<dyn Pbrt2dSpectrumTexture>>,
|
||||
pub(super) scale: Either<Float, Arc<dyn Pbrt2dFloatTexture>>,
|
||||
}
|
||||
|
||||
impl PbrtTexture for SpectrumScaleTexture2d {
|
||||
|
|
@ -11,16 +11,16 @@ impl PbrtTexture for SpectrumScaleTexture2d {
|
|||
TextureDimension::D2
|
||||
}
|
||||
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_float_texture>> {
|
||||
fn get_2d_float_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dFloatTexture>> {
|
||||
Err(miette!("Unable to convert to float texture"))
|
||||
}
|
||||
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt_2d_spectrum_texture>> {
|
||||
fn get_2d_spectrum_texture(self: Arc<Self>) -> Result<Arc<dyn Pbrt2dSpectrumTexture>> {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Pbrt_2d_spectrum_texture for SpectrumScaleTexture2d {
|
||||
impl Pbrt2dSpectrumTexture for SpectrumScaleTexture2d {
|
||||
fn get(&self, u: Float, v: Float) -> Color {
|
||||
let x = match &self.tex {
|
||||
Either::A(x) => *x,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
use crate::{
|
||||
BytesToChar, PbrtContext, either::Either, error::SourceFile, texture::Pbrt_2d_float_texture,
|
||||
};
|
||||
use const_format::concatcp;
|
||||
use miette::{Diagnostic, Error, IntoDiagnostic, Report, Result, SourceSpan};
|
||||
use ray_tracing_core::prelude::Float;
|
||||
use crate::{BytesToChar, error::SourceFile};
|
||||
use miette::{Diagnostic, IntoDiagnostic, Report, Result, SourceSpan};
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufReader, Bytes, Read},
|
||||
iter::Peekable,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
@ -32,10 +27,6 @@ impl Tokenizer {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_path(&self) -> &Path {
|
||||
&self.path
|
||||
}
|
||||
|
||||
pub fn get_base_path(&self) -> &Path {
|
||||
&self.base_path
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
use std::cell::OnceCell;
|
||||
|
||||
use super::ExampleScene;
|
||||
use crate::{
|
||||
examples::ExampleSceneEnum,
|
||||
triangle_bvh::{BVHMaterial, Triangle, TriangleBVH},
|
||||
};
|
||||
|
||||
use super::ExampleScene;
|
||||
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*};
|
||||
use ray_tracing_material::{diffuse::DiffuseMaterial, mirror::Mirror};
|
||||
use std::cell::OnceCell;
|
||||
|
||||
pub struct BasicCornell<R: Rng> {
|
||||
scene: OnceCell<TriangleBVH<R>>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rand::Rng;
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*};
|
||||
use ray_tracing_material::{diffuse::DiffuseMaterial, mirror::Mirror};
|
||||
use std::cell::OnceCell;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
examples::ExampleSceneEnum,
|
||||
triangle_bvh::{BVHMaterial, Triangle, TriangleBVH},
|
||||
};
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*};
|
||||
use ray_tracing_material::{
|
||||
microfacet::{BeckmannDistribution, Microfacet},
|
||||
mirror::Mirror,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
use ray_tracing_core::{prelude::*, scene::Scene};
|
||||
use ray_tracing_material::iridescent::Iridescent;
|
||||
use ray_tracing_material::microfacet::{BeckmannDistribution, Microfacet};
|
||||
use ray_tracing_material::mirror::Mirror;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::acceleration_structure::triangle_bvh::TriangleBVH;
|
||||
use crate::acceleration_structure::AccelerationStructureScene;
|
||||
use crate::basic_scene::BasicScene;
|
||||
use crate::acceleration_structure::{triangle_bvh::TriangleBVH, AccelerationStructureScene};
|
||||
use ray_tracing_core::prelude::*;
|
||||
use ray_tracing_material::{
|
||||
iridescent::Iridescent,
|
||||
microfacet::{BeckmannDistribution, Microfacet},
|
||||
mirror::Mirror,
|
||||
};
|
||||
use std::{collections::HashMap, fmt::Debug, sync::Arc};
|
||||
|
||||
pub enum ExampleSceneEnum<R: Rng> {
|
||||
AccelerationStructureScene(AccelerationStructureScene<TriangleBVH<u32>, R>),
|
||||
TriangleBVH(crate::triangle_bvh::TriangleBVH<R>),
|
||||
BasicScene(crate::basic_scene::BasicScene<Arc<dyn Material<R>>>),
|
||||
}
|
||||
|
||||
pub trait ExampleScene<R: Rng> {
|
||||
|
|
@ -59,8 +58,8 @@ pub fn example_scenes<R: Rng + Debug + 'static>() -> HashMap<&'static str, Box<d
|
|||
map.insert("mis_test", Box::new(mis_test::MISTest::new()));
|
||||
|
||||
// let material = Iridescent::new(250.0, 250.0, 1.0, 1.3, 20);
|
||||
// let material = Iridescent::new(0.9 * 988.0, 0.1 * 988.0, 1.0, 1.5, 20);
|
||||
// map.insert("sphere", Box::new(sphere::SphereScene::new(material)));
|
||||
let material = Iridescent::new(0.9 * 988.0, 0.1 * 988.0, 1.0, 1.5, 20);
|
||||
map.insert("sphere", Box::new(sphere::SphereScene::new(material)));
|
||||
|
||||
map.insert(
|
||||
"presentation",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use ray_tracing_core::{
|
|||
color::Color,
|
||||
light::AreaLight,
|
||||
math::{Dir3, Pos3},
|
||||
prelude::{Float, Material},
|
||||
prelude::Float,
|
||||
};
|
||||
use ray_tracing_material::{iridescent::Iridescent, oren_nayar::OrenNayar};
|
||||
use std::cell::OnceCell;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
use super::ExampleScene;
|
||||
use crate::{basic_scene::BasicScene, examples::ExampleSceneEnum};
|
||||
use ray_tracing_core::prelude::*;
|
||||
use std::cell::{Cell, OnceCell};
|
||||
use std::{
|
||||
cell::{Cell, OnceCell},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub struct SphereScene<M> {
|
||||
scene: OnceCell<BasicScene<M>>,
|
||||
pub struct SphereScene<R: Rng, M> {
|
||||
scene: OnceCell<BasicScene<Arc<dyn Material<R>>>>,
|
||||
material: Cell<Option<M>>,
|
||||
}
|
||||
|
||||
impl<M> SphereScene<M> {
|
||||
impl<R: Rng, M> SphereScene<R, M> {
|
||||
pub fn new(material: M) -> Self {
|
||||
Self {
|
||||
scene: OnceCell::new(),
|
||||
|
|
@ -17,33 +20,33 @@ impl<M> SphereScene<M> {
|
|||
}
|
||||
}
|
||||
|
||||
// impl<R, M> ExampleScene<R> for SphereScene<M>
|
||||
// where
|
||||
// R: Rng + 'static,
|
||||
// M: Material<R> + Clone + 'static,
|
||||
// M: Send + Sync,
|
||||
// {
|
||||
// fn get_scene(&self) -> ExampleSceneEnum<R> {
|
||||
// let s = self
|
||||
// .scene
|
||||
// .get_or_init(|| BasicScene::new(self.material.take().unwrap()));
|
||||
impl<R, M> ExampleScene<R> for SphereScene<R, M>
|
||||
where
|
||||
R: Rng + 'static,
|
||||
M: Material<R> + Clone + 'static,
|
||||
M: Send + Sync,
|
||||
{
|
||||
fn get_scene(&self) -> ExampleSceneEnum<R> {
|
||||
let s = self
|
||||
.scene
|
||||
.get_or_init(|| BasicScene::new(Arc::new(self.material.take().unwrap())));
|
||||
|
||||
// ExampleSceneEnum::BasicScene(s.clone())
|
||||
// }
|
||||
ExampleSceneEnum::BasicScene(s.clone())
|
||||
}
|
||||
|
||||
// fn get_camera_pos(&self) -> Pos3 {
|
||||
// Pos3::new(5.0, 1.0, 0.0)
|
||||
// }
|
||||
fn get_camera_pos(&self) -> Pos3 {
|
||||
Pos3::new(5.0, 1.0, 0.0)
|
||||
}
|
||||
|
||||
// fn get_camera_look_at(&self) -> Pos3 {
|
||||
// Pos3::new(0.0, 0.0, 0.0)
|
||||
// }
|
||||
fn get_camera_look_at(&self) -> Pos3 {
|
||||
Pos3::new(0.0, 0.0, 0.0)
|
||||
}
|
||||
|
||||
// fn get_camera_up(&self) -> Dir3 {
|
||||
// Dir3::up()
|
||||
// }
|
||||
fn get_camera_up(&self) -> Dir3 {
|
||||
Dir3::up()
|
||||
}
|
||||
|
||||
// fn get_horizontal_fov(&self) -> Float {
|
||||
// Float::to_radians(90.0)
|
||||
// }
|
||||
// }
|
||||
fn get_horizontal_fov(&self) -> Float {
|
||||
Float::to_radians(90.0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
use super::ExampleScene;
|
||||
use crate::{
|
||||
examples::ExampleSceneEnum,
|
||||
parse_obj::ObjData,
|
||||
triangle_bvh::{BVHMaterial, Triangle, TriangleBVH},
|
||||
};
|
||||
use rand::Rng;
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*};
|
||||
use ray_tracing_material::oren_nayar::OrenNayar;
|
||||
use std::cell::{Cell, OnceCell};
|
||||
|
||||
use super::ExampleScene;
|
||||
|
||||
pub struct StanfordDragon<R: Rng, M: Material<R>> {
|
||||
scene: OnceCell<TriangleBVH<R>>,
|
||||
material: Cell<Option<M>>,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,4 @@
|
|||
use rand::Rng;
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*, scene::Scene};
|
||||
use ray_tracing_material::{
|
||||
microfacet::{BeckmannDistribution, Microfacet},
|
||||
oren_nayar::OrenNayar,
|
||||
};
|
||||
use std::cell::OnceCell;
|
||||
|
||||
use super::ExampleScene;
|
||||
use crate::{
|
||||
acceleration_structure::{
|
||||
triangle_bvh::{Triangle, TriangleBVH},
|
||||
|
|
@ -14,8 +7,13 @@ use crate::{
|
|||
examples::ExampleSceneEnum,
|
||||
parse_obj::ObjData,
|
||||
};
|
||||
|
||||
use super::ExampleScene;
|
||||
use rand::Rng;
|
||||
use ray_tracing_core::{light::AreaLight, prelude::*};
|
||||
use ray_tracing_material::{
|
||||
microfacet::{BeckmannDistribution, Microfacet},
|
||||
oren_nayar::OrenNayar,
|
||||
};
|
||||
use std::cell::OnceCell;
|
||||
|
||||
pub struct StanfordDragon<R: Rng> {
|
||||
scene: OnceCell<AccelerationStructureScene<TriangleBVH<u32>, R>>,
|
||||
|
|
|
|||
|
|
@ -69,19 +69,19 @@ fn parse_float(i: &str) -> IResult<&str, Float> {
|
|||
double(i).map(|(i, f)| (i, f as Float))
|
||||
}
|
||||
|
||||
fn parse_vertex(i: &str) -> IResult<&str, Line> {
|
||||
fn parse_vertex(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
|
||||
let mut v = [0.0; 3];
|
||||
let (i, _) = fill(parse_float, &mut v)(i)?;
|
||||
Ok((i, Line::Vertex(Pos3::new(v[0], v[1], v[2]))))
|
||||
}
|
||||
|
||||
fn parse_normal(i: &str) -> IResult<&str, Line> {
|
||||
fn parse_normal(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
|
||||
let mut v = [0.0; 3];
|
||||
let (i, _) = fill(parse_float, &mut v)(i)?;
|
||||
Ok((i, Line::Normal(Dir3::new(v[0], v[1], v[2]))))
|
||||
}
|
||||
|
||||
fn parse_texcoord(i: &str) -> IResult<&str, Line> {
|
||||
fn parse_texcoord(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
|
||||
let mut v = [0.0; 2];
|
||||
let (i, _) = fill(parse_float, &mut v)(i)?;
|
||||
Ok((i, Line::Texcoord(v)))
|
||||
|
|
@ -125,7 +125,7 @@ fn face_vertex_normal_tex(i: &str) -> IResult<&str, (i32, i32, i32)> {
|
|||
Ok((i, (v, t, n)))
|
||||
}
|
||||
|
||||
fn parse_face(i: &str) -> IResult<&str, Line> {
|
||||
fn parse_face(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
|
||||
if let Ok((i, s)) = many1(face_vertex_normal_tex)(i) {
|
||||
if s.len() >= 3 {
|
||||
Ok((
|
||||
|
|
@ -198,17 +198,17 @@ fn parse_face(i: &str) -> IResult<&str, Line> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_mtllib(i: &str) -> IResult<&str, Line> {
|
||||
fn parse_mtllib(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
|
||||
let (i, s) = take_till(|c| c == ' ')(i)?;
|
||||
Ok((i, Line::Mtllib(s)))
|
||||
}
|
||||
|
||||
fn parse_mtl(i: &str) -> IResult<&str, Line> {
|
||||
fn parse_mtl(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
|
||||
let (i, s) = take_till(|c| c == ' ')(i)?;
|
||||
Ok((i, Line::Material(s)))
|
||||
}
|
||||
|
||||
fn parse_line(i: &str) -> IResult<&str, Line> {
|
||||
fn parse_line(i: &'_ str) -> IResult<&'_ str, Line<'_>> {
|
||||
let (i, ident) = parse_identifier(i)?;
|
||||
let (i, _) = remove_whitespace(i)?;
|
||||
match ident {
|
||||
|
|
@ -250,12 +250,12 @@ enum MaterialsLine<'a> {
|
|||
Empty,
|
||||
}
|
||||
|
||||
fn parse_new_material(i: &str) -> IResult<&str, MaterialsLine> {
|
||||
fn parse_new_material(i: &'_ str) -> IResult<&'_ str, MaterialsLine<'_>> {
|
||||
let (i, ident) = take_till1(|c| c == ' ')(i)?;
|
||||
Ok((i, MaterialsLine::Material(ident)))
|
||||
}
|
||||
|
||||
fn parse_line_material(i: &str) -> IResult<&str, MaterialsLine> {
|
||||
fn parse_line_material(i: &'_ str) -> IResult<&'_ str, MaterialsLine<'_>> {
|
||||
let (i, ident) = parse_identifier(i)?;
|
||||
let (i, _) = remove_whitespace(i)?;
|
||||
match ident {
|
||||
|
|
|
|||
|
|
@ -36,14 +36,13 @@ struct Args {
|
|||
}
|
||||
|
||||
fn render_image<
|
||||
'sc,
|
||||
R: ClassicalRenderer<SmallRng, S, C> + Sync,
|
||||
S: Scene<SmallRng> + Sync,
|
||||
C: Camera<SmallRng> + Sync,
|
||||
>(
|
||||
name: impl AsRef<str>,
|
||||
renderer: &R,
|
||||
scene: &'sc S,
|
||||
scene: &S,
|
||||
camera: &C,
|
||||
samples_per_pixel: usize,
|
||||
tev: &mut TevClient,
|
||||
|
|
@ -109,7 +108,7 @@ fn render_image<
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn choose_renderer<'sc, S, C>(args: &Args, scene: &str, s: &'sc S, c: &C, tev: &mut TevClient)
|
||||
fn choose_renderer<S, C>(args: &Args, scene: &str, s: &S, c: &C, tev: &mut TevClient)
|
||||
where
|
||||
S: Scene<SmallRng> + Sync,
|
||||
C: Camera<SmallRng> + Sync,
|
||||
|
|
@ -216,6 +215,9 @@ fn main() {
|
|||
ray_tracing_scene::examples::ExampleSceneEnum::TriangleBVH(s) => {
|
||||
choose_renderer(&args, scene, s, &c, &mut client);
|
||||
}
|
||||
ray_tracing_scene::examples::ExampleSceneEnum::BasicScene(s) => {
|
||||
choose_renderer(&args, scene, s, &c, &mut client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue