diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/accelerate/myqtconcurrent.cpp | 32 | ||||
-rw-r--r-- | src/illuminate/illuminate.cpp | 1 | ||||
-rw-r--r-- | src/intersect/intersect.cpp | 2 | ||||
-rw-r--r-- | src/vec4ops/vec4ops.cpp | 2 |
4 files changed, 23 insertions, 14 deletions
diff --git a/src/accelerate/myqtconcurrent.cpp b/src/accelerate/myqtconcurrent.cpp index 259fba3..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::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) { diff --git a/src/illuminate/illuminate.cpp b/src/illuminate/illuminate.cpp index a093fd1..39ecccb 100644 --- a/src/illuminate/illuminate.cpp +++ b/src/illuminate/illuminate.cpp @@ -1,3 +1,4 @@ +#include <iostream> #include "raytracer/raytracer.h" glm::vec4 RayTracer::illuminationFromPointLight( diff --git a/src/intersect/intersect.cpp b/src/intersect/intersect.cpp index 353508e..69512e3 100644 --- a/src/intersect/intersect.cpp +++ b/src/intersect/intersect.cpp @@ -1,3 +1,4 @@ +#include <iostream> #include "raytracer/raytracer.h" /** @@ -28,6 +29,7 @@ glm::vec4 intersectCircle( return glm::vec4(0.f); } + float t1 = (-b - std::sqrt(discriminant)) / (2.f*a); float t2 = (-b + std::sqrt(discriminant)) / (2.f*a); if (t1 <= 0 && t2 <= 0) // both behind camera diff --git a/src/vec4ops/vec4ops.cpp b/src/vec4ops/vec4ops.cpp index cf0900a..3ef939a 100644 --- a/src/vec4ops/vec4ops.cpp +++ b/src/vec4ops/vec4ops.cpp @@ -37,7 +37,7 @@ glm::mat4 Vec4Ops::getViewMatrix4( glm::vec4 upVector, glm::vec4 overVector) { // start with the e3 basis vector, the normalized look vector - glm::vec4 e3 = glm::normalize(-lookVector); + glm::vec4 e3 = glm::normalize(lookVector); // calculate e0 basis vector, from the combinatory cross of up and over with e3 glm::vec4 e0 = cross4(upVector, overVector, e3); |