29 lines
1.1 KiB
Rust
29 lines
1.1 KiB
Rust
use crate::Arena;
|
|
use crate::core::texture::{CreateSpectrumTexture, CreateTextureMapping, SpectrumTexture};
|
|
use crate::spectra::get_colorspace_device;
|
|
use crate::utils::{FileLoc, TextureParameterDictionary};
|
|
use anyhow::Result;
|
|
use shared::Transform;
|
|
use shared::core::texture::{SpectrumType, TextureMapping3D};
|
|
use shared::textures::MarbleTexture;
|
|
|
|
impl CreateSpectrumTexture for MarbleTexture {
|
|
fn create(
|
|
render_from_texture: Transform,
|
|
parameters: TextureParameterDictionary,
|
|
spectrum_type: SpectrumType,
|
|
loc: FileLoc,
|
|
_arena: &Arena,
|
|
) -> Result<SpectrumTexture> {
|
|
let map = TextureMapping3D::create(¶meters, &render_from_texture, &loc)?;
|
|
let tex = MarbleTexture::new(
|
|
map,
|
|
parameters.get_one_int("octaves", 8)?,
|
|
parameters.get_one_float("roughness", 0.5)?,
|
|
parameters.get_one_float("scale", 1.)?,
|
|
parameters.get_one_float("variation", 0.2)?,
|
|
get_colorspace_device().srgb,
|
|
);
|
|
Ok(SpectrumTexture::Marble(tex))
|
|
}
|
|
}
|