aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main.zig2
-rw-r--r--src/rtw/texture.zig7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/main.zig b/src/main.zig
index e2553b5..a0b0fd2 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -165,7 +165,7 @@ fn generateTwoSpheres(rng: Random, allocator: anytype) !Hittable {
fn generateTwoPerlinSpheres(rng: Random, allocator: anytype) !Hittable {
var hittable_objects = ArrayList(Hittable).init(allocator);
- const perlin = Texture.makeNoise(rng);
+ const perlin = Texture.makeNoise(4.0, rng);
var mat1 = try allocator.create(Material);
var mat2 = try allocator.create(Material);
diff --git a/src/rtw/texture.zig b/src/rtw/texture.zig
index 63b8f46..cf2b08b 100644
--- a/src/rtw/texture.zig
+++ b/src/rtw/texture.zig
@@ -29,8 +29,8 @@ pub const Texture = union(TextureTag) {
) };
}
- pub fn makeNoise(rng: Random) Texture {
- return .{ .noise = .{ .perlin = Perlin.init(rng) } };
+ pub fn makeNoise(scale: f64, rng: Random) Texture {
+ return .{ .noise = .{ .perlin = Perlin.init(rng), .scale = scale } };
}
pub fn value(tx: Texture, u: f64, v: f64, p: Vec3) Color {
@@ -83,10 +83,11 @@ pub const CheckerTexture = struct {
pub const NoiseTexture = struct {
perlin: Perlin,
+ scale: f64,
fn value(tx: NoiseTexture, u: f64, v: f64, p: Vec3) Color {
_ = u;
_ = v;
- return rgb(1, 1, 1).mul(tx.perlin.noise(p));
+ return rgb(1, 1, 1).mul(tx.perlin.noise(p.mul(tx.scale)));
}
};