diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-08-19 14:56:33 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-08-19 14:56:33 +0900 |
| commit | b8d5f7cc926c19f87884f8506a925b86c53c99c1 (patch) | |
| tree | 224381921c1d29221163287089d2b53efc78ce3a /src/rtw/texture.zig | |
| parent | aa61d3a19167c7ef21fd2c7dcceb759005e81ea3 (diff) | |
| download | RayTracingInOneWeekend.zig-b8d5f7cc926c19f87884f8506a925b86c53c99c1.tar.gz RayTracingInOneWeekend.zig-b8d5f7cc926c19f87884f8506a925b86c53c99c1.tar.zst RayTracingInOneWeekend.zig-b8d5f7cc926c19f87884f8506a925b86c53c99c1.zip | |
feat: update zig 0.11.0
Diffstat (limited to 'src/rtw/texture.zig')
| -rw-r--r-- | src/rtw/texture.zig | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rtw/texture.zig b/src/rtw/texture.zig index aabc18d..4095a9c 100644 --- a/src/rtw/texture.zig +++ b/src/rtw/texture.zig @@ -130,18 +130,18 @@ pub const ImageTexture = struct { // Clamp input texture coordinates to [0, 1] x [1, 0] const u_ = std.math.clamp(u, 0.0, 1.0); const v_ = 1.0 - std.math.clamp(v, 0.0, 1.0); // Flip v to image coordinates - const i = @floatToInt(usize, u_ * @intToFloat(f64, tx.image.width)); - const j = @floatToInt(usize, v_ * @intToFloat(f64, tx.image.height)); + const i = @as(usize, @intFromFloat(u_ * @as(f64, @floatFromInt(tx.image.width)))); + const j = @as(usize, @intFromFloat(v_ * @as(f64, @floatFromInt(tx.image.height)))); // Clamp integer mapping, since actual coordinates should be less than 1.0 const i_ = @min(i, tx.image.width - 1); const j_ = @min(j, tx.image.width - 1); const color_scale = 1.0 / 255.0; const pixels = tx.image.pixels.asBytes(); const offset = j_ * tx.image.width * 4 + i_ * 4; - const r = @intToFloat(f64, pixels[offset + 0]); - const g = @intToFloat(f64, pixels[offset + 1]); - const b = @intToFloat(f64, pixels[offset + 2]); - const a = @intToFloat(f64, pixels[offset + 3]); + const r = @as(f64, @floatFromInt(pixels[offset + 0])); + const g = @as(f64, @floatFromInt(pixels[offset + 1])); + const b = @as(f64, @floatFromInt(pixels[offset + 2])); + const a = @as(f64, @floatFromInt(pixels[offset + 3])); if (a == 0) { // Ocean return rgb(0, 0, 1.0); |
