diff options
| author | nsfisis <nsfisis@gmail.com> | 2022-12-06 22:02:39 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2022-12-06 22:02:39 +0900 |
| commit | f414f8428584cc609d7ca302faf56c82ebf7fa67 (patch) | |
| tree | 1f99f40f14d5f07ad95b328f9c71be521fa2db67 | |
| parent | 123aa329786012849af0b68bb03c160b02f20551 (diff) | |
| download | RayTracingInOneWeekend.zig-f414f8428584cc609d7ca302faf56c82ebf7fa67.tar.gz RayTracingInOneWeekend.zig-f414f8428584cc609d7ca302faf56c82ebf7fa67.tar.zst RayTracingInOneWeekend.zig-f414f8428584cc609d7ca302faf56c82ebf7fa67.zip | |
4.1
| -rw-r--r-- | src/main.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index 0979ca9..fac7648 100644 --- a/src/main.zig +++ b/src/main.zig @@ -234,6 +234,9 @@ const HitRecord = struct { material: *const Material, // p = ray.at(t) t: f64, + // The coordinate of the surface where the ray intersects. + u: f64, + v: f64, // True if the ray hits the hittable from the front face, i.e., outside of it. front_face: bool, }; @@ -627,6 +630,31 @@ const BvhNode = struct { } }; +const TextureTag = enum { + solid, +}; + +const Texture = union(TextureTag) { + solid: SolidTexture, + + fn value(tx: Texture, u: f64, v: f64, p: Vec3) Color { + return switch (tx) { + TextureTag.solid => |solidTx| solidTx.value(u, v, p), + }; + } +}; + +const SolidTexture = struct { + color: Color, + + fn value(tx: SolidTexture, u: f64, v: f64, p: Vec3) Color { + _ = u; + _ = v; + _ = p; + return tx.color; + } +}; + const Camera = struct { origin: Point3, horizontal: Vec3, |
