diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-12-12 22:59:21 -0500 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-12-12 23:15:46 -0500 |
commit | cb25af3547e469e2296d5d7621331db54c4fe362 (patch) | |
tree | 5858e227a3cefe485e7375b11ceac4ecb099051e | |
parent | 27304e9b491b39fbcef915838b95deaf7fe8d92a (diff) |
updat ray tracer to include depth
-rw-r--r-- | src/accelerate/myqtconcurrent.cpp | 7 | ||||
-rw-r--r-- | src/raytracer/raytracescene.h | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/accelerate/myqtconcurrent.cpp b/src/accelerate/myqtconcurrent.cpp index 686d28f..74dbd88 100644 --- a/src/accelerate/myqtconcurrent.cpp +++ b/src/accelerate/myqtconcurrent.cpp @@ -43,15 +43,14 @@ void RayTracer::renderParallel(RGBA *imageData, const RayTraceScene &scene) for (int imageRow = 0; imageRow < scene.height(); imageRow++) { for (int imageCol = 0; imageCol < scene.width(); imageCol++) { // FIXME: for now, use height as depth - for (int imageDepth = 0; imageDepth < scene.height(); imageDepth++) { + for (int imageDepth = 0; imageDepth < scene.depth(); imageDepth++) { // compute the ray float x = (imageCol - scene.width()/2.f) * viewplaneWidth / scene.width(); float y = (imageRow - scene.height()/2.f) * viewplaneHeight / scene.height(); - float z = (imageDepth - scene.height()/2.f) * viewplaneHeight / scene.height(); - float camera4dDepth = 1; + float z = (imageDepth - scene.width()/2.f) * viewplaneDepth / scene.width(); glm::vec4 pWorld = Vec4Ops::transformPoint4(glm::vec4(0.f), camera.getViewMatrix(), camera.getTranslationVector()); - glm::vec4 dWorld = Vec4Ops::inverseTransformDir4(glm::vec4(x, y, z, cameraDepth), camera.getViewMatrix()); + glm::vec4 dWorld = Vec4Ops::inverseTransformDir4(glm::vec4(x, y, z, -1.0), camera.getViewMatrix()); // get the pixel color glm::vec4 pixelColor = getPixelFromRay(pWorld, dWorld, scene, 0); diff --git a/src/raytracer/raytracescene.h b/src/raytracer/raytracescene.h index a380adc..35e4fb4 100644 --- a/src/raytracer/raytracescene.h +++ b/src/raytracer/raytracescene.h @@ -32,6 +32,9 @@ public: KdTree *m_kdTree; bvh *m_bvh; + + const int &depth() const; + private: int m_width; int m_height; @@ -41,5 +44,4 @@ private: std::vector<SceneLightData>m_lights; int m_depth; - const int &depth() const; }; |