add Metal material

This commit is contained in:
Fabien Freling 2021-05-11 22:52:51 +02:00
parent b3c47a914f
commit bc3fb54991
3 changed files with 45 additions and 11 deletions

View file

@ -94,17 +94,27 @@ pub fn main() anyerror!void {
// World
const materialGround = Material{
.materialType = MaterialType.Lambertian,
.materialType = .Lambertian,
.color = Color{ .x = 0.8, .y = 0.8, .z = 0.0 },
};
const materialCenter = Material{
.materialType = MaterialType.Lambertian,
.materialType = .Lambertian,
.color = Color{ .x = 0.7, .y = 0.3, .z = 0.3 },
};
const materialLeft = Material{
.materialType = .Metal,
.color = Color{ .x = 0.8, .y = 0.8, .z = 0.8 },
};
const materialRight = Material{
.materialType = .Metal,
.color = Color{ .x = 0.8, .y = 0.6, .z = 0.2 },
};
const spheres = [_]Sphere{
Sphere{ .center = Point3{ .x = 0, .y = 0, .z = -1 }, .radius = 0.5, .material = materialCenter },
Sphere{ .center = Point3{ .x = 0, .y = -100.5, .z = -1 }, .radius = 100, .material = materialGround },
Sphere{ .center = Point3{ .x = 0, .y = 0, .z = -1 }, .radius = 0.5, .material = materialCenter },
Sphere{ .center = Point3{ .x = -1, .y = 0, .z = -1 }, .radius = 0.5, .material = materialLeft },
Sphere{ .center = Point3{ .x = 1, .y = 0, .z = -1 }, .radius = 0.5, .material = materialRight },
};
const world = World{ .spheres = spheres[0..spheres.len] };