2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2017-07-29 05:20:01 +00:00
|
|
|
Copyright (c) 2011-2017 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2011-11-26 06:20:35 +00:00
|
|
|
#ifndef SPROUT_DARKROOM_PIXELS_GENERATE_HPP
|
|
|
|
#define SPROUT_DARKROOM_PIXELS_GENERATE_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
2014-04-30 07:30:26 +00:00
|
|
|
#include <sprout/workaround/std/cstddef.hpp>
|
2013-04-06 04:06:51 +00:00
|
|
|
#include <sprout/index_tuple/metafunction.hpp>
|
2013-04-22 04:04:27 +00:00
|
|
|
#include <sprout/array.hpp>
|
2012-03-31 07:24:13 +00:00
|
|
|
#include <sprout/container/traits.hpp>
|
|
|
|
#include <sprout/container/functions.hpp>
|
2013-03-31 06:14:10 +00:00
|
|
|
#include <sprout/container/indexes.hpp>
|
2011-11-26 06:20:35 +00:00
|
|
|
#include <sprout/darkroom/colors/rgb.hpp>
|
2013-12-12 14:29:50 +00:00
|
|
|
#include <sprout/darkroom/renderers/calculate.hpp>
|
2013-09-24 06:08:36 +00:00
|
|
|
#include <sprout/darkroom/tracers/calculate.hpp>
|
2011-11-26 06:20:35 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace darkroom {
|
|
|
|
namespace pixels {
|
|
|
|
//
|
|
|
|
// generate
|
|
|
|
//
|
|
|
|
namespace detail {
|
|
|
|
template<
|
|
|
|
typename Pixels,
|
2012-10-05 15:58:56 +00:00
|
|
|
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-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Pixels>::value_type
|
2011-11-26 06:20:35 +00:00
|
|
|
generate_impl_line(
|
2012-10-05 15:58:56 +00:00
|
|
|
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
|
2012-10-06 04:53:07 +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
|
2012-10-06 04:53:07 +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>(
|
2013-09-24 06:08:36 +00:00
|
|
|
sprout::darkroom::tracers::calculate(
|
|
|
|
raytracer,
|
2012-10-05 15:58:56 +00:00
|
|
|
renderer, camera, objs, lights,
|
|
|
|
x + XIndexes, y, width, height, depth_max
|
2011-11-26 06:20:35 +00:00
|
|
|
)
|
|
|
|
)...
|
|
|
|
);
|
|
|
|
}
|
|
|
|
template<
|
|
|
|
typename Pixels,
|
2012-10-05 15:58:56 +00:00
|
|
|
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
|
|
|
>
|
2012-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR Pixels
|
2011-11-26 06:20:35 +00:00
|
|
|
generate_impl(
|
2012-10-05 15:58:56 +00:00
|
|
|
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>(
|
2012-10-05 15:58:56 +00:00
|
|
|
raytracer, renderer, camera, objs, lights,
|
|
|
|
x, y + YIndexes, width, height, depth_max,
|
2013-03-31 06:14:10 +00:00
|
|
|
sprout::container_indexes<typename sprout::container_traits<Pixels>::value_type>::make()
|
2011-11-26 06:20:35 +00:00
|
|
|
)...
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
template<
|
|
|
|
typename Pixels,
|
2012-10-05 15:58:56 +00:00
|
|
|
typename RayTracer, typename Renderer, typename Camera,
|
|
|
|
typename Objects, typename Lights
|
2011-11-26 06:20:35 +00:00
|
|
|
>
|
2012-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR Pixels generate(
|
2012-10-05 15:58:56 +00:00
|
|
|
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-10-06 04:53:07 +00:00
|
|
|
= 0,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Pixels>::size_type y
|
2012-10-06 04:53:07 +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
|
2012-10-06 04:53:07 +00:00
|
|
|
>::static_size,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Pixels>::size_type height
|
2012-10-06 04:53:07 +00:00
|
|
|
= sprout::container_traits<Pixels>::static_size,
|
2013-12-12 14:29:50 +00:00
|
|
|
std::size_t depth_max = sprout::darkroom::renderers::default_depth
|
2011-11-26 06:20:35 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::darkroom::pixels::detail::generate_impl<Pixels>(
|
2012-10-05 15:58:56 +00:00
|
|
|
raytracer, renderer, camera, objs, lights,
|
|
|
|
x, y, width, height, depth_max,
|
2013-03-31 06:14:10 +00:00
|
|
|
sprout::container_indexes<Pixels>::make()
|
2011-11-26 06:20:35 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// color_pixels
|
|
|
|
//
|
2013-03-26 17:02:16 +00:00
|
|
|
template<std::size_t Width, std::size_t Height, typename Color = sprout::darkroom::colors::rgb_t>
|
2011-11-26 06:20:35 +00:00
|
|
|
struct color_pixels {
|
|
|
|
public:
|
2012-10-05 15:58:56 +00:00
|
|
|
typedef sprout::array<sprout::array<Color, Width>, Height> type;
|
2011-11-26 06:20:35 +00:00
|
|
|
};
|
|
|
|
} // namespace pixels
|
|
|
|
} // namespace darkroom
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_DARKROOM_PIXELS_GENERATE_HPP
|