diff options
author | Fate Bussey <lafayette_bussey@brown.edu> | 2023-12-13 13:50:26 -0500 |
---|---|---|
committer | Fate Bussey <lafayette_bussey@brown.edu> | 2023-12-13 13:50:26 -0500 |
commit | 88ac9032e4a53407c569d6eb7c67619924daf296 (patch) | |
tree | 2fbf16d94d17a33602fb3f69751f1801a8659a87 /src | |
parent | 4fb06778c1a19914c759ab5db495754b1fd9e2c3 (diff) |
cone intersection fixes ONGOING
Diffstat (limited to 'src')
-rw-r--r-- | src/.DS_Store | bin | 8196 -> 0 bytes | |||
-rw-r--r-- | src/illuminate/illuminate.cpp | 2 | ||||
-rw-r--r-- | src/intersect/intersect.cpp | 8 | ||||
-rw-r--r-- | src/raytracer/raytracer.cpp | 2 |
4 files changed, 7 insertions, 5 deletions
diff --git a/src/.DS_Store b/src/.DS_Store Binary files differdeleted file mode 100644 index 5d99fdf..0000000 --- a/src/.DS_Store +++ /dev/null diff --git a/src/illuminate/illuminate.cpp b/src/illuminate/illuminate.cpp index a651924..d031e6d 100644 --- a/src/illuminate/illuminate.cpp +++ b/src/illuminate/illuminate.cpp @@ -93,4 +93,4 @@ glm::vec4 RayTracer::illuminatePixel( illumination += reflect(intersectionWorld, normalWorld, incidentDir, shape, scene, depth + 1); return illumination; -}
\ No newline at end of file +} diff --git a/src/intersect/intersect.cpp b/src/intersect/intersect.cpp index 69512e3..71cae49 100644 --- a/src/intersect/intersect.cpp +++ b/src/intersect/intersect.cpp @@ -59,7 +59,7 @@ glm::vec4 intersectCone( isHit = false; float t = FINF; // updated to 4d - // x^2 + y^2 - z^2 - w^2= 0, conic top + // x^2 + z^2 - y^2 - w^2= 0, conic top float radius = 0.5f; float a = d.x*d.x + d.z*d.z - .25f*(d.y*d.y) - .25f*(d[3]*d[3]); float b = 2.f*(p.x*d.x + p.z*d.z) - .5f*(p.y*d.y) + .25f*d.y - .5f*(p[3]*d[3]) + .25f*d[3]; @@ -97,7 +97,8 @@ glm::vec4 intersectCone( auto pwBase = p + twBase * d; if ( twBase > 0 && - pwBase.x*pwBase.x + pwBase.z*pwBase.z <= pwBase.y*pwBase.y + pwBase.x*pwBase.x + pwBase.z*pwBase.z <= pwBase.y*pwBase.y -.25f && + pwBase.y >= -.5f && pwBase.y <= .5f ) { t = std::min(t, twBase); @@ -108,7 +109,8 @@ glm::vec4 intersectCone( auto pyBase = p + tyBase * d; if ( tyBase > 0 && - pyBase.x*pyBase.x + pyBase.z*pyBase.z <= pyBase[3]*pyBase[3] + pyBase.x*pyBase.x + pyBase.z*pyBase.z <= pyBase[3]*pyBase[3] -.25f && + pyBase[3] >= -.5f && pyBase[3] <= .5f ) { t = std::min(t, tyBase); diff --git a/src/raytracer/raytracer.cpp b/src/raytracer/raytracer.cpp index 3db0faa..65f898d 100644 --- a/src/raytracer/raytracer.cpp +++ b/src/raytracer/raytracer.cpp @@ -99,7 +99,7 @@ glm::vec4 RayTracer::getPixelFromRay( continue; } - auto newIntersectionWorld = shape.ctm * newIntersectionObj; + auto newIntersectionWorld = Vec4Ops::transformPoint4(newIntersectionObj,shape.ctm,shape.translation4d); float newDist = glm::distance(newIntersectionWorld, pWorld); if ( newDist < minDist // closer intersection |