aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.zig
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-03-05 17:55:51 +0900
committernsfisis <nsfisis@gmail.com>2023-05-07 10:09:08 +0900
commitca914b32fabdc5bb3e2782d91cc323205d0714fd (patch)
tree6862d744e41286d5e371c5a19946e7fa400285db /src/main.zig
parent9ab677e15853814079583257d11256bdcdc88cbe (diff)
downloadRayTracingInOneWeekend.zig-ca914b32fabdc5bb3e2782d91cc323205d0714fd.tar.gz
RayTracingInOneWeekend.zig-ca914b32fabdc5bb3e2782d91cc323205d0714fd.tar.zst
RayTracingInOneWeekend.zig-ca914b32fabdc5bb3e2782d91cc323205d0714fd.zip
6.2
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index 00bc7e6..4a667f9 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -244,6 +244,19 @@ fn generateRandomScene(rng: Random, allocator: anytype) !Hittable {
return .{ .list = .{ .objects = hittable_objects } };
}
+fn generateEarthScene(allocator: anytype) !Hittable {
+ var hittable_objects = ArrayList(Hittable).init(allocator);
+
+ const earth_texture = try Texture.makeImage(allocator, "assets/sekaichizu.png");
+ var earth_surface = try allocator.create(Material);
+
+ earth_surface.* = .{ .diffuse = .{ .albedo = earth_texture } };
+
+ try hittable_objects.append(makeSphere(.{ .x = 0, .y = 0, .z = 0 }, 2, earth_surface));
+
+ return .{ .list = .{ .objects = hittable_objects } };
+}
+
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
@@ -259,7 +272,7 @@ pub fn main() !void {
const samples_per_pixel = 50;
const max_depth = 50;
- const scene = 3;
+ const scene = 4;
// World
var world: Hittable = undefined;
@@ -284,6 +297,11 @@ pub fn main() !void {
lookFrom = .{ .x = 13, .y = 2, .z = 3 };
lookAt = .{ .x = 0, .y = 0, .z = 0 };
vFov = 20.0;
+ } else if (scene == 4) {
+ world = try generateEarthScene(allocator);
+ lookFrom = .{ .x = 13, .y = 2, .z = 3 };
+ lookAt = .{ .x = 0, .y = 0, .z = 0 };
+ vFov = 20.0;
}
defer world.deinit(allocator);