Home › Forums › GAMES在线课程(现代计算机图形学入门)讨论区 › 作业7全黑(只有光源)问题
Tagged: 回答
- This topic has 1 reply, 2 voices, and was last updated 2 years, 1 month ago by Cisco.
Viewing 1 reply thread
-
AuthorPosts
-
-
nebulaParticipant
Vector3f Scene::castRay(const Ray &ray, int depth) const { // TO DO Implement Path Tracing Algorithm here Vector3f result(0.0f); Intersection wo_inter = intersect(ray); if (!wo_inter.happened) { return result; } // 有光源直接用 if (wo_inter.m->hasEmission()) { return wo_inter.m->getEmission(); } Intersection ws_inter; float pdf; sampleLight(ws_inter, pdf); Vector3f p = wo_inter.coords; Vector3f x = ws_inter.coords; Vector3f wo = ray.direction; Vector3f ws = (x - p).normalized(); Vector3f N = wo_inter.normal.normalized(); Vector3f NN = ws_inter.normal.normalized(); Vector3f emit = ws_inter.emit; float ws_distance = (x - p).norm(); Ray incoming(p, ws); Intersection in_intersection = intersect(incoming); Vector3f l_dir; if(in_intersection.distance - ws_distance >= -EPSILON){ l_dir = emit * wo_inter.m->eval(wo, ws, N) * dotProduct(ws, N) * dotProduct(-ws, NN) / (ws_distance * ws_distance) / pdf; // std::cout << l_dir << std::endl; } // if(get_random_float() > RussianRoulette) { // return l_dir; // } Vector3f l_indir; // Vector3f wi_dir = wo_inter.m->sample(wo, N).normalized(); // Ray wi_ray(wo_inter.coords, wi_dir); // Intersection wi_inter = intersect(wi_ray); // if (wi_inter.happened && (!wi_inter.m->hasEmission())) { // l_indir = castRay(wi_ray, depth + 1) * wo_inter.m->eval(ray.direction, wi_ray.direction, N) // * dotProduct(wi_ray.direction, N) // / wo_inter.m->pdf(ray.direction, wi_ray.direction, N) // / RussianRoulette; // } return l_dir + l_indir; }
只做了直接光照,光源是直接投到了观察方向才有展示,看了比较久没发现什么原因。。
-
CiscoParticipant
IntersectP(const Ray& ray, const Vector3f& invDir, const std::array<int, 3>& dirIsNeg) in the Bounds3.hpp:
这个函数的作用是判断包围盒 BoundingBox 与光线是否相交,请直接将上次实验中实现的内容粘贴在此处,并且注意检查 t_enter = t_exit 的时候的判断是否正确。
-
-
AuthorPosts
Viewing 1 reply thread
- You must be logged in to reply to this topic.