From cb25af3547e469e2296d5d7621331db54c4fe362 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Tue, 12 Dec 2023 22:59:21 -0500 Subject: updat ray tracer to include depth --- src/accelerate/myqtconcurrent.cpp | 7 +++---- src/raytracer/raytracescene.h | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') 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::vectorm_lights; int m_depth; - const int &depth() const; }; -- cgit v1.2.3-70-g09d2