2011-11-26 06:20:35 +00:00
|
|
|
#ifndef SPROUT_DARKROOM_PIXELS_GENERATE_HPP
|
|
|
|
#define SPROUT_DARKROOM_PIXELS_GENERATE_HPP
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/index_tuple.hpp>
|
|
|
|
#include <sprout/array.hpp>
|
2012-03-31 07:24:13 +00:00
|
|
|
#include <sprout/container/traits.hpp>
|
|
|
|
#include <sprout/container/functions.hpp>
|
2011-11-26 06:20:35 +00:00
|
|
|
#include <sprout/darkroom/colors/rgb.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace darkroom {
|
|
|
|
namespace pixels {
|
|
|
|
//
|
|
|
|
// generate
|
|
|
|
//
|
|
|
|
namespace detail {
|
|
|
|
template<
|
|
|
|
typename Pixels,
|
|
|
|
typename RayTracer,
|
|
|
|
typename Renderer,
|
|
|
|
typename Camera,
|
|
|
|
typename Objects,
|
|
|
|
typename Lights,
|
2012-02-28 01:46:39 +00:00
|
|
|
sprout::index_t... XIndexes
|
2011-11-26 06:20:35 +00:00
|
|
|
>
|
2012-03-31 07:24:13 +00:00
|
|
|
SPROUT_CONSTEXPR inline typename sprout::container_traits<Pixels>::value_type
|
2011-11-26 06:20:35 +00:00
|
|
|
generate_impl_line(
|
|
|
|
RayTracer const& raytracer,
|
|
|
|
Renderer const& renderer,
|
|
|
|
Camera const& camera,
|
|
|
|
Objects const& objs,
|
|
|
|
Lights const& lights,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<
|
|
|
|
typename sprout::container_traits<Pixels>::value_type
|
2011-11-26 06:20:35 +00:00
|
|
|
>::size_type x
|
|
|
|
,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Pixels>::size_type y,
|
|
|
|
typename sprout::container_traits<
|
|
|
|
typename sprout::container_traits<Pixels>::value_type
|
2011-11-26 06:20:35 +00:00
|
|
|
>::size_type width
|
|
|
|
,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Pixels>::size_type height,
|
2011-11-26 06:20:35 +00:00
|
|
|
std::size_t depth_max,
|
|
|
|
sprout::index_tuple<XIndexes...>
|
|
|
|
)
|
|
|
|
{
|
2012-03-31 07:24:13 +00:00
|
|
|
typedef typename sprout::container_traits<Pixels>::value_type pixel_line_type;
|
|
|
|
typedef typename sprout::container_traits<pixel_line_type>::value_type pixel_type;
|
|
|
|
return sprout::make<pixel_line_type>(
|
2011-11-26 06:20:35 +00:00
|
|
|
sprout::darkroom::colors::rgb_f_to_rgb<pixel_type>(
|
|
|
|
raytracer.template operator()(
|
|
|
|
renderer,
|
|
|
|
camera,
|
|
|
|
objs,
|
|
|
|
lights,
|
|
|
|
x + XIndexes,
|
|
|
|
y,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
depth_max
|
|
|
|
)
|
|
|
|
)...
|
|
|
|
);
|
|
|
|
}
|
|
|
|
template<
|
|
|
|
typename Pixels,
|
|
|
|
typename RayTracer,
|
|
|
|
typename Renderer,
|
|
|
|
typename Camera,
|
|
|
|
typename Objects,
|
|
|
|
typename Lights,
|
2012-02-28 01:46:39 +00:00
|
|
|
sprout::index_t... YIndexes
|
2011-11-26 06:20:35 +00:00
|
|
|
>
|
|
|
|
SPROUT_CONSTEXPR inline Pixels
|
|
|
|
generate_impl(
|
|
|
|
RayTracer const& raytracer,
|
|
|
|
Renderer const& renderer,
|
|
|
|
Camera const& camera,
|
|
|
|
Objects const& objs,
|
|
|
|
Lights const& lights,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<
|
|
|
|
typename sprout::container_traits<Pixels>::value_type
|
2011-11-26 06:20:35 +00:00
|
|
|
>::size_type x
|
|
|
|
,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Pixels>::size_type y,
|
|
|
|
typename sprout::container_traits<
|
|
|
|
typename sprout::container_traits<Pixels>::value_type
|
2011-11-26 06:20:35 +00:00
|
|
|
>::size_type width
|
|
|
|
,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Pixels>::size_type height,
|
2011-11-26 06:20:35 +00:00
|
|
|
std::size_t depth_max,
|
|
|
|
sprout::index_tuple<YIndexes...>
|
|
|
|
)
|
|
|
|
{
|
2012-03-31 07:24:13 +00:00
|
|
|
return sprout::make<Pixels>(
|
2011-11-26 06:20:35 +00:00
|
|
|
sprout::darkroom::pixels::detail::generate_impl_line<Pixels>(
|
|
|
|
raytracer,
|
|
|
|
renderer,
|
|
|
|
camera,
|
|
|
|
objs,
|
|
|
|
lights,
|
|
|
|
x,
|
|
|
|
y + YIndexes,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
depth_max,
|
|
|
|
typename sprout::index_range<
|
|
|
|
0,
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::container_traits<
|
|
|
|
typename sprout::container_traits<Pixels>::value_type
|
|
|
|
>::static_size
|
2011-11-26 06:20:35 +00:00
|
|
|
>::type()
|
|
|
|
)...
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
template<
|
|
|
|
typename Pixels,
|
|
|
|
typename RayTracer,
|
|
|
|
typename Renderer,
|
|
|
|
typename Camera,
|
|
|
|
typename Objects,
|
|
|
|
typename Lights
|
|
|
|
>
|
|
|
|
SPROUT_CONSTEXPR inline Pixels generate(
|
|
|
|
RayTracer const& raytracer,
|
|
|
|
Renderer const& renderer,
|
|
|
|
Camera const& camera,
|
|
|
|
Objects const& objs,
|
|
|
|
Lights const& lights,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<
|
|
|
|
typename sprout::container_traits<Pixels>::value_type
|
2011-11-26 06:20:35 +00:00
|
|
|
>::size_type x
|
|
|
|
= 0
|
|
|
|
,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Pixels>::size_type y
|
2011-11-26 06:20:35 +00:00
|
|
|
= 0
|
|
|
|
,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<
|
|
|
|
typename sprout::container_traits<Pixels>::value_type
|
2011-11-26 06:20:35 +00:00
|
|
|
>::size_type width
|
2012-03-31 07:24:13 +00:00
|
|
|
= sprout::container_traits<
|
|
|
|
typename sprout::container_traits<Pixels>::value_type
|
|
|
|
>::static_size
|
2011-11-26 06:20:35 +00:00
|
|
|
,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Pixels>::size_type height
|
|
|
|
= sprout::container_traits<Pixels>::static_size
|
2011-11-26 06:20:35 +00:00
|
|
|
,
|
|
|
|
std::size_t depth_max = 8
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::darkroom::pixels::detail::generate_impl<Pixels>(
|
|
|
|
raytracer,
|
|
|
|
renderer,
|
|
|
|
camera,
|
|
|
|
objs,
|
|
|
|
lights,
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
depth_max,
|
|
|
|
typename sprout::index_range<
|
|
|
|
0,
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::container_traits<Pixels>::static_size
|
2011-11-26 06:20:35 +00:00
|
|
|
>::type()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// color_pixels
|
|
|
|
//
|
|
|
|
template<std::size_t Width, std::size_t Height, typename Color = sprout::darkroom::colors::rgb>
|
|
|
|
struct color_pixels {
|
|
|
|
public:
|
|
|
|
typedef sprout::array<
|
|
|
|
sprout::array<Color, Width>,
|
|
|
|
Height
|
|
|
|
> type;
|
|
|
|
};
|
|
|
|
} // namespace pixels
|
|
|
|
} // namespace darkroom
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_DARKROOM_PIXELS_GENERATE_HPP
|