From b2917e704872a7eea802bd645cce32cefb39957b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20T=C3=B3th?= <tothmiklostibor@gmail.com> Date: Thu, 15 Apr 2021 19:56:46 +0200 Subject: [PATCH] actually actually positional light --- Skeleton.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Skeleton.cpp b/Skeleton.cpp index 90d6d9f..0535868 100644 --- a/Skeleton.cpp +++ b/Skeleton.cpp @@ -203,7 +203,7 @@ struct Light { float getDistance(const vec3& point) const { vec3 d = point - position; - return sqrtf(dot(d, d)); + return length(d); } }; @@ -288,8 +288,8 @@ public: if (hit.material->type == ROUGH) { outRadiance = hit.material->ka * La; for (Light *light : lights) { - Ray shadowRay(hit.position + hit.normal * epsilon, light->position); - float cosTheta = dot(hit.normal, light->position); + auto cosTheta = dot(hit.normal, light->getDirection(hit.position)); + Ray shadowRay(hit.position + hit.normal * epsilon, light->getDirection(hit.position)); if (cosTheta > 0 && !shadowIntersect(shadowRay, light)) { // shadow computation vec3 le = light->Le / powf(light->getDistance(hit.position), 2); outRadiance = outRadiance + le * hit.material->kd * cosTheta; @@ -438,6 +438,6 @@ void onMouseMotion(int pX, int pY) { // Idle event indicating that some time elapsed: do animation here void onIdle() { - scene.Animate(.1f); + scene.Animate(.05f); glutPostRedisplay(); } -- GitLab