Skip to content

Commit 61ed559

Browse files
committed
Selective merge of seminar contribution of Eckholz via pr #31
1 parent f6826db commit 61ed559

File tree

17 files changed

+1013
-3
lines changed

17 files changed

+1013
-3
lines changed

src/artic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ set(ARTIC_EXTRA_SRC
8080
${CMAKE_CURRENT_SOURCE_DIR}/impl/technique/debugtracer.art
8181
${CMAKE_CURRENT_SOURCE_DIR}/impl/technique/infobuffer.art
8282
${CMAKE_CURRENT_SOURCE_DIR}/impl/technique/pathtracer.art
83+
${CMAKE_CURRENT_SOURCE_DIR}/impl/technique/restir.art
8384
${CMAKE_CURRENT_SOURCE_DIR}/impl/technique/photonmapper.art
8485
${CMAKE_CURRENT_SOURCE_DIR}/impl/technique/volpathtracer.art
8586
${CMAKE_CURRENT_SOURCE_DIR}/impl/technique/wireframe.art

src/artic/impl/camera/common.art

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Special camera to satisfy issues when using tracing mode
22
fn @make_null_camera() = Camera {
3+
near = 0,
4+
far = 0,
5+
fov = 0,
36
generate_ray = @ |_, _, _| make_zero_ray(),
47
differential = @ |_| ( make_vec3(0,0,0), make_vec3(0,0,0) )
58
};

src/artic/impl/camera/fishlens.art

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ fn @make_fishlens_camera(eye: Vec3, dir: Vec3, up: Vec3, w: f32, h: f32, mode: F
4848
}
4949

5050
Camera {
51+
near = tmin,
52+
far = tmax,
53+
fov = 0,
5154
generate_ray = @ |_, x, y| {
5255
make_ray(eye, compute_d(x,y), tmin, tmax, ray_flag_camera)
5356
},

src/artic/impl/camera/orthogonal.art

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
fn @make_orthogonal_camera(eye: Vec3, dir: Vec3, up: Vec3, scale: Vec2, tmin: f32, tmax: f32) -> Camera {
33
let right = vec3_normalize(vec3_cross(dir, up));
44
Camera {
5+
near = tmin,
6+
far = tmax,
7+
fov = 0,
58
generate_ray = @ |_, x, y| {
69
let pos = vec3_add(vec3_add(vec3_mulf(right, scale.x * x), vec3_mulf(up, scale.y * y)), eye);
710
make_ray(pos, dir, tmin, tmax, ray_flag_camera)

src/artic/impl/camera/perspective.art

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ fn @compute_scale_from_vfov(fov: f32, aspect: f32) -> Vec2 {
1313
}
1414

1515
// Creates a perspective camera
16-
fn @make_perspective_camera(eye: Vec3, dir: Vec3, up: Vec3, scale: Vec2, tmin: f32, tmax: f32) -> Camera {
16+
fn @make_perspective_camera(eye: Vec3, dir: Vec3, up: Vec3, scale: Vec2, tmin: f32, angle: f32, tmax: f32) -> Camera {
1717
let right = vec3_normalize(vec3_cross(dir, up));
1818
let view = make_mat3x3(right, up, dir);
1919

2020
Camera {
21+
near = tmin,
22+
far = tmax,
23+
fov = angle,
2124
generate_ray = @ |_, x, y| {
2225
let d = vec3_normalize(mat3x3_mul(view, make_vec3(scale.x * x, scale.y * y, 1)));
2326
make_ray(eye, d, tmin, tmax, ray_flag_camera)
@@ -37,6 +40,9 @@ fn @make_perspective_dof_camera(eye: Vec3, dir: Vec3, up: Vec3, scale: Vec2, ape
3740
let view = make_mat3x3(right, up, dir);
3841

3942
Camera {
43+
near = tmin,
44+
far = tmax,
45+
fov = 0,
4046
generate_ray = @ |rnd, x, y| {
4147
let global_dir = vec3_normalize(mat3x3_mul(view, make_vec3(scale.x * x, scale.y * y, 1)));
4248
let focus_pos = vec3_mulf(global_dir, focal_length);

src/artic/impl/emitter.art

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11

22
type RayStateInitializer = fn () -> RayPayload;
33

4-
fn @make_camera_emitter(camera: Camera, iter: i32, spi: i32, sampler: PixelSampler, initState: RayStateInitializer) -> RayEmitter {
4+
fn @make_camera_emitter(camera: Camera, iter: i32, spi: i32, frame: i32, sampler: PixelSampler, initState: RayStateInitializer) -> RayEmitter {
55
@ |sample, x, y, width, height| {
66
let mut hash = fnv_init();
77
hash = fnv_hash(hash, sample as u32);
88
hash = fnv_hash(hash, iter as u32);
99
hash = fnv_hash(hash, x as u32);
1010
hash = fnv_hash(hash, y as u32);
11+
hash = fnv_hash(hash, frame as u32);
1112
let mut rnd = hash /*as RndState*/;
1213
let (rx, ry) = sampler(&mut rnd, iter * spi + sample, x, y);
1314
let kx = 2 * (x as f32 + rx) / (width as f32) - 1;

src/artic/impl/pixel_sampler.art

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ fn @make_uniform_pixel_sampler() -> PixelSampler {
99
}
1010
}
1111

12+
fn @make_in_the_middle_sampler() -> PixelSampler {
13+
@| _, _, _, _| {
14+
(0.5, 0.5)
15+
}
16+
}
17+
1218
// --------------------------
1319
fn @make_mjitt_pixel_sampler(bin_x: u32, bin_y: u32) -> PixelSampler {
1420
let F1 = 0xa511e9b3 : u32;

src/artic/impl/sampling.art

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ fn @sample_triangle(mut u: f32, mut v: f32) -> (f32, f32) {
4747
// Probability density function for uniform sphere sampling
4848
fn @uniform_sphere_pdf() = 1 / (4 * flt_pi);
4949

50+
fn @uniform_hemisphere_pdf() = 1 / (2 * flt_pi);
51+
5052
// Samples a direction uniformly on a sphere
5153
fn @sample_uniform_sphere(u: f32, v: f32) -> DirSample {
5254
let c = 2 * v - 1;
@@ -55,6 +57,21 @@ fn @sample_uniform_sphere(u: f32, v: f32) -> DirSample {
5557
make_dir_sample(c, s, phi, uniform_sphere_pdf())
5658
}
5759

60+
fn @sample_uniform_hemisphere(u: f32, v: f32) -> DirSample {
61+
62+
let phi = 2.0 * flt_pi * v;
63+
64+
let sinTheta = safe_sqrt(1.0 - u * u);
65+
66+
DirSample
67+
{
68+
dir = make_vec3(sinTheta * math_builtins::cos(phi),
69+
sinTheta * math_builtins::sin(phi),
70+
u),
71+
pdf = uniform_hemisphere_pdf()
72+
}
73+
}
74+
5875
// Probability density function for equal area sphere sampling
5976
// Note: Keep in mind this is essentially the same as uniform_sphere, but a bit faster
6077
fn @equal_area_sphere_pdf() = uniform_sphere_pdf();

0 commit comments

Comments
 (0)