mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix darkroom parallel_light
This commit is contained in:
parent
dc1e85923b
commit
e9910b090d
3 changed files with 25 additions and 79 deletions
|
@ -3,9 +3,6 @@
|
|||
|
||||
#include <limits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
#include <sprout/darkroom/colors/rgb.hpp>
|
||||
#include <sprout/darkroom/coords/vector.hpp>
|
||||
|
@ -35,7 +32,7 @@ namespace sprout {
|
|||
color_type col_;
|
||||
private:
|
||||
template<typename Intersection>
|
||||
SPROUT_CONSTEXPR color_type shade_4(
|
||||
SPROUT_CONSTEXPR color_type shade_2(
|
||||
Intersection const& inter,
|
||||
unit_type const& intensity
|
||||
) const
|
||||
|
@ -49,85 +46,51 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Intersection, typename LightRayIntersection>
|
||||
SPROUT_CONSTEXPR color_type shade_3(
|
||||
SPROUT_CONSTEXPR color_type shade_1(
|
||||
Intersection const& inter,
|
||||
position_type const& diff,
|
||||
position_type const& direction,
|
||||
LightRayIntersection const& light_ray_inter
|
||||
) const
|
||||
{
|
||||
return shade_4(
|
||||
return shade_2(
|
||||
inter,
|
||||
!sprout::darkroom::intersects::does_intersect(light_ray_inter)
|
||||
|| sprout::darkroom::intersects::distance(light_ray_inter)
|
||||
> sprout::darkroom::coords::length(diff)
|
||||
|| sprout::darkroom::intersects::distance(light_ray_inter)
|
||||
< std::numeric_limits<unit_type>::epsilon()
|
||||
? NS_SSCRISK_CEL_OR_SPROUT::max(
|
||||
std::numeric_limits<unit_type>::epsilon(),
|
||||
sprout::darkroom::coords::dot(
|
||||
direction,
|
||||
dir_,
|
||||
sprout::darkroom::intersects::normal(inter)
|
||||
)
|
||||
)
|
||||
: 0
|
||||
);
|
||||
}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type shade_2(
|
||||
Intersection const& inter,
|
||||
Objects const& objs,
|
||||
position_type const& diff,
|
||||
position_type const& direction
|
||||
) const
|
||||
{
|
||||
return shade_3(
|
||||
inter,
|
||||
diff,
|
||||
direction,
|
||||
sprout::darkroom::objects::intersect_list(
|
||||
objs,
|
||||
sprout::darkroom::rays::make_ray(
|
||||
sprout::darkroom::coords::add(
|
||||
sprout::darkroom::coords::scale(
|
||||
direction,
|
||||
std::numeric_limits<unit_type>::epsilon() * 256
|
||||
),
|
||||
sprout::darkroom::intersects::point_of_intersection(inter)
|
||||
),
|
||||
direction
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type shade_1(
|
||||
Intersection const& inter,
|
||||
Objects const& objs,
|
||||
position_type const& diff
|
||||
) const
|
||||
{
|
||||
return shade_2(
|
||||
inter,
|
||||
objs,
|
||||
diff,
|
||||
sprout::darkroom::coords::normalize(diff)
|
||||
);
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR basic_parallel_light(
|
||||
position_type const& dir,
|
||||
color_type const& col
|
||||
)
|
||||
: dir_(dir)
|
||||
: dir_(sprout::darkroom::coords::normalize(dir))
|
||||
, col_(col)
|
||||
{}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type operator()(Intersection const& inter, Objects const& objs) const {
|
||||
return shade_1(
|
||||
inter,
|
||||
objs,
|
||||
dir_
|
||||
sprout::darkroom::objects::intersect_list(
|
||||
objs,
|
||||
sprout::darkroom::rays::make_ray(
|
||||
sprout::darkroom::coords::add(
|
||||
sprout::darkroom::coords::scale(
|
||||
dir_,
|
||||
std::numeric_limits<unit_type>::epsilon() * 256
|
||||
),
|
||||
sprout::darkroom::intersects::point_of_intersection(inter)
|
||||
),
|
||||
dir_
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
#include <limits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
#include <sprout/darkroom/colors/rgb.hpp>
|
||||
#include <sprout/darkroom/coords/vector.hpp>
|
||||
|
|
|
@ -64,18 +64,21 @@ namespace sprout {
|
|||
return direction_value_ == aa_plane_direction::z;
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_6(
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_5(
|
||||
int hit_side,
|
||||
bool does_intersect,
|
||||
unit_type distance,
|
||||
position_type const& point_of_intersection,
|
||||
position_type const& normal
|
||||
position_type const& point_of_intersection
|
||||
) const
|
||||
{
|
||||
return typename intersection<Ray>::type(
|
||||
does_intersect,
|
||||
distance,
|
||||
point_of_intersection,
|
||||
normal,
|
||||
is_x() ? position_type(hit_side > 0 ? 1 : -1, 0, 0)
|
||||
: is_y() ? position_type(0, hit_side > 0 ? 1 : -1, 0)
|
||||
: position_type(0, 0, hit_side > 0 ? 1 : -1)
|
||||
,
|
||||
is_x() ? sprout::darkroom::materials::calc_material(
|
||||
mat_,
|
||||
sprout::darkroom::coords::z(point_of_intersection),
|
||||
|
@ -94,23 +97,6 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_5(
|
||||
int hit_side,
|
||||
bool does_intersect,
|
||||
unit_type distance,
|
||||
position_type const& point_of_intersection
|
||||
) const
|
||||
{
|
||||
return intersect_6<Ray>(
|
||||
does_intersect,
|
||||
distance,
|
||||
point_of_intersection,
|
||||
is_x() ? position_type(hit_side > 0 ? 1 : -1, 0, 0)
|
||||
: is_y() ? position_type(0, hit_side > 0 ? 1 : -1, 0)
|
||||
: position_type(0, 0, hit_side > 0 ? 1 : -1)
|
||||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_4(
|
||||
Ray const& ray,
|
||||
int hit_side,
|
||||
|
|
Loading…
Reference in a new issue