Continuing on the quest to fix bugs. Never again
This commit is contained in:
parent
b6b17a8c7e
commit
64a139d108
39 changed files with 174 additions and 230 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use shared::core::{
|
||||
light::Light,
|
||||
material::{self, Material},
|
||||
material::Material,
|
||||
medium::MediumInterface,
|
||||
primitive::{GeometricPrimitive, SimplePrimitive},
|
||||
shape::Shape,
|
||||
|
|
@ -8,8 +8,6 @@ use shared::core::{
|
|||
|
||||
use shared::utils::Ptr;
|
||||
|
||||
use crate::core::texture::FloatTexture;
|
||||
|
||||
pub trait CreateSimplePrimitive {
|
||||
fn new(shape: Ptr<Shape>, material: Ptr<Material>) -> SimplePrimitive {
|
||||
SimplePrimitive { shape, material }
|
||||
|
|
@ -37,4 +35,3 @@ pub trait CreateGeometricPrimitive {
|
|||
}
|
||||
|
||||
impl CreateGeometricPrimitive for GeometricPrimitive {}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::utils::{FileLoc, ParameterDictionary};
|
|||
use anyhow::{Result, anyhow};
|
||||
use shared::core::geometry::Point2i;
|
||||
use shared::core::sampler::{
|
||||
HaltonSampler, IndependentSampler, PaddedSobolSampler, Sampler, SamplerTrait, SobolSampler,
|
||||
HaltonSampler, IndependentSampler, PaddedSobolSampler, Sampler, SobolSampler,
|
||||
StratifiedSampler, ZSobolSampler,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ use crate::utils::{Upload, resolve_filename};
|
|||
use parking_lot::Mutex;
|
||||
use rayon::prelude::*;
|
||||
use shared::core::camera::Camera;
|
||||
use shared::core::color::ColorEncoding;
|
||||
use shared::core::color::LINEAR;
|
||||
use shared::core::film::Film;
|
||||
use shared::core::filter::Filter;
|
||||
|
|
@ -29,7 +28,6 @@ use shared::core::sampler::Sampler;
|
|||
use shared::core::shape::Shape;
|
||||
use shared::core::texture::SpectrumType;
|
||||
use shared::spectra::RGBColorSpace;
|
||||
use shared::textures::FloatConstantTexture;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -161,7 +159,7 @@ impl BasicScene {
|
|||
&camera.base.name,
|
||||
&camera.base.parameters,
|
||||
&camera.camera_transform,
|
||||
medium,
|
||||
medium.unwrap(),
|
||||
camera_film,
|
||||
&camera.base.loc,
|
||||
arena,
|
||||
|
|
@ -291,7 +289,7 @@ impl BasicScene {
|
|||
TextureParameterDictionary::new(texture_clone.base.parameters.into(), None);
|
||||
let texture = SpectrumTexture::create(
|
||||
&texture_clone.base.name,
|
||||
&render_from_texture,
|
||||
render_from_texture,
|
||||
tex_dict,
|
||||
SpectrumType::Albedo,
|
||||
texture_clone.base.loc,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use super::{SceneEntity, TextureSceneEntity};
|
||||
use crate::core::image::Image;
|
||||
use crate::core::light::Light;
|
||||
use crate::core::medium::Medium;
|
||||
use crate::core::texture::{FloatTexture, SpectrumTexture};
|
||||
use crate::utils::parallel::AsyncJob;
|
||||
use shared::core::light::Light;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct TextureState {
|
||||
pub serial_float_textures: Vec<(String, TextureSceneEntity)>,
|
||||
pub serial_spectrum_textures: Vec<(String, TextureSceneEntity)>,
|
||||
|
|
@ -18,7 +18,7 @@ pub struct TextureState {
|
|||
pub n_missing_textures: i32,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct MaterialState {
|
||||
pub named_materials: Vec<(String, SceneEntity)>,
|
||||
pub materials: Vec<SceneEntity>,
|
||||
|
|
@ -26,19 +26,19 @@ pub struct MaterialState {
|
|||
pub normal_maps: HashMap<String, Arc<Image>>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct LightState {
|
||||
pub light_jobs: Vec<AsyncJob<Light>>,
|
||||
pub area_lights: Vec<SceneEntity>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct MediaState {
|
||||
pub jobs: HashMap<String, AsyncJob<Medium>>,
|
||||
pub map: HashMap<String, Arc<Medium>>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct SingletonState<T> {
|
||||
pub result: Option<Arc<T>>,
|
||||
pub job: Option<AsyncJob<T>>,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::core::texture::FloatTexture;
|
||||
use crate::shapes::{BilinearPatchMesh, TriQuadMesh, TriangleMesh};
|
||||
use crate::utils::{Arena, FileLoc, ParameterDictionary, resolve_filename};
|
||||
use shared::core::options::get_options;
|
||||
use crate::shapes::{BilinearPatchMesh, TriangleMesh};
|
||||
use crate::utils::{Arena, FileLoc, ParameterDictionary};
|
||||
use shared::core::shape::*;
|
||||
use shared::shapes::*;
|
||||
// use shared::spectra::*;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
use crate::spectra::cie_y;
|
||||
use crate::spectra::{DenselySampledSpectrumBuffer, cie_y};
|
||||
use crate::utils::containers::InternCache;
|
||||
use parking_lot::Mutex;
|
||||
use shared::Float;
|
||||
use shared::core::spectrum::Spectrum;
|
||||
use shared::spectra::DenselySampledSpectrum;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
pub static SPECTRUM_CACHE: LazyLock<InternCache<DenselySampledSpectrum>> =
|
||||
pub static SPECTRUM_CACHE: LazyLock<InternCache<DenselySampledSpectrumBuffer>> =
|
||||
LazyLock::new(InternCache::new);
|
||||
|
||||
pub static SPECTRUM_FILE_CACHE: LazyLock<Mutex<HashMap<String, Spectrum>>> =
|
||||
LazyLock::new(|| Mutex::new(HashMap::new()));
|
||||
|
||||
pub fn get_spectrum_cache() -> &'static InternCache<DenselySampledSpectrum> {
|
||||
pub fn get_spectrum_cache() -> &'static InternCache<DenselySampledSpectrumBuffer> {
|
||||
&SPECTRUM_CACHE
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,18 +45,21 @@ pub enum FloatTexture {
|
|||
Wrinkled(WrinkledTexture),
|
||||
}
|
||||
|
||||
impl FloatTextureTrait for FloatDotsTexture {
|
||||
fn evaluate(&self, _ctx: &shared::core::texture::TextureEvalContext) -> shared::Float {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl FloatTextureTrait for Arc<FloatTexture> {
|
||||
fn evaluate(&self, ctx: &TextureEvalContext) -> Float {
|
||||
self.as_ref().evaluate(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CreateFloatTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
params: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
arena: &mut Arena,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl FloatTexture {
|
||||
pub fn create(
|
||||
name: &str,
|
||||
|
|
@ -155,16 +158,6 @@ impl SpectrumTextureTrait for Arc<SpectrumTexture> {
|
|||
}
|
||||
}
|
||||
|
||||
impl SpectrumTextureTrait for SpectrumDotsTexture {
|
||||
fn evaluate(
|
||||
&self,
|
||||
_ctx: &shared::core::texture::TextureEvalContext,
|
||||
_lambda: &shared::spectra::SampledWavelengths,
|
||||
) -> shared::spectra::SampledSpectrum {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CreateTextureMapping {
|
||||
fn create(
|
||||
params: &TextureParameterDictionary,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use super::state::PathState;
|
||||
use crate::core::light::Light;
|
||||
use shared::core::geometry::Ray;
|
||||
use shared::core::interaction::{Interaction, InteractionTrait};
|
||||
use shared::core::light::Light;
|
||||
use shared::core::primitive::{Primitive, PrimitiveTrait};
|
||||
use shared::core::shape::ShapeIntersection;
|
||||
use shared::lights::LightSampler;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@ mod state;
|
|||
|
||||
pub use path::PathIntegrator;
|
||||
|
||||
use crate::Arena;
|
||||
use shared::core::film::VisibleSurface;
|
||||
use shared::core::geometry::{Point2i, Ray};
|
||||
use shared::core::sampler::Sampler;
|
||||
use shared::spectra::{SampledSpectrum, SampledWavelengths};
|
||||
|
||||
pub trait IntegratorTrait {
|
||||
fn render(&self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::core::film::FilmTrait;
|
|||
use crate::core::image::{Image, ImageIO, ImageMetadata};
|
||||
use crate::spectra::get_spectra_context;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use rayon::iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
use shared::Float;
|
||||
use shared::core::camera::{Camera, CameraTrait};
|
||||
use shared::core::geometry::{Bounds2i, Point2i, VectorLike};
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ impl CreateDiffuseLight for DiffuseAreaLight {
|
|||
colorspace,
|
||||
shape,
|
||||
alpha: stored_alpha.expect("Could not retrieve texture"),
|
||||
lemit: Ptr::from(&*lemit),
|
||||
lemit: Ptr::from(lemit.device()),
|
||||
two_sided,
|
||||
scale,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ impl CreateDistantLight for DistantLight {
|
|||
let lemit = lookup_spectrum(&le);
|
||||
Self {
|
||||
base,
|
||||
lemit: Ptr::from(&*lemit),
|
||||
lemit: Ptr::from(lemit.device()),
|
||||
scale,
|
||||
scene_center: Point3f::default(),
|
||||
scene_radius: 0.,
|
||||
|
|
|
|||
|
|
@ -43,11 +43,10 @@ impl CreateGoniometricLight for GoniometricLight {
|
|||
);
|
||||
|
||||
let iemit = lookup_spectrum(&le);
|
||||
// let d = image.get_sampling_distribution_uniform();
|
||||
let distrib = PiecewiseConstant2D::from_image(&image);
|
||||
Self {
|
||||
base,
|
||||
iemit: *iemit,
|
||||
iemit: Ptr::from(iemit.device()),
|
||||
scale,
|
||||
image: Ptr::from(image.device_image()),
|
||||
distrib: Ptr::from(&distrib.device),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use anyhow::{Result, anyhow};
|
|||
use rayon::prelude::*;
|
||||
use shared::core::camera::CameraTransform;
|
||||
use shared::core::geometry::{Bounds2f, Frame, Point2f, Point2i, Point3f, VectorLike, cos_theta};
|
||||
use shared::core::image::{PixelFormat, WrapMode};
|
||||
use shared::core::image::{DeviceImage, WrapMode};
|
||||
use shared::core::light::{Light, LightBase, LightType};
|
||||
use shared::core::medium::MediumInterface;
|
||||
use shared::core::spectrum::Spectrum;
|
||||
|
|
@ -20,6 +20,7 @@ use shared::utils::math::{equal_area_sphere_to_square, equal_area_square_to_sphe
|
|||
use shared::utils::sampling::{DevicePiecewiseConstant2D, DeviceWindowedPiecewiseConstant2D};
|
||||
use shared::utils::{Ptr, Transform};
|
||||
use shared::{Float, PI};
|
||||
use shareed::spectra::DenselySampledSpectrum;
|
||||
use std::path::Path;
|
||||
|
||||
pub trait CreateImageInfiniteLight {
|
||||
|
|
@ -206,10 +207,12 @@ fn create_image_light(
|
|||
let (n_u, n_v) = (res.x() as usize, res.y() as usize);
|
||||
|
||||
// Extract luminance data
|
||||
let image_ptr = image.upload(arena);
|
||||
let value = image.clone();
|
||||
let mut data: Vec<Float> = (0..n_v)
|
||||
.flat_map(|v| {
|
||||
(0..n_u).map(move |u| {
|
||||
image
|
||||
&value
|
||||
.get_channels(Point2i::new(u as i32, v as i32))
|
||||
.average()
|
||||
})
|
||||
|
|
@ -233,7 +236,7 @@ fn create_image_light(
|
|||
let light = ImageInfiniteLight::new(
|
||||
render_from_light,
|
||||
scale,
|
||||
image.upload(arena),
|
||||
image_ptr,
|
||||
image_cs.upload(arena),
|
||||
distrib.upload(arena),
|
||||
compensated_distrib.upload(arena),
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ impl CreatePointLight for PointLight {
|
|||
render_from_light,
|
||||
medium_interface,
|
||||
);
|
||||
let i = Ptr::from(&*lookup_spectrum(&le));
|
||||
let iemit = lookup_spectrum(&le);
|
||||
let i = Ptr::from(iemit.device());
|
||||
|
||||
Self { base, scale, i }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use shared::core::spectrum::Spectrum;
|
|||
use shared::lights::ProjectionLight;
|
||||
use shared::spectra::RGBColorSpace;
|
||||
use shared::utils::math::{radians, square};
|
||||
use shared::utils::sampling::DeviceWindowedPiecewiseConstant2D;
|
||||
use shared::utils::{Ptr, Transform};
|
||||
use std::path::Path;
|
||||
|
||||
|
|
@ -48,21 +49,11 @@ impl CreateProjectionLight for ProjectionLight {
|
|||
medium_interface,
|
||||
);
|
||||
|
||||
let res = image.resolution();
|
||||
let aspect = res.x() as Float / res.y() as Float;
|
||||
let screen_bounds = if aspect > 1.0 {
|
||||
Bounds2f::from_points(Point2f::new(-aspect, -1.0), Point2f::new(aspect, 1.0))
|
||||
} else {
|
||||
Bounds2f::from_points(
|
||||
Point2f::new(-1.0, -1.0 / aspect),
|
||||
Point2f::new(1.0, 1.0 / aspect),
|
||||
)
|
||||
};
|
||||
|
||||
let hither = 1e-3;
|
||||
let screen_from_light = Transform::perspective(fov, hither, 1e30).unwrap();
|
||||
let light_from_screen = screen_from_light.inverse();
|
||||
|
||||
let hither = 1e-3;
|
||||
let res = image.resolution();
|
||||
let aspect = res.x() as Float / res.y() as Float;
|
||||
let opposite = (radians(fov) / 2.0).tan();
|
||||
let aspect_ratio = if aspect > 1.0 { aspect } else { 1.0 / aspect };
|
||||
let a = 4.0 * square(opposite) * aspect_ratio;
|
||||
|
|
@ -140,12 +131,27 @@ impl CreateLight for ProjectionLight {
|
|||
let flip = Transform::scale(1., -1., 1.);
|
||||
let render_from_light_flip = render_from_light * flip;
|
||||
|
||||
let hither = 1e-3;
|
||||
let screen_from_light = Transform::perspective(fov, hither, 1e30).unwrap();
|
||||
let light_from_screen = screen_from_light.inverse();
|
||||
|
||||
let dwda = |p: Point2f| {
|
||||
let w =
|
||||
Vector3f::from(light_from_screen.apply_to_point(Point3f::new(p.x(), p.y(), 0.0)));
|
||||
cos_theta(w.normalize()).powi(3)
|
||||
};
|
||||
|
||||
let res = image.resolution();
|
||||
let aspect = res.x() as Float / res.y() as Float;
|
||||
let screen_bounds = if aspect > 1.0 {
|
||||
Bounds2f::from_points(Point2f::new(-aspect, -1.0), Point2f::new(aspect, 1.0))
|
||||
} else {
|
||||
Bounds2f::from_points(
|
||||
Point2f::new(-1.0, -1.0 / aspect),
|
||||
Point2f::new(1.0, 1.0 / aspect),
|
||||
)
|
||||
};
|
||||
|
||||
let d = image.get_sampling_distribution(dwda, screen_bounds);
|
||||
let distrib =
|
||||
PiecewiseConstant2D::new(d.as_slice(), d.x_size() as usize, d.y_size() as usize);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ impl CreateSpotLight for SpotLight {
|
|||
MediumInterface::empty(),
|
||||
);
|
||||
|
||||
let iemit = Ptr::from(&*lookup_spectrum(&le));
|
||||
let i = lookup_spectrum(&le);
|
||||
let iemit = Ptr::from(&i.device());
|
||||
Self {
|
||||
base,
|
||||
iemit,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
use crate::core::image::Image;
|
||||
use crate::core::material::CreateMaterial;
|
||||
use crate::spectra::{get_colorspace_context, get_colorspace_device};
|
||||
use crate::spectra::get_colorspace_device;
|
||||
use crate::utils::{Arena, FileLoc, TextureParameterDictionary, Upload};
|
||||
use shared::bxdfs::HairBxDF;
|
||||
use shared::core::material::Material;
|
||||
use shared::core::spectrum::Spectrum;
|
||||
use shared::core::texture::{SpectrumTexture, SpectrumType};
|
||||
use shared::materials::complex::*;
|
||||
use shared::spectra::RGBUnboundedSpectrum;
|
||||
// use shared::spectra::SampledWavelengths;
|
||||
use shared::textures::SpectrumConstantTexture;
|
||||
// use shared::utils::Ptr;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
use crate::Arena;
|
||||
use crate::core::sampler::CreateSampler;
|
||||
use crate::utils::math::{DigitPermutation, compute_radical_inverse_permutations};
|
||||
use crate::utils::math::compute_radical_inverse_permutations;
|
||||
use crate::utils::{FileLoc, ParameterDictionary};
|
||||
use anyhow::{Result, anyhow};
|
||||
use shared::core::geometry::Point2i;
|
||||
use shared::core::options::get_options;
|
||||
use shared::core::sampler::{HaltonSampler, MAX_HALTON_RESOLUTION, RandomizeStrategy};
|
||||
use shared::utils::Ptr;
|
||||
|
||||
pub trait CreateHaltonSampler {
|
||||
fn new(
|
||||
|
|
@ -23,7 +24,7 @@ impl CreateHaltonSampler for HaltonSampler {
|
|||
randomize: RandomizeStrategy,
|
||||
seed: u64,
|
||||
) -> Self {
|
||||
let (_, _digit_permutations) = compute_radical_inverse_permutations(seed);
|
||||
let (_, digit_permutations) = compute_radical_inverse_permutations(seed);
|
||||
let mut base_scales = [0u64; 2];
|
||||
let mut base_exponents = [0u64; 2];
|
||||
let bases = [2, 3];
|
||||
|
|
@ -55,7 +56,7 @@ impl CreateHaltonSampler for HaltonSampler {
|
|||
Self {
|
||||
samples_per_pixel,
|
||||
randomize,
|
||||
digit_permutations: Ptr::from(&digit_permutations),
|
||||
digit_permutations: digit_permutations.as_ptr().into(),
|
||||
base_scales,
|
||||
base_exponents,
|
||||
mult_inverse,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,3 @@ pub mod halton;
|
|||
pub mod independent;
|
||||
pub mod sobol;
|
||||
pub mod stratified;
|
||||
|
||||
pub use halton::*;
|
||||
pub use independent::*;
|
||||
pub use sobol::*;
|
||||
pub use stratified::*;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,8 @@ pub mod mesh;
|
|||
pub mod sphere;
|
||||
pub mod triangle;
|
||||
|
||||
pub use bilinear::*;
|
||||
pub use curves::*;
|
||||
pub use cylinder::*;
|
||||
pub use disk::*;
|
||||
pub use mesh::*;
|
||||
pub use sphere::*;
|
||||
pub use triangle::*;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::spectra::get_spectra_context;
|
|||
|
||||
use super::DenselySampledSpectrumBuffer;
|
||||
use shared::core::color::{RGB, RGBToSpectrumTable, XYZ};
|
||||
use shared::core::geometry::{Point2f, Vector3f};
|
||||
use shared::core::geometry::Point2f;
|
||||
use shared::core::spectrum::Spectrum;
|
||||
use shared::spectra::RGBColorSpace;
|
||||
use shared::utils::math::SquareMatrix;
|
||||
|
|
@ -30,7 +30,7 @@ impl RGBColorSpaceData {
|
|||
rgb_to_spectrum_table: Ptr<RGBToSpectrumTable>,
|
||||
) -> Self {
|
||||
let stdspec = get_spectra_context();
|
||||
let w_xyz: XYZ = Spectrum::Dense(*illuminant).to_xyz(&stdspec);
|
||||
let w_xyz: XYZ = Spectrum::Dense(illuminant.device()).to_xyz(&stdspec);
|
||||
let w = w_xyz.xy();
|
||||
let r_xyz = XYZ::from_xyy(r, Some(1.0));
|
||||
let g_xyz = XYZ::from_xyy(g, Some(1.0));
|
||||
|
|
@ -51,7 +51,7 @@ impl RGBColorSpaceData {
|
|||
g,
|
||||
b,
|
||||
w,
|
||||
illuminant: *illuminant,
|
||||
illuminant: illuminant.device(),
|
||||
xyz_from_rgb,
|
||||
rgb_from_xyz,
|
||||
rgb_to_spectrum_table,
|
||||
|
|
|
|||
|
|
@ -5,30 +5,31 @@ use shared::spectra::{
|
|||
BlackbodySpectrum, DenselySampledSpectrum, LAMBDA_MAX, LAMBDA_MIN, PiecewiseLinearSpectrum,
|
||||
};
|
||||
use shared::utils::math::square;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DenselySampledSpectrumBuffer {
|
||||
pub device: DenselySampledSpectrum,
|
||||
pub _storage: Vec<Float>,
|
||||
pub lambda_min: i32,
|
||||
pub lambda_max: i32,
|
||||
pub values: Vec<Float>,
|
||||
}
|
||||
|
||||
impl std::ops::Deref for DenselySampledSpectrumBuffer {
|
||||
type Target = DenselySampledSpectrum;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.device
|
||||
impl Hash for DenselySampledSpectrumBuffer {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.lambda_min.hash(state);
|
||||
self.lambda_max.hash(state);
|
||||
for &val in &self.values {
|
||||
val.to_bits().hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DenselySampledSpectrumBuffer {
|
||||
pub fn new(lambda_min: i32, lambda_max: i32, values: Vec<Float>) -> Self {
|
||||
let view = DenselySampledSpectrum {
|
||||
Self {
|
||||
lambda_min,
|
||||
lambda_max,
|
||||
values: values.as_ptr().into(),
|
||||
};
|
||||
Self {
|
||||
device: view,
|
||||
_storage: values,
|
||||
values,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,16 +99,16 @@ impl DenselySampledSpectrumBuffer {
|
|||
Self::from_function(|lambda| temp_pls.evaluate(lambda), LAMBDA_MIN, LAMBDA_MAX)
|
||||
}
|
||||
|
||||
pub fn as_view(&self) -> DenselySampledSpectrum {
|
||||
pub fn device(&self) -> DenselySampledSpectrum {
|
||||
DenselySampledSpectrum {
|
||||
lambda_min: self.device.lambda_min,
|
||||
lambda_max: self.device.lambda_max,
|
||||
values: self._storage.as_ptr().into(),
|
||||
lambda_min: self.lambda_min,
|
||||
lambda_max: self.lambda_max,
|
||||
values: self.values.as_ptr().into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scale(&mut self, s: Float) {
|
||||
for v in &mut self._storage {
|
||||
for v in &mut self.values {
|
||||
*v *= s;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,8 @@ pub mod piecewise;
|
|||
|
||||
pub use dense::DenselySampledSpectrumBuffer;
|
||||
|
||||
fn get_d65_illuminant_buffer() -> DenselySampledSpectrumBuffer {
|
||||
DenselySampledSpectrumBuffer::new(
|
||||
CIE_D65_DATA.device.lambda_min,
|
||||
CIE_D65_DATA.device.lambda_max,
|
||||
CIE_D65_DATA._storage.clone(),
|
||||
)
|
||||
fn get_d65_illuminant_buffer() -> &DenselySampledSpectrumBuffer {
|
||||
&CIE_D65_DATA
|
||||
}
|
||||
|
||||
static CIE_X_DATA: LazyLock<DenselySampledSpectrumBuffer> =
|
||||
|
|
@ -34,27 +30,27 @@ static CIE_D65_DATA: LazyLock<DenselySampledSpectrumBuffer> =
|
|||
LazyLock::new(|| data::create_cie_buffer(&CIE_D65));
|
||||
|
||||
pub fn cie_x() -> Spectrum {
|
||||
Spectrum::Dense(CIE_X_DATA.device)
|
||||
Spectrum::Dense(CIE_X_DATA.device())
|
||||
}
|
||||
|
||||
pub fn cie_y() -> Spectrum {
|
||||
Spectrum::Dense(CIE_Y_DATA.device)
|
||||
Spectrum::Dense(CIE_Y_DATA.device())
|
||||
}
|
||||
|
||||
pub fn cie_z() -> Spectrum {
|
||||
Spectrum::Dense(CIE_Z_DATA.device)
|
||||
Spectrum::Dense(CIE_Z_DATA.device())
|
||||
}
|
||||
|
||||
pub fn cie_d65() -> Spectrum {
|
||||
Spectrum::Dense(CIE_D65_DATA.device)
|
||||
Spectrum::Dense(CIE_D65_DATA.device())
|
||||
}
|
||||
|
||||
pub fn get_spectra_context() -> StandardSpectra {
|
||||
StandardSpectra {
|
||||
x: CIE_X_DATA.device,
|
||||
y: CIE_Y_DATA.device,
|
||||
z: CIE_Z_DATA.device,
|
||||
d65: CIE_D65_DATA.device,
|
||||
x: CIE_X_DATA.device(),
|
||||
y: CIE_Y_DATA.device(),
|
||||
z: CIE_Z_DATA.device(),
|
||||
d65: CIE_D65_DATA.device(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
use crate::core::texture::{CreateSpectrumTexture, FloatTextureTrait, SpectrumTextureTrait};
|
||||
use crate::Arena;
|
||||
use crate::core::texture::{
|
||||
CreateFloatTexture, CreateSpectrumTexture, FloatTextureTrait, SpectrumTexture,
|
||||
SpectrumTextureTrait,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use shared::core::texture::SpectrumType;
|
||||
use shared::{
|
||||
|
|
@ -11,19 +15,12 @@ use crate::{
|
|||
utils::{FileLoc, TextureParameterDictionary},
|
||||
};
|
||||
|
||||
pub trait CreateFloatBilerpTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl CreateFloatBilerpTexture for FloatBilerpTexture {
|
||||
impl CreateFloatTexture for FloatBilerpTexture {
|
||||
fn create(
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_loc: FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<FloatTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use anyhow::Result;
|
||||
use crate::Arena;
|
||||
use shared::{
|
||||
core::texture::SpectrumType,
|
||||
textures::{FloatCheckerboardTexture, SpectrumCheckerboardTexture},
|
||||
|
|
@ -7,25 +8,18 @@ use shared::{
|
|||
|
||||
use crate::{
|
||||
core::texture::{
|
||||
CreateSpectrumTexture, FloatTexture, FloatTextureTrait, SpectrumTexture,
|
||||
SpectrumTextureTrait,
|
||||
CreateFloatTexture, CreateSpectrumTexture, FloatTexture, FloatTextureTrait,
|
||||
SpectrumTexture, SpectrumTextureTrait,
|
||||
},
|
||||
utils::{FileLoc, TextureParameterDictionary},
|
||||
};
|
||||
|
||||
pub trait CreateFloatCheckerboardTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl CreateFloatCheckerboardTexture for FloatCheckerboardTexture {
|
||||
impl CreateFloatTexture for FloatCheckerboardTexture {
|
||||
fn create(
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_loc: FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<FloatTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use anyhow::Result;
|
||||
use crate::Arena;
|
||||
use shared::{
|
||||
core::texture::{SpectrumType, TextureEvalContext},
|
||||
textures::{FloatConstantTexture, SpectrumConstantTexture},
|
||||
|
|
@ -7,25 +8,18 @@ use shared::{
|
|||
|
||||
use crate::{
|
||||
core::texture::{
|
||||
CreateSpectrumTexture, FloatTexture, FloatTextureTrait, SpectrumTextureTrait,
|
||||
SpectrumTextureTrait,
|
||||
CreateFloatTexture, CreateSpectrumTexture, FloatTexture, FloatTextureTrait,
|
||||
SpectrumTextureTrait, SpectrumTextureTrait, SpectrumTexture
|
||||
},
|
||||
utils::{FileLoc, TextureParameterDictionary},
|
||||
};
|
||||
|
||||
pub trait CreateFloatConstantTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl CreateFloatConstantTexture for FloatConstantTexture {
|
||||
impl CreateFloatTexture for FloatConstantTexture {
|
||||
fn create(
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_loc: FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<FloatTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,37 @@
|
|||
use crate::Arena;
|
||||
use anyhow::Result;
|
||||
use shared::{
|
||||
core::texture::SpectrumType,
|
||||
textures::{FloatDotsTexture, SpectrumDotsTexture},
|
||||
utils::Transform,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
core::texture::{CreateSpectrumTexture, FloatTexture, FloatTextureTrait, SpectrumTextureTrait},
|
||||
core::texture::{
|
||||
CreateFloatTexture, CreateSpectrumTexture, FloatTexture, FloatTextureTrait,
|
||||
SpectrumTexture, SpectrumTextureTrait,
|
||||
},
|
||||
utils::{FileLoc, TextureParameterDictionary},
|
||||
};
|
||||
|
||||
pub trait CreateFloatDotsTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl FloatTextureTrait for FloatDotsTexture {
|
||||
fn evaluate(&self, ctx: &shared::core::texture::TextureEvalContext) -> shared::Float {
|
||||
fn evaluate(&self, _ctx: &shared::core::texture::TextureEvalContext) -> shared::Float {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl CreateFloatDotsTexture for FloatDotsTexture {
|
||||
impl CreateFloatTexture for FloatDotsTexture {
|
||||
fn create(
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_loc: FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<FloatTexture> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl SpectrumTextureTrait for SpectrumScaledTexture {
|
||||
impl SpectrumTextureTrait for SpectrumDotsTexture {
|
||||
fn evaluate(
|
||||
&self,
|
||||
_ctx: &shared::core::texture::TextureEvalContext,
|
||||
|
|
|
|||
|
|
@ -1,25 +1,19 @@
|
|||
use anyhow::Result;
|
||||
use crate::Arena;
|
||||
use shared::core::texture::TextureEvalContext;
|
||||
use shared::{textures::FBmTexture, utils::Transform};
|
||||
|
||||
use crate::{
|
||||
core::texture::{FloatTexture, FloatTextureTrait},
|
||||
core::texture::{CreateFloatTexture, FloatTexture, FloatTextureTrait},
|
||||
utils::{FileLoc, TextureParameterDictionary},
|
||||
};
|
||||
|
||||
pub trait CreateFBmTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl CreateFBmTexture for FBmTexture {
|
||||
impl CreateFloatTexture for FBmTexture {
|
||||
fn create(
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_loc: FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<FloatTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
use crate::Arena;
|
||||
use crate::core::texture::{
|
||||
CreateSpectrumTexture, FloatTexture, FloatTextureTrait, SpectrumTexture, SpectrumTextureTrait,
|
||||
CreateFloatTexture, CreateSpectrumTexture, FloatTexture, FloatTextureTrait, SpectrumTexture,
|
||||
SpectrumTextureTrait,
|
||||
};
|
||||
use crate::core::texture::{TexInfo, get_texture_cache};
|
||||
use crate::utils::TextureParameterDictionary;
|
||||
use crate::utils::mipmap::{MIPMap, MIPMapFilterOptions};
|
||||
use crate::utils::{FileLoc, TextureParameterDictionary};
|
||||
use anyhow::Result;
|
||||
use shared::Float;
|
||||
use shared::core::color::ColorEncoding;
|
||||
|
|
@ -16,6 +18,7 @@ use shared::spectra::{
|
|||
RGBAlbedoSpectrum, RGBIlluminantSpectrum, RGBUnboundedSpectrum, SampledSpectrum,
|
||||
SampledWavelengths,
|
||||
};
|
||||
use shared::utils::Transform;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
// use crate::utils::{FileLoc, TextureParameterDictionary};
|
||||
|
|
@ -197,19 +200,12 @@ impl FloatTextureTrait for FloatImageTexture {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait CreateFloatImageTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl CreateFloatImageTexture for FloatImageTexture {
|
||||
impl CreateFloatTexture for FloatImageTexture {
|
||||
fn create(
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_loc: FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<FloatTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::core::texture::{CreateSpectrumTexture, SpectrumTexture, SpectrumTextureTrait};
|
||||
use shared::core::texture::SpectrumType;
|
||||
use shared::textures::MarbleTexture;
|
||||
|
||||
impl SpectrumTextureTrait for MarbleTexture {
|
||||
|
|
@ -13,10 +14,10 @@ impl SpectrumTextureTrait for MarbleTexture {
|
|||
|
||||
impl CreateSpectrumTexture for MarbleTexture {
|
||||
fn create(
|
||||
render_from_texture: shared::utils::Transform,
|
||||
parameters: crate::utils::TextureParameterDictionary,
|
||||
spectrum_type: SpectrumType,
|
||||
loc: crate::utils::FileLoc,
|
||||
_render_from_texture: shared::utils::Transform,
|
||||
_parameters: crate::utils::TextureParameterDictionary,
|
||||
_spectrum_type: SpectrumType,
|
||||
_loc: crate::utils::FileLoc,
|
||||
) -> anyhow::Result<SpectrumTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
use crate::Arena;
|
||||
use crate::core::texture::{
|
||||
CreateSpectrumTexture, FloatTexture, FloatTextureTrait, SpectrumTexture, SpectrumTextureTrait,
|
||||
};
|
||||
use crate::utils::{Arena, FileLoc, TextureParameterDictionary};
|
||||
use crate::utils::{FileLoc, TextureParameterDictionary};
|
||||
use anyhow::Result;
|
||||
use shared::Float;
|
||||
use shared::core::geometry::{Vector3f, VectorLike};
|
||||
use shared::core::texture::TextureEvalContext;
|
||||
use shared::core::texture::{SpectrumType, TextureEvalContext};
|
||||
use shared::spectra::{SampledSpectrum, SampledWavelengths};
|
||||
use shared::utils::Transform;
|
||||
use std::sync::Arc;
|
||||
|
|
@ -97,11 +98,11 @@ pub struct SpectrumMixTexture {
|
|||
|
||||
impl CreateSpectrumTexture for SpectrumMixTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
spectrum_type: SpectrumType,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture> {
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_spectrum_type: SpectrumType,
|
||||
_loc: FileLoc,
|
||||
) -> Result<SpectrumTexture> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
@ -121,10 +122,10 @@ pub struct SpectrumDirectionMixTexture {
|
|||
|
||||
impl CreateSpectrumTexture for SpectrumDirectionMixTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
spectrum_type: SpectrumType,
|
||||
loc: FileLoc,
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_spectrum_type: SpectrumType,
|
||||
_loc: FileLoc,
|
||||
) -> Result<SpectrumTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,6 @@ mod scaled;
|
|||
mod windy;
|
||||
mod wrinkled;
|
||||
|
||||
pub use bilerp::*;
|
||||
pub use checkerboard::*;
|
||||
pub use constant::*;
|
||||
pub use dots::*;
|
||||
pub use fbm::*;
|
||||
pub use image::*;
|
||||
pub use marble::*;
|
||||
pub use mix::*;
|
||||
pub use ptex::*;
|
||||
pub use scaled::*;
|
||||
pub use windy::*;
|
||||
pub use wrinkled::*;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
use crate::Arena;
|
||||
use crate::core::texture::{CreateSpectrumTexture, FloatTexture, SpectrumTexture};
|
||||
use crate::core::texture::{FloatTextureTrait, SpectrumTextureTrait};
|
||||
use crate::utils::{Arena, FileLoc, TextureParameterDictionary};
|
||||
use crate::utils::{FileLoc, TextureParameterDictionary};
|
||||
use anyhow::Result;
|
||||
use shared::Float;
|
||||
use shared::core::texture::TextureEvalContext;
|
||||
use shared::core::texture::{SpectrumType, TextureEvalContext};
|
||||
use shared::spectra::{SampledSpectrum, SampledWavelengths};
|
||||
use shared::utils::Transform;
|
||||
use std::sync::Arc;
|
||||
|
|
@ -69,11 +70,11 @@ pub struct SpectrumScaledTexture {
|
|||
|
||||
impl CreateSpectrumTexture for SpectrumScaledTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
spectrum_type: SpectrumType,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture> {
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_spectrum_type: SpectrumType,
|
||||
_loc: FileLoc,
|
||||
) -> Result<SpectrumTexture> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,18 @@
|
|||
use anyhow::Result;
|
||||
use crate::Arena;
|
||||
use shared::{textures::WindyTexture, utils::Transform};
|
||||
|
||||
use crate::{
|
||||
core::texture::{FloatTexture, FloatTextureTrait},
|
||||
core::texture::{CreateFloatTexture, FloatTexture, FloatTextureTrait},
|
||||
utils::{FileLoc, TextureParameterDictionary},
|
||||
};
|
||||
|
||||
pub trait CreateWindyTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl CreateWindyTexture for WindyTexture {
|
||||
impl CreateFloatTexture for WindyTexture {
|
||||
fn create(
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_loc: FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<FloatTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,18 @@
|
|||
use crate::Arena;
|
||||
use anyhow::Result;
|
||||
use shared::{textures::WrinkledTexture, utils::Transform};
|
||||
|
||||
use crate::{
|
||||
core::texture::{FloatTexture, FloatTextureTrait},
|
||||
core::texture::{CreateFloatTexture, FloatTexture, FloatTextureTrait},
|
||||
utils::{FileLoc, TextureParameterDictionary},
|
||||
};
|
||||
|
||||
pub trait CreateWrinkledTexture {
|
||||
fn create(
|
||||
render_from_texture: Transform,
|
||||
parameters: TextureParameterDictionary,
|
||||
loc: FileLoc,
|
||||
) -> Result<FloatTexture>;
|
||||
}
|
||||
|
||||
impl CreateWrinkledTexture for WrinkledTexture {
|
||||
impl CreateFloatTexture for WrinkledTexture {
|
||||
fn create(
|
||||
_render_from_texture: Transform,
|
||||
_parameters: TextureParameterDictionary,
|
||||
_loc: FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<FloatTexture> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ impl Upload for Spectrum {
|
|||
impl Upload for DenselySampledSpectrumBuffer {
|
||||
type Target = DenselySampledSpectrum;
|
||||
fn upload(&self, arena: &mut Arena) -> Ptr<Self::Target> {
|
||||
arena.alloc(self.device)
|
||||
arena.alloc(self.device())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ impl<T> Array2D<T> {
|
|||
let width = extent.p_max.x() - extent.p_min.x();
|
||||
let device = DeviceArray2D {
|
||||
extent,
|
||||
values: storage.as_mut_ptr(),
|
||||
values: values.as_mut_ptr().into(),
|
||||
stride: width,
|
||||
};
|
||||
Self { device, values }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::core::spectrum::{SPECTRUM_CACHE, get_spectrum_cache};
|
||||
use crate::core::spectrum::SPECTRUM_FILE_CACHE;
|
||||
use crate::core::texture::{FloatTexture, SpectrumTexture};
|
||||
use crate::spectra::data::get_named_spectrum;
|
||||
use crate::spectra::piecewise::PiecewiseLinearSpectrumBuffer;
|
||||
|
|
|
|||
Loading…
Reference in a new issue