this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

gamma correction

Altagos 522e4bdd cfd4e7b8

+10 -6
+10 -6
src/renderer.zig
··· 25 25 26 26 if (world.hit(r, IntervalF32.init(0.001, std.math.inf(f32)))) |rec| { 27 27 r.orig = rec.p; 28 - r.dir = util.randomOnHemisphere(rec.normal); 29 - return zm.f32x4(0.5, 0.5, 0.5, 1.0) * rayColor(r, world, depth - 1); 28 + r.dir = rec.normal + util.randomUnitVec(); 29 + return zm.f32x4(0.1, 0.1, 0.1, 1.0) * rayColor(r, world, depth - 1); 30 30 } 31 31 32 32 const unit_direction = zm.normalize3(r.dir); ··· 73 73 const scale: f32 = 1.0 / @as(f32, @floatFromInt(samples_per_pixel)); 74 74 const intensity = IntervalF32.init(0.0, 0.999); 75 75 76 - const r_scaled = v[0] * scale; 77 - const g_scaled = v[1] * scale; 78 - const b_scaled = v[2] * scale; 79 - const a_scaled = v[3] * scale; 76 + const r_scaled = linearToGamma(v[0] * scale); 77 + const g_scaled = linearToGamma(v[1] * scale); 78 + const b_scaled = linearToGamma(v[2] * scale); 79 + const a_scaled = linearToGamma(v[3] * scale); 80 80 81 81 const r: u8 = @intFromFloat(256 * intensity.clamp(r_scaled)); 82 82 const g: u8 = @intFromFloat(256 * intensity.clamp(g_scaled)); ··· 85 85 86 86 return zigimg.color.Rgba32.initRgba(r, g, b, a); 87 87 } 88 + 89 + inline fn linearToGamma(linear_component: f32) f32 { 90 + return @sqrt(linear_component); 91 + }