adaptive ray epsilon
parent
0b8863f2cb
commit
9fcc46643b
|
@ -108,9 +108,7 @@ public:
|
||||||
|
|
||||||
/// Cast a shadow ray
|
/// Cast a shadow ray
|
||||||
inline bool isOccluded(const Point &p1, const Point &p2) const {
|
inline bool isOccluded(const Point &p1, const Point &p2) const {
|
||||||
Intersection its;
|
Ray ray(p1, p2-p1);
|
||||||
Vector direction = p2 - p1;
|
|
||||||
Ray ray(p1, direction);
|
|
||||||
ray.mint = ShadowEpsilon;
|
ray.mint = ShadowEpsilon;
|
||||||
ray.maxt = 1-ShadowEpsilon;
|
ray.maxt = 1-ShadowEpsilon;
|
||||||
return m_kdtree->rayIntersect(ray);
|
return m_kdtree->rayIntersect(ray);
|
||||||
|
|
|
@ -211,8 +211,15 @@ bool KDTree::rayIntersect(const Ray &ray, Intersection &its) const {
|
||||||
++raysTraced;
|
++raysTraced;
|
||||||
if (m_rootBounds.rayIntersect(ray, mint, maxt)) {
|
if (m_rootBounds.rayIntersect(ray, mint, maxt)) {
|
||||||
its.t = std::numeric_limits<Float>::infinity();
|
its.t = std::numeric_limits<Float>::infinity();
|
||||||
if (ray.mint > mint)
|
|
||||||
mint = ray.mint;
|
/* Adaptive ray epsilon */
|
||||||
|
Float rayMinT = ray.mint;
|
||||||
|
if (rayMinT == Epsilon)
|
||||||
|
rayMinT *= std::max(std::max(std::abs(ray.o.x),
|
||||||
|
std::abs(ray.o.y)), std::abs(ray.o.z));
|
||||||
|
|
||||||
|
if (rayMinT > mint)
|
||||||
|
mint = rayMinT;
|
||||||
if (ray.maxt < maxt)
|
if (ray.maxt < maxt)
|
||||||
maxt = ray.maxt;
|
maxt = ray.maxt;
|
||||||
if (maxt <= mint)
|
if (maxt <= mint)
|
||||||
|
|
Loading…
Reference in New Issue