diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-01-23 23:44:14 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-01-23 23:44:14 +0900 |
| commit | 686b8801e6848573d5b9f8bc45bc9ab86153452b (patch) | |
| tree | db3e0e20ee63437e7ff0b7745e807a0afcb546bf /src/rtw/perlin.zig | |
| parent | 443912a58041f4b1733391758d2edd33de609ab0 (diff) | |
| download | RayTracingInOneWeekend.zig-686b8801e6848573d5b9f8bc45bc9ab86153452b.tar.gz RayTracingInOneWeekend.zig-686b8801e6848573d5b9f8bc45bc9ab86153452b.tar.zst RayTracingInOneWeekend.zig-686b8801e6848573d5b9f8bc45bc9ab86153452b.zip | |
5.3
Diffstat (limited to 'src/rtw/perlin.zig')
| -rw-r--r-- | src/rtw/perlin.zig | 5 |
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 { |
