diff options
Diffstat (limited to 'src/accelerate/myqtconcurrent.cpp')
-rw-r--r-- | src/accelerate/myqtconcurrent.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/accelerate/myqtconcurrent.cpp b/src/accelerate/myqtconcurrent.cpp index 9f51cdd..12e9138 100644 --- a/src/accelerate/myqtconcurrent.cpp +++ b/src/accelerate/myqtconcurrent.cpp @@ -1,6 +1,7 @@ #include <QList> #include <QtConcurrent> +#include <iostream> #include "../raytracer/raytracer.h" #include "../vec4ops/vec4ops.h" #include "settings.h" @@ -48,21 +49,29 @@ void RayTracer::renderParallel(RGBA *imageData, const RayTraceScene &scene) // 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.width()/2.f) * viewplaneDepth / scene.width(); + float z = (imageDepth - scene.depth()/2.f) * viewplaneDepth / scene.depth(); glm::vec4 pWorld = Vec4Ops::transformPoint4(glm::vec4(0.f), camera.getViewMatrix(), camera.getTranslationVector()); - glm::vec4 dWorld = Vec4Ops::inverseTransformDir4(glm::vec4(x, y, z, -1.0), camera.getViewMatrix()); + glm::vec4 dWorld = Vec4Ops::transformDir4(glm::vec4(x, y, z, -1.0), camera.getViewMatrix()); // get the pixel color glm::vec4 pixelColor = getPixelFromRay(pWorld, dWorld, scene, 0); + if (pixelColor.r > 0) { + std::cout << "pixelColor.r: " << pixelColor.r << ", x" << imageCol << ", y" << imageRow << ", z" << imageDepth << std::endl; + } + // set the pixel color - int index = imageRow * scene.width() + imageCol; - imageData[index] = RGBA{ - (std::uint8_t) (pixelColor.r * 255.f), - (std::uint8_t) (pixelColor.g * 255.f), - (std::uint8_t) (pixelColor.b * 255.f), - (std::uint8_t) (pixelColor.a * 255.f) - }; + if (imageDepth == 250) + { + int index = imageRow * scene.width() + imageCol; + imageData[index] = RGBA{ + (std::uint8_t) (pixelColor.r * 255.f), + (std::uint8_t) (pixelColor.g * 255.f), + (std::uint8_t) (pixelColor.b * 255.f), + (std::uint8_t) (pixelColor.a * 255.f) + }; + } + } } } @@ -72,11 +81,8 @@ void RayTracer::renderParallel(RGBA *imageData, const RayTraceScene &scene) // get the slice relating to z == 0 and set it into int the iamge data array // int currentSlice = settings.w + 100.f * (5.f / 2.f); - int currentSlice = 0; - int ptr = currentSlice * scene.width() * scene.height(); - for (int i = 0; i < scene.width() * scene.height(); i++) { - imageData[i] = pixels[ptr + i]; - } + + std::cout << " here " << std::endl; if (m_enableAntiAliasing) { |