diff options
Diffstat (limited to 'src/main.zig')
| -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, |
