From 8cc3e2ada26af6a45e577b9c7ffffb0bc795b7d3 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 27 Nov 2022 15:07:34 +0900 Subject: 8.4 --- src/main.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 216a302..7e78372 100644 --- a/src/main.zig +++ b/src/main.zig @@ -251,7 +251,7 @@ fn rayColor(r: Ray, world: Hittable, rand: std.rand.Random, depth: u32) Color { // If we've exceeded the ray bounce limit, no more ligth is gathered. return Color{ .x = 0.0, .y = 0.0, .z = 0.0 }; } - if (world.hit(r, 0, inf, &rec)) { + if (world.hit(r, 0.001, inf, &rec)) { const target = rec.p.add(rec.normal).add(randomPointInUnitSphere(rand)); return rayColor(Ray{ .origin = rec.p, .dir = target.sub(rec.p) }, world, rand, depth - 1).mul(0.5); } @@ -263,9 +263,9 @@ fn rayColor(r: Ray, world: Hittable, rand: std.rand.Random, depth: u32) Color { fn writeColor(out: anytype, c: Color, samples_per_pixel: u32) !void { const scale = 1.0 / @intToFloat(f64, samples_per_pixel); try out.print("{} {} {}\n", .{ - @floatToInt(u8, 256.0 * math.clamp(c.x * scale, 0.0, 0.999)), - @floatToInt(u8, 256.0 * math.clamp(c.y * scale, 0.0, 0.999)), - @floatToInt(u8, 256.0 * math.clamp(c.z * scale, 0.0, 0.999)), + @floatToInt(u8, 256.0 * math.clamp(@sqrt(c.x * scale), 0.0, 0.999)), + @floatToInt(u8, 256.0 * math.clamp(@sqrt(c.y * scale), 0.0, 0.999)), + @floatToInt(u8, 256.0 * math.clamp(@sqrt(c.z * scale), 0.0, 0.999)), }); } -- cgit v1.2.3-70-g09d2