materials: add StripePattern as a Material color option.

This commit is contained in:
2021-07-24 19:36:32 -07:00
parent 3e383c4dbd
commit bfa3282a37
8 changed files with 96 additions and 45 deletions

View File

@@ -22,7 +22,7 @@ fn main() -> Result<()> {
let half = wall_size / 2.;
let mut shape = Shape::sphere();
shape.material = Material {
color: Color::new(1., 0.2, 1.),
color: Color::new(1., 0.2, 1.).into(),
specular: 0.5,
diffuse: 0.7,
shininess: 30.,

View File

@@ -42,7 +42,7 @@ fn main() -> Result<()> {
let mut floor = Shape::sphere();
floor.set_transform(Matrix4x4::scaling(10., 0.01, 10.));
floor.material = Material {
color: Color::new(1., 0.9, 0.9),
color: Color::new(1., 0.9, 0.9).into(),
specular: 0.,
..Material::default()
};
@@ -68,7 +68,7 @@ fn main() -> Result<()> {
let mut middle = Shape::sphere();
middle.set_transform(Matrix4x4::translation(-0.5, 1., 0.5));
middle.material = Material {
color: Color::new(0.1, 1., 0.5),
color: Color::new(0.1, 1., 0.5).into(),
diffuse: 0.7,
specular: 0.3,
..Material::default()
@@ -77,7 +77,7 @@ fn main() -> Result<()> {
let mut right = Shape::sphere();
right.set_transform(Matrix4x4::translation(1.5, 0.5, -0.5) * Matrix4x4::scaling(0.5, 0.5, 0.5));
right.material = Material {
color: Color::new(0.5, 1., 0.1),
color: Color::new(0.5, 1., 0.1).into(),
diffuse: 0.7,
specular: 0.3,
..Material::default()
@@ -88,7 +88,7 @@ fn main() -> Result<()> {
Matrix4x4::translation(-1.5, 0.33, -0.75) * Matrix4x4::scaling(0.33, 0.33, 0.33),
);
left.material = Material {
color: Color::new(1., 0.8, 0.1),
color: Color::new(1., 0.8, 0.1).into(),
diffuse: 0.7,
specular: 0.3,
..Material::default()

View File

@@ -54,7 +54,7 @@ fn main() -> Result<()> {
let mut floor = Shape::sphere();
floor.set_transform(Matrix4x4::scaling(10., 0.01, 10.));
floor.material = Material {
color: Color::new(1., 0.9, 0.9),
color: Color::new(1., 0.9, 0.9).into(),
specular: 0.,
..Material::default()
};
@@ -80,7 +80,7 @@ fn main() -> Result<()> {
let mut middle = Shape::sphere();
middle.set_transform(Matrix4x4::translation(-0.5, 1., 0.5));
middle.material = Material {
color: Color::new(0.1, 1., 0.5),
color: Color::new(0.1, 1., 0.5).into(),
diffuse: 0.7,
specular: 0.3,
..Material::default()
@@ -89,7 +89,7 @@ fn main() -> Result<()> {
let mut right = Shape::sphere();
right.set_transform(Matrix4x4::translation(1.5, 0.5, -0.5) * Matrix4x4::scaling(0.5, 0.5, 0.5));
right.material = Material {
color: Color::new(1., 1., 1.),
color: Color::new(1., 1., 1.).into(),
diffuse: 0.7,
specular: 0.0,
..Material::default()
@@ -100,7 +100,7 @@ fn main() -> Result<()> {
Matrix4x4::translation(-1.5, 0.33, -0.75) * Matrix4x4::scaling(0.33, 0.33, 0.33),
);
left.material = Material {
color: Color::new(1., 0.8, 0.1),
color: Color::new(1., 0.8, 0.1).into(),
diffuse: 0.7,
specular: 0.3,
..Material::default()

View File

@@ -59,14 +59,14 @@ fn main() -> Result<()> {
let mut floor = Shape::plane();
floor.material = Material {
color: Color::new(1., 0.2, 0.2),
color: Color::new(1., 0.2, 0.2).into(),
specular: 0.,
..Material::default()
};
let mut ceiling = Shape::plane();
ceiling.set_transform(Matrix4x4::translation(0., 6., 0.) * Matrix4x4::rotation_x(PI));
ceiling.material = Material {
color: Color::new(0.6, 0.6, 0.8),
color: Color::new(0.6, 0.6, 0.8).into(),
specular: 0.2,
..Material::default()
};
@@ -74,7 +74,7 @@ fn main() -> Result<()> {
let mut middle = Shape::sphere();
middle.set_transform(Matrix4x4::translation(-0.5, 0.5, 0.5));
middle.material = Material {
color: Color::new(0.1, 1., 0.5),
color: Color::new(0.1, 1., 0.5).into(),
diffuse: 0.7,
specular: 0.3,
..Material::default()
@@ -83,7 +83,7 @@ fn main() -> Result<()> {
let mut right = Shape::sphere();
right.set_transform(Matrix4x4::translation(1.5, 0.5, -0.5) * Matrix4x4::scaling(0.5, 0.5, 0.5));
right.material = Material {
color: Color::new(1., 1., 1.),
color: Color::new(1., 1., 1.).into(),
diffuse: 0.7,
specular: 0.0,
..Material::default()
@@ -94,7 +94,7 @@ fn main() -> Result<()> {
Matrix4x4::translation(-1.5, 0.33, -0.75) * Matrix4x4::scaling(0.33, 0.33, 0.33),
);
left.material = Material {
color: Color::new(1., 0.8, 0.1),
color: Color::new(1., 0.8, 0.1).into(),
diffuse: 0.7,
specular: 0.3,
..Material::default()