this repo has no description
1const std = @import("std");
2
3const rayray = @import("rayray");
4const Camera = rayray.Camera;
5const Hittable = rayray.hittable.Hittable;
6const HittableList = rayray.hittable.HittableList;
7const material = rayray.material;
8const Material = material.Material;
9const Scene = rayray.Scene;
10const Sphere = rayray.hittable.Sphere;
11const tex = rayray.texture;
12const zm = rayray.zmath;
13
14camera: Camera.Options,
15world: HittableList,
16allocator: std.mem.Allocator,
17
18pub fn scene(s: *Scene) !void {
19 const c1 = try s.createTexture(tex.SolidColor.rgb(0.2, 0.3, 0.1));
20 const c2 = try s.createTexture(tex.SolidColor.rgb(0.9, 0.9, 0.9));
21 const checker_tex = try s.createTexture(tex.CheckerTexture.init(0.32, c1, c2));
22
23 const checker = try s.createMaterial(checker_tex);
24
25 try s.world.add(Hittable.initSphere(Sphere.init(zm.f32x4(0, -10, 0, 0), 10, checker)));
26 try s.world.add(Hittable.initSphere(Sphere.init(zm.f32x4(0, 10, 0, 0), 10, checker)));
27
28 try s.setCamera(Camera.Options{
29 .aspect_ratio = 16.0 / 9.0,
30 .image_width = 400,
31 .samples_per_pixel = 100,
32 .max_depth = 50,
33
34 .vfov = 20,
35 .look_from = zm.f32x4(13, 2, 3, 0),
36 .look_at = zm.f32x4(0, 0, 0, 0),
37
38 .defocus_angle = 0,
39 });
40}
41
42pub fn deinit(self: *@This()) void {
43 self.world.deinit();
44}