aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-01-23 23:44:14 +0900
committernsfisis <nsfisis@gmail.com>2023-01-23 23:44:14 +0900
commit686b8801e6848573d5b9f8bc45bc9ab86153452b (patch)
treedb3e0e20ee63437e7ff0b7745e807a0afcb546bf
parent443912a58041f4b1733391758d2edd33de609ab0 (diff)
downloadRayTracingInOneWeekend.zig-686b8801e6848573d5b9f8bc45bc9ab86153452b.tar.gz
RayTracingInOneWeekend.zig-686b8801e6848573d5b9f8bc45bc9ab86153452b.tar.zst
RayTracingInOneWeekend.zig-686b8801e6848573d5b9f8bc45bc9ab86153452b.zip
5.3
-rw-r--r--src/rtw/perlin.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rtw/perlin.zig b/src/rtw/perlin.zig
index 176be00..987ac52 100644
--- a/src/rtw/perlin.zig
+++ b/src/rtw/perlin.zig
@@ -35,6 +35,9 @@ pub const Perlin = struct {
const u = p.x - @floor(p.x);
const v = p.y - @floor(p.y);
const w = p.z - @floor(p.z);
+ const u_ = u * u * (3 - 2 * u);
+ const v_ = v * v * (3 - 2 * v);
+ const w_ = w * w * (3 - 2 * w);
const i = @floatToInt(i32, @floor(p.x));
const j = @floatToInt(i32, @floor(p.y));
@@ -56,7 +59,7 @@ pub const Perlin = struct {
}
}
- return trilinearInterp(c, u, v, w);
+ return trilinearInterp(c, u_, v_, w_);
}
fn perlinGeneratePerm(rng: Random, p: []usize) void {