Fixing some import errors
This commit is contained in:
parent
a14960562c
commit
384a0019d8
10 changed files with 51 additions and 42 deletions
|
|
@ -31,12 +31,17 @@ const SWATCH_REFLECTANCES: LazyLock<[Spectrum; N_SWATCH_REFLECTANCES]> = LazyLoc
|
|||
})
|
||||
});
|
||||
|
||||
pub fn get_swatches() -> Arc<[Spectrum; N_SWATCH_REFLECTANCES]> {
|
||||
Arc::new(*SWATCH_REFLECTANCES)
|
||||
}
|
||||
|
||||
pub trait CreatePixelSensor: Sized {
|
||||
fn create(
|
||||
params: &ParameterDictionary,
|
||||
output_colorspace: Arc<RGBColorSpace>,
|
||||
exposure_time: Float,
|
||||
loc: &FileLoc,
|
||||
arena: &Arena,
|
||||
) -> Result<Self>;
|
||||
|
||||
fn new(
|
||||
|
|
@ -46,12 +51,14 @@ pub trait CreatePixelSensor: Sized {
|
|||
output_colorspace: Arc<RGBColorSpace>,
|
||||
sensor_illum: Option<&Spectrum>,
|
||||
imaging_ratio: Float,
|
||||
arena: &Arena,
|
||||
) -> Self;
|
||||
|
||||
fn new_with_white_balance(
|
||||
output_colorspace: &RGBColorSpace,
|
||||
sensor_illum: Option<&Spectrum>,
|
||||
imaging_ratio: Float,
|
||||
arena: &Arena,
|
||||
) -> Self;
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +68,7 @@ impl CreatePixelSensor for PixelSensor {
|
|||
output_colorspace: Arc<RGBColorSpace>,
|
||||
exposure_time: Float,
|
||||
loc: &FileLoc,
|
||||
arena: &Arena,
|
||||
) -> Result<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
@ -90,6 +98,7 @@ impl CreatePixelSensor for PixelSensor {
|
|||
output_colorspace.as_ref(),
|
||||
sensor_illum.as_deref(),
|
||||
imaging_ratio,
|
||||
arena
|
||||
));
|
||||
} else {
|
||||
let r_opt = get_named_spectrum(&format!("{}_r", sensor_name));
|
||||
|
|
@ -118,6 +127,7 @@ impl CreatePixelSensor for PixelSensor {
|
|||
.expect("Sensor must have illuminant"),
|
||||
),
|
||||
imaging_ratio,
|
||||
arena
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -129,6 +139,7 @@ impl CreatePixelSensor for PixelSensor {
|
|||
output_colorspace: Arc<RGBColorSpace>,
|
||||
sensor_illum: Option<&Spectrum>,
|
||||
imaging_ratio: Float,
|
||||
arena: &Arena,
|
||||
) -> Self {
|
||||
let illum: &Spectrum = match sensor_illum {
|
||||
Some(arc_illum) => arc_illum,
|
||||
|
|
@ -138,17 +149,20 @@ impl CreatePixelSensor for PixelSensor {
|
|||
let r_bar = DenselySampledSpectrum::from_spectrum(r);
|
||||
let g_bar = DenselySampledSpectrum::from_spectrum(g);
|
||||
let b_bar = DenselySampledSpectrum::from_spectrum(b);
|
||||
let r_ptr = arena.alloc(r_bar);
|
||||
let g_ptr = arena.alloc(r_bar);
|
||||
let v_ptr = arena.alloc(r_bar);
|
||||
let mut rgb_camera = [[0.; 3]; N_SWATCH_REFLECTANCES];
|
||||
|
||||
let swatches = Self::get_swatches();
|
||||
let swatches = get_swatches();
|
||||
|
||||
for i in 0..N_SWATCH_REFLECTANCES {
|
||||
let rgb = PixelSensor::project_reflectance::<RGB>(
|
||||
&swatches[i],
|
||||
illum,
|
||||
&Spectrum::Dense(r_bar),
|
||||
&Spectrum::Dense(g_bar),
|
||||
&Spectrum::Dense(b_bar),
|
||||
&Spectrum::Dense(r_ptr),
|
||||
&Spectrum::Dense(g_ptr),
|
||||
&Spectrum::Dense(b_ptr),
|
||||
);
|
||||
for c in 0..3 {
|
||||
rgb_camera[i][c] = rgb[c];
|
||||
|
|
@ -157,7 +171,7 @@ impl CreatePixelSensor for PixelSensor {
|
|||
|
||||
let mut xyz_output = [[0.; 3]; N_SWATCH_REFLECTANCES];
|
||||
let spectra = get_spectra_context();
|
||||
let sensor_white_g = illum.inner_product(&Spectrum::Dense(g_bar));
|
||||
let sensor_white_g = illum.inner_product(&Spectrum::Dense(g_ptr));
|
||||
let sensor_white_y = illum.inner_product(&Spectrum::Dense(spectra.y));
|
||||
for i in 0..N_SWATCH_REFLECTANCES {
|
||||
let s = swatches[i].clone();
|
||||
|
|
@ -177,9 +191,9 @@ impl CreatePixelSensor for PixelSensor {
|
|||
.expect("Could not convert sensor illuminance to XYZ space");
|
||||
|
||||
PixelSensor {
|
||||
r_bar: r_bar.clone(),
|
||||
g_bar: g_bar.clone(),
|
||||
b_bar: b_bar.clone(),
|
||||
r_bar: r_ptr,
|
||||
g_bar: g_ptr,
|
||||
b_bar: b_ptr,
|
||||
imaging_ratio,
|
||||
xyz_from_sensor_rgb,
|
||||
}
|
||||
|
|
@ -205,17 +219,14 @@ impl CreatePixelSensor for PixelSensor {
|
|||
}
|
||||
|
||||
PixelSensor {
|
||||
r_bar: r_bar.clone(),
|
||||
g_bar: g_bar.clone(),
|
||||
b_bar: b_bar.clone(),
|
||||
r_bar: arena.alloc(r_bar),
|
||||
g_bar: arena.alloc(g_bar),
|
||||
b_bar: arena.alloc(b_bar),
|
||||
xyz_from_sensor_rgb,
|
||||
imaging_ratio,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_swatches() -> Arc<[Spectrum; N_SWATCH_REFLECTANCES]> {
|
||||
Arc::new(*SWATCH_REFLECTANCES)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CreateFilmBase {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use super::{Image, ImageAndMetadata, ImageMetadata};
|
||||
use super::{HostImage, ImageAndMetadata, ImageMetadata};
|
||||
use crate::core::image::{PixelStorage, WrapMode};
|
||||
use crate::utils::error::ImageError;
|
||||
use anyhow::{Context, Result, bail};
|
||||
|
|
@ -22,7 +22,7 @@ pub trait ImageIO {
|
|||
fn to_u8_buffer(&self) -> Vec<u8>;
|
||||
}
|
||||
|
||||
impl ImageIO for Image {
|
||||
impl ImageIO for HostImage {
|
||||
fn read(path: &Path, encoding: Option<ColorEncoding>) -> Result<ImageAndMetadata> {
|
||||
let ext = path
|
||||
.extension()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::core::image::Image;
|
||||
use crate::core::image::HostImage;
|
||||
use crate::core::material::CreateMaterial;
|
||||
use crate::core::texture::SpectrumTexture;
|
||||
use crate::globals::get_options;
|
||||
|
|
@ -18,7 +18,7 @@ use std::sync::Arc;
|
|||
impl CreateMaterial for CoatedDiffuseMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
normal_map: Option<Arc<Image>>,
|
||||
normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
arena: &Arena,
|
||||
|
|
@ -78,7 +78,7 @@ impl CreateMaterial for CoatedDiffuseMaterial {
|
|||
impl CreateMaterial for CoatedConductorMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
normal_map: Option<Arc<Image>>,
|
||||
normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
loc: &FileLoc,
|
||||
arena: &Arena,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::core::image::Image;
|
||||
use crate::core::image::HostImage;
|
||||
use crate::core::material::CreateMaterial;
|
||||
use crate::core::texture::SpectrumTexture;
|
||||
use crate::spectra::get_colorspace_device;
|
||||
|
|
@ -17,7 +17,7 @@ use std::sync::Arc;
|
|||
impl CreateMaterial for HairMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
arena: &Arena,
|
||||
|
|
@ -64,7 +64,7 @@ impl CreateMaterial for HairMaterial {
|
|||
impl CreateMaterial for SubsurfaceMaterial {
|
||||
fn create(
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &Arena,
|
||||
|
|
@ -76,7 +76,7 @@ impl CreateMaterial for SubsurfaceMaterial {
|
|||
impl CreateMaterial for MeasuredMaterial {
|
||||
fn create(
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &Arena,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::core::image::Image;
|
||||
use crate::core::image::HostImage;
|
||||
use crate::core::material::CreateMaterial;
|
||||
// use crate::core::scattering::TrowbridgeReitzDistribution;
|
||||
use crate::utils::TextureParameterDictionary;
|
||||
|
|
@ -10,7 +10,7 @@ use std::sync::Arc;
|
|||
impl CreateMaterial for ConductorMaterial {
|
||||
fn create(
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &std::collections::HashMap<String, shared::core::material::Material>,
|
||||
_loc: &crate::utils::FileLoc,
|
||||
_arena: &crate::Arena,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::Arena;
|
||||
use crate::core::image::Image;
|
||||
use crate::core::image::HostImage;
|
||||
use crate::core::material::CreateMaterial;
|
||||
use crate::utils::{FileLoc, TextureParameterDictionary};
|
||||
use anyhow::Result;
|
||||
|
|
@ -11,7 +11,7 @@ use std::sync::Arc;
|
|||
impl CreateMaterial for DielectricMaterial {
|
||||
fn create(
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &Arena,
|
||||
|
|
@ -23,7 +23,7 @@ impl CreateMaterial for DielectricMaterial {
|
|||
impl CreateMaterial for ThinDielectricMaterial {
|
||||
fn create(
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &Arena,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::Arena;
|
||||
use crate::core::image::Image;
|
||||
use crate::core::image::HostImage;
|
||||
use crate::core::material::CreateMaterial;
|
||||
use crate::utils::{FileLoc, TextureParameterDictionary};
|
||||
use anyhow::Result;
|
||||
|
|
@ -11,7 +11,7 @@ use std::sync::Arc;
|
|||
impl CreateMaterial for DiffuseMaterial {
|
||||
fn create(
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &Arena,
|
||||
|
|
@ -23,7 +23,7 @@ impl CreateMaterial for DiffuseMaterial {
|
|||
impl CreateMaterial for DiffuseTransmissionMaterial {
|
||||
fn create(
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &Arena,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::core::image::Image;
|
||||
use crate::core::image::HostImage;
|
||||
use crate::core::material::CreateMaterial;
|
||||
use crate::utils::{Arena, FileLoc, TextureParameterDictionary};
|
||||
use anyhow::Result;
|
||||
|
|
@ -10,7 +10,7 @@ use std::sync::Arc;
|
|||
impl CreateMaterial for MixMaterial {
|
||||
fn create(
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_normal_map: Option<Arc<HostImage>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &Arena,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::core::image::{Image, ImageIO};
|
||||
use crate::core::shape::{CreateShape, ALL_BILINEAR_MESHES};
|
||||
use crate::core::texture::FloatTexture;
|
||||
use crate::shapes::mesh::BilinearPatchMesh;
|
||||
use crate::utils::sampling::PiecewiseConstant2D;
|
||||
use crate::{Arena, FileLoc, ParameterDictionary};
|
||||
use anyhow::{anyhow, Result};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
use crate::core::shape::{CreateShape, ALL_TRIANGLE_MESHES};
|
||||
use crate::core::texture::FloatTexture;
|
||||
use crate::shapes::mesh::TriangleMesh;
|
||||
use crate::{Arena, FileLoc, ParameterDictionary};
|
||||
use anyhow::{bail, Result};
|
||||
use log::warn;
|
||||
use shared::core::shape::Shape;
|
||||
use shared::shapes::TriangleShape;
|
||||
use shared::shapes::{TriangleMesh, TriangleShape};
|
||||
use shared::{Ptr, Transform};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
|
@ -87,12 +86,12 @@ impl CreateShape for TriangleShape {
|
|||
let host = TriangleMesh::new(
|
||||
&render_from_object,
|
||||
reverse_orientation,
|
||||
vertex_indices,
|
||||
p,
|
||||
n,
|
||||
s,
|
||||
uvs,
|
||||
face_indices,
|
||||
&vertex_indices,
|
||||
&p,
|
||||
&n,
|
||||
&s,
|
||||
&uvs,
|
||||
&face_indices,
|
||||
);
|
||||
|
||||
let host_arc = Arc::new(host);
|
||||
|
|
|
|||
Loading…
Reference in a new issue