1#ifndef TATOOINE_RENDERING_RAYTRACING_RENDER_H
2#define TATOOINE_RENDERING_RAYTRACING_RENDER_H
10template <
typename Real>
13 std::string
const& prop_name =
"image") {
15 auto& rendered_mesh = image.template add_vertex_property<vec3>(prop_name);
17 constexpr std::array offsets{
vec2{0, 0},
vec2{-0.25, -0.25},
18 vec2{0.25, -0.25},
vec2{-0.25, 0.25},
20 Real
const shininess = 10;
21 auto const L =
normalize(cam.lookat() - cam.eye());
22#pragma omp parallel for collapse(2)
23 for (std::size_t y = 0; y < cam.plane_height(); ++y) {
24 for (std::size_t x = 0; x < cam.plane_width(); ++x) {
26 for (
auto const& offset : offsets) {
27 auto const cur_ray = cam.ray(x + offset(0), y + offset(1));
31 auto const V =
normalize(cur_ray.direction());
34 auto luminance = diffuse_color;
36 auto const illuminance = std::abs(
dot(L, N));
45 rendered_mesh(x, y) += luminance;
47 rendered_mesh(x, y) += bg_color;
50 rendered_mesh(x, y) /= offsets.size();
Definition: rectilinear_grid.h:38
auto render(camera< Real > const &cam, unstructured_triangular_grid< Real, 3 > const &mesh, vec< Real, 3 > const &bg_color=vec< Real, 3 >::ones(), std::string const &prop_name="image")
Definition: render.h:11
constexpr auto normalize(base_tensor< Tensor, T, N > const &t_in) -> vec< T, N >
Definition: tensor_operations.h:100
constexpr auto dot(base_tensor< Tensor0, T0, N > const &lhs, base_tensor< Tensor1, T1, N > const &rhs)
Definition: tensor_operations.h:120
Definition: intersection.h:13
normal_t normal
normal of intersection point on the primitive
Definition: intersection.h:31
Definition: unstructured_triangular_grid.h:10
static auto constexpr zeros()
Definition: vec.h:26