diff --git a/Step 2/cmake-build-debug/.ninja_deps b/Step 2/cmake-build-debug/.ninja_deps index 3169da8..a8c024a 100644 Binary files a/Step 2/cmake-build-debug/.ninja_deps and b/Step 2/cmake-build-debug/.ninja_deps differ diff --git a/Step 2/cmake-build-debug/.ninja_log b/Step 2/cmake-build-debug/.ninja_log index d23e4bb..b4a75e2 100644 --- a/Step 2/cmake-build-debug/.ninja_log +++ b/Step 2/cmake-build-debug/.ninja_log @@ -24,3 +24,9 @@ 1 762 1665980918014947659 CMakeFiles/Step_2.dir/src/raytracing.cpp.o cfda37b51895cd7e 1 792 1665980918042948384 CMakeFiles/Step_2.dir/src/main.cpp.o 2fb1ddffcef25127 792 853 1665980918102949937 Step_2 513d6b5f7b82bcb +0 1054 1666014553412325352 CMakeFiles/Step_2.dir/src/raytracing.cpp.o cfda37b51895cd7e +1054 1110 1666014553468326760 Step_2 513d6b5f7b82bcb +1 769 1666014587269182037 CMakeFiles/Step_2.dir/src/raytracing.cpp.o cfda37b51895cd7e +769 823 1666014587321183357 Step_2 513d6b5f7b82bcb +0 764 1666014713416442097 CMakeFiles/Step_2.dir/src/raytracing.cpp.o cfda37b51895cd7e +764 819 1666014713468443463 Step_2 513d6b5f7b82bcb diff --git a/Step 2/cmake-build-debug/CMakeFiles/Step_2.dir/src/raytracing.cpp.o b/Step 2/cmake-build-debug/CMakeFiles/Step_2.dir/src/raytracing.cpp.o index e8b2f56..f29b423 100644 Binary files a/Step 2/cmake-build-debug/CMakeFiles/Step_2.dir/src/raytracing.cpp.o and b/Step 2/cmake-build-debug/CMakeFiles/Step_2.dir/src/raytracing.cpp.o differ diff --git a/Step 2/cmake-build-debug/Step_2 b/Step 2/cmake-build-debug/Step_2 index d90ba59..8be2b5b 100755 Binary files a/Step 2/cmake-build-debug/Step_2 and b/Step 2/cmake-build-debug/Step_2 differ diff --git a/Step 2/cmake-build-debug/Testing/Temporary/LastTest.log b/Step 2/cmake-build-debug/Testing/Temporary/LastTest.log index 9ca65d5..bd6749b 100644 --- a/Step 2/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/Step 2/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Oct 17 00:29 EDT +Start testing: Oct 17 09:51 EDT ---------------------------------------------------------- -End testing: Oct 17 00:29 EDT +End testing: Oct 17 09:51 EDT diff --git a/Step 2/cmake-build-debug/test.png b/Step 2/cmake-build-debug/test.png index a2e8c21..a753a57 100644 Binary files a/Step 2/cmake-build-debug/test.png and b/Step 2/cmake-build-debug/test.png differ diff --git a/Step 2/include/raytracing.h b/Step 2/include/raytracing.h index 75432d2..19a70c5 100644 --- a/Step 2/include/raytracing.h +++ b/Step 2/include/raytracing.h @@ -70,7 +70,7 @@ namespace Raytracing { World& world; Random rnd{-1, 1}; - vec4 randomInSphere() { + vec4 randomUnitVector() { // there are two methods to generating a random unit sphere // one which is fast and approximate: //auto v = vec4(rnd.getDouble(), rnd.getDouble(), rnd.getDouble()); @@ -85,6 +85,14 @@ namespace Raytracing { // the second creates better results but is 18% slower (better defined shadows) // likely due to not over generating unit vectors biased towards the corners } + // unused but provides another method of diffuse rendering + vec4 randomUnitHemisphere(const vec4& normal){ + vec4 v = randomUnitVector().normalize(); + if (vec4::dot(v, normal) > 0.0) + return v; + else + return -v; + } vec4 raycast(const Ray& ray, int depth); public: diff --git a/Step 2/src/main.cpp b/Step 2/src/main.cpp index fde3b06..bdb8cc6 100644 --- a/Step 2/src/main.cpp +++ b/Step 2/src/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char** args) { // not perfect (contains duplicates) but good enough. parser.printAllInInfo(); - Raytracing::Image image(256, 256); + Raytracing::Image image(445, 256); Raytracing::Camera camera(90, image); //camera.lookAt(Raytracing::vec4(0,1,0), Raytracing::vec4(0, 0, -1), Raytracing::vec4(0, 1, 0)); diff --git a/Step 2/src/raytracing.cpp b/Step 2/src/raytracing.cpp index cec5d6a..837a225 100644 --- a/Step 2/src/raytracing.cpp +++ b/Step 2/src/raytracing.cpp @@ -38,8 +38,6 @@ namespace Raytracing { // TODO: profile for speed; for (int s = 0; s < raysPerPixel; s++){ // simulate anti aliasing by generating rays with very slight random directions - // TODO: this should be updated with a [-1, 1] generator as this currently only produces [0, 1] - // and therefore lacks true aliasing color = color + raycast(camera.projectRay(i + rnd.getDouble(), j + rnd.getDouble()), 0); } PRECISION_TYPE sf = 1.0 / raysPerPixel; @@ -57,10 +55,10 @@ namespace Raytracing { if (hit.hit) { // randomly cast our bounce rays to simulate diffuse lighting - vec4 newRay = hit.hitPoint + hit.normal + randomInSphere(); + vec4 newRay = hit.normal + randomUnitVector().normalize(); // recursion is the only good way to do this // TODO: maybe without the recursion, clang tidy is annoying me. - return 0.5* raycast({hit.hitPoint, newRay - hit.hitPoint}, depth + 1); + return 0.5* raycast({hit.hitPoint, newRay}, depth + 1); } vec4 dir = ray.getDirection().normalize();