(fb: *mut Vec3, view: Viewport, scene: &Scene, rand_states: *mut DefaultRand)
| 4 | |
| 5 | #[kernel] |
| 6 | pub unsafe fn render(fb: *mut Vec3, view: Viewport, scene: &Scene, rand_states: *mut DefaultRand) { |
| 7 | let idx = thread::index_2d(); |
| 8 | if idx.x >= view.bounds.x as u32 || idx.y >= view.bounds.y as u32 { |
| 9 | return; |
| 10 | } |
| 11 | let px_idx = idx.y as usize * view.bounds.x + idx.x as usize; |
| 12 | |
| 13 | // generate a tiny offset for the ray for antialiasing |
| 14 | let rng = &mut *rand_states.add(px_idx); |
| 15 | let offset = Vec2::from(rng.normal_f32_2()); |
| 16 | |
| 17 | let ray = generate_ray(idx, &view, offset); |
| 18 | |
| 19 | let color = scene.ray_color(ray, rng); |
| 20 | *fb.add(px_idx) += color; |
| 21 | } |
| 22 | |
| 23 | /// Scales an accumulated buffer by the sample count, storing each pixel in the corresponding `out` pixel. |
| 24 | #[kernel] |
nothing calls this directly
no test coverage detected