From df0b1f1fdbe92de3f71275e07085135acd231cf5 Mon Sep 17 00:00:00 2001
From: bobarna <barnabas.borcsok@gmail.com>
Date: Sat, 18 Apr 2020 22:06:55 +0200
Subject: [PATCH] todo: sun and sampling

---
 raytrace.cpp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/raytrace.cpp b/raytrace.cpp
index dd1fed5..ccfcd04 100644
--- a/raytrace.cpp
+++ b/raytrace.cpp
@@ -305,12 +305,12 @@ class Scene {
     vec3 La;
 public:
     void build() {
-        vec3 eye = vec3(0, 3.0f, 3.0f), vup = vec3(0, 0, 1), lookat = vec3(0, 0, 0);
+        vec3 eye = vec3(0.0, 1.8f, 0.0f), vup = vec3(0, 0, 1), lookat = vec3(0, 0, 0);
         float fov = 80 * M_PI / 180;
         camera.set(eye, lookat, vup, fov);
 
         //LIGHTING
-        La = vec3(0.2f, 0.2f, 0.8f);
+        La = vec3(0.2f, 0.2f, 0.4f);
         vec3 lightDirection(3, 2, 2), Le(1, 1, 1);
         lights.push_back(new Light(lightDirection, Le));
 
@@ -335,8 +335,10 @@ public:
         roomEllipsoid->intersectors.push_back(topHolePlane);
 
         //BUILDING THE LIGHT "TUBE"
-        Quadric *lightTube = new Hyperboloid(0.5f, 0.5f, 0.65f, materialSilver);
+        Quadric *lightTube = new Hyperboloid(0.6f, 0.6f, 0.3f, materialSilver);
+        lightTube->Scale(1,1,10.0f);
         lightTube->intersectors.push_back(new Plane(vec3(0.0f, 0.0f, 0.95f), vec3(0.0f, 0.0f, -1.0f), materialCylinder));
+        lightTube->intersectors.push_back(new Plane(vec3(0.0f, 0.0f, 4.0f), vec3(0.0f, 0.0f, 1.0f), materialCylinder));
 
         // BULDING THE BLUE CYLINDER
         Quadric *cylinder = new Cylinder(0.4f, 0.4f, materialCylinder);
@@ -356,12 +358,12 @@ public:
         vial->Translate(0.8f, 0.3f, 0.0f);
 
         // INSERTING THE OBJECTS INTO THE ROOM
-        //objects.push_back(roomEllipsoid);
+        objects.push_back(roomEllipsoid);
         objects.push_back(lightTube);
-        //objects.push_back(cylinder);
-        //objects.push_back(paraboloid);
-        //objects.push_back(vial);
-        //objects.push_back(new Sphere(vec3(0,0,0), 0.1f, materialCylinder));
+        objects.push_back(cylinder);
+        objects.push_back(paraboloid);
+        objects.push_back(vial);
+//        objects.push_back(new Sphere(vec3(0,0,0), 0.1f, materialCylinder));
     }
 
     void render(std::vector<vec4> &image) {
@@ -401,6 +403,7 @@ public:
         if (hit.material->type == ROUGH) {
             outRadiance = hit.material->ka * La;
             for (Light *light : lights) {
+                // TODO: sampling points from the hole on the top of the room
                 Ray shadowRay(hit.position + hit.normal * epsilon, light->direction);
                 float cosTheta = dot(hit.normal, light->direction);
                 if (cosTheta > 0 && !shadowIntersect(shadowRay)) {    // shadow computation
-- 
GitLab