add defocus blur
This commit is contained in:
parent
d6ba8e354c
commit
2ab82d4c92
2 changed files with 40 additions and 11 deletions
|
@ -123,12 +123,19 @@ pub fn main() anyerror!void {
|
|||
const world = World{ .spheres = spheres[0..spheres.len] };
|
||||
|
||||
// Camera
|
||||
const lookFrom = Point3{ .x = 3, .y = 3, .z = 2 };
|
||||
const lookAt = Point3{ .x = 0, .y = 0, .z = -1 };
|
||||
const vup = Vec3{ .x = 0, .y = 1, .z = 0 };
|
||||
const distToFocus = lookFrom.sub(lookAt).length();
|
||||
const aperture = 2.0;
|
||||
const camera = Camera.init(
|
||||
Point3{ .x = -2, .y = 2, .z = 1 },
|
||||
Point3{ .x = 0, .y = 0, .z = -1 },
|
||||
Vec3{ .x = 0, .y = 1, .z = 0 },
|
||||
lookFrom,
|
||||
lookAt,
|
||||
vup,
|
||||
20.0,
|
||||
aspectRatio
|
||||
aspectRatio,
|
||||
aperture,
|
||||
distToFocus
|
||||
);
|
||||
|
||||
const window = sdl.c.SDL_CreateWindow(
|
||||
|
@ -186,7 +193,7 @@ pub fn main() anyerror!void {
|
|||
|
||||
const u = (@intToFloat(f32, i) + prng.random.float(f32)) / @intToFloat(f32, (imageWidth - 1));
|
||||
const v = (@intToFloat(f32, j) + prng.random.float(f32)) / @intToFloat(f32, (imageHeight - 1));
|
||||
const r = camera.getRay(u, v);
|
||||
const r = camera.getRay(u, v, &prng.random);
|
||||
const sample = rayColor(r, world, &prng.random, maxDepth);
|
||||
pixelColor.* = pixelColor.*.add(sample);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue