Skip to main content

pfx_materials/
fixtures.rs

1use crate::brdf::{GLASS_IOR, WATER_IOR, dielectric_f0};
2use crate::kinds::{CoatWobble, Crinkle, Fibre, Grime, PlankWood, Scratch, WallMottle};
3use crate::material::{Content, Family, Material, NoiseKind, NoiseLayer};
4
5pub fn glass() -> Material {
6    Material {
7        family: Family::Glass,
8        base: [1.0, 1.0, 1.0],
9        roughness: 0.02,
10        specular: dielectric_f0(GLASS_IOR),
11        transmission: 1.0,
12        ior: GLASS_IOR,
13        ..Material::default()
14    }
15}
16
17pub fn liquid() -> Material {
18    let mut m = Material {
19        family: Family::Liquid,
20        base: [1.0, 1.0, 1.0],
21        roughness: 0.02,
22        specular: dielectric_f0(WATER_IOR),
23        transmission: 1.0,
24        ior: WATER_IOR,
25        absorption: 0.1,
26        subsurface: 0.1,
27        thin_film: 250.0,
28        thin_film_ior: 1.8,
29        thin_film_amount: 0.5,
30        ..Material::default()
31    };
32    m.push_layer(NoiseLayer::new(NoiseKind::Flow, 1.0, 10.0, 0));
33    m
34}
35
36pub fn all() -> Vec<(&'static str, Material)> {
37    let plain = Material {
38        base: [0.6, 0.55, 0.5],
39        roughness: 0.6,
40        ..Material::default()
41    };
42    let mut lacquer = Material {
43        family: Family::Lacquer,
44        base: [0.7, 0.2, 0.1],
45        roughness: 0.4,
46        clearcoat: 1.0,
47        clearcoat_roughness: 0.08,
48        content: Content::Ink,
49        ..Material::default()
50    };
51    lacquer.push_layer(CoatWobble::SAMPLE.layer(0.02, 0));
52    lacquer.push_layer(Scratch::SAMPLE.layer(0.5, 0));
53    let mut metal = Material {
54        family: Family::Metal,
55        base: [0.8, 0.7, 0.5],
56        roughness: 0.3,
57        metalness: 1.0,
58        ..Material::default()
59    };
60    metal.push_layer(CoatWobble::SAMPLE.layer(0.01, 0));
61    metal.push_layer(Grime::SAMPLE.layer(1.0, 0));
62    let mut wood = Material {
63        family: Family::Wood,
64        base: [0.3, 0.18, 0.1],
65        roughness: 0.45,
66        ..Material::default()
67    };
68    wood.push_layer(PlankWood::SAMPLE.layer(1.0, 0));
69    let mut wall = Material {
70        family: Family::Plaster,
71        base: [0.8, 0.78, 0.74],
72        roughness: 0.9,
73        ..Material::default()
74    };
75    wall.push_layer(WallMottle::SAMPLE.layer(1.0, 0));
76    let mut sheet = Material {
77        family: Family::Cloth,
78        base: [0.9, 0.88, 0.82],
79        roughness: 0.8,
80        subsurface: 0.25,
81        ..Material::default()
82    };
83    sheet.push_layer(Fibre::SAMPLE.layer(1.0, 0));
84    sheet.push_layer(Crinkle::SAMPLE.layer(1.0, 0));
85    let mut aged = plain;
86    aged.ageing.fade = 0.5;
87    aged.ageing.dust = 0.5;
88    aged.ageing.scratch = 0.4;
89    aged.ageing.seed = 7;
90    let glow = Material {
91        family: Family::Emissive,
92        base: [1.0, 0.9, 0.7],
93        emission: [2.0, 1.8, 1.4],
94        ..Material::default()
95    };
96    vec![
97        ("fixture/plain", plain),
98        ("fixture/lacquer", lacquer),
99        ("fixture/metal", metal),
100        ("fixture/wood", wood),
101        ("fixture/wall", wall),
102        ("fixture/sheet", sheet),
103        ("fixture/aged", aged),
104        ("fixture/glow", glow),
105        ("fixture/glass", glass()),
106        ("fixture/liquid", liquid()),
107    ]
108}