diff --git a/bidirectional_pathtracing.h b/bidirectional_pathtracing.h index 920ba48..d67b715 100644 --- a/bidirectional_pathtracing.h +++ b/bidirectional_pathtracing.h @@ -288,4 +288,4 @@ BidirectionalPathtracingResult bidirectional_pathtracing(const Camera &camera, c }; -#endif \ No newline at end of file +#endif diff --git a/lighttracing.h b/lighttracing.h index 2eace7c..982802b 100644 --- a/lighttracing.h +++ b/lighttracing.h @@ -81,7 +81,8 @@ LighttracingResult generate_vertices_by_lighttracing(const Camera &camera, Rando const Sphere &now_object = spheres[intersection.object_id]; const Hitpoint &hitpoint = intersection.hitpoint; - const Vec orienting_normal = dot(hitpoint.normal , now_ray.dir) < 0.0 ? hitpoint.normal: (-1.0 * hitpoint.normal); // 交差位置の法線(物体からのレイの入出を考慮) + // 交差位置の法線(物体からのレイの入出を考慮) + const Vec orienting_normal = dot(hitpoint.normal , now_ray.dir) < 0.0 ? hitpoint.normal: (-1.0 * hitpoint.normal); const double russian_roulette_probability = russian_roulette(now_object); // ロシアンルーレット if (rnd->next01() >= russian_roulette_probability) { @@ -141,7 +142,9 @@ LighttracingResult generate_vertices_by_lighttracing(const Camera &camera, Rando Vec reflection_dir, refraction_dir; double fresnel_reflectance, fresnel_transmittance; - if (check_refraction(into, hitpoint.position, now_ray.dir, hitpoint.normal, orienting_normal, &reflection_dir, &refraction_dir, &fresnel_reflectance, &fresnel_transmittance)) { + if (check_refraction( + into, hitpoint.position, now_ray.dir, hitpoint.normal, orienting_normal, + &reflection_dir, &refraction_dir, &fresnel_reflectance, &fresnel_transmittance)) { // 屈折 + 反射 if (rnd->next01() < reflection_probability) { // 反射 now_sampled_pdf_omega = 1.0; diff --git a/pathtracing.h b/pathtracing.h index adafcb3..0aaa524 100644 --- a/pathtracing.h +++ b/pathtracing.h @@ -47,7 +47,8 @@ PathtracingResult generate_vertices_by_pathtracing(const Camera &camera, const i const Sphere &now_object = spheres[intersection.object_id]; const Hitpoint &hitpoint = intersection.hitpoint; - const Vec orienting_normal = dot(hitpoint.normal , now_ray.dir) < 0.0 ? hitpoint.normal: (-1.0 * hitpoint.normal); // 交差位置の法線(物体からのレイの入出を考慮) + // 交差位置の法線(物体からのレイの入出を考慮) + const Vec orienting_normal = dot(hitpoint.normal , now_ray.dir) < 0.0 ? hitpoint.normal: (-1.0 * hitpoint.normal); const double russian_roulette_probability = russian_roulette(now_object); // ロシアンルーレットによって、新しい頂点を「実際に」サンプリングし、生成するのかどうかを決定する。 @@ -120,7 +121,9 @@ PathtracingResult generate_vertices_by_pathtracing(const Camera &camera, const i Vec reflection_dir, refraction_dir; double fresnel_reflectance, fresnel_transmittance; - if (check_refraction(into, hitpoint.position, now_ray.dir, hitpoint.normal, orienting_normal, &reflection_dir, &refraction_dir, &fresnel_reflectance, &fresnel_transmittance)) { + if (check_refraction( + into, hitpoint.position, now_ray.dir, hitpoint.normal, orienting_normal, + &reflection_dir, &refraction_dir, &fresnel_reflectance, &fresnel_transmittance)) { // 屈折 + 反射 if (rnd->next01() < reflection_probability) { // 反射 now_sampled_pdf_omega = 1.0; diff --git a/reference_pathtracing.h b/reference_pathtracing.h index b8ee379..6a5e09f 100644 --- a/reference_pathtracing.h +++ b/reference_pathtracing.h @@ -32,11 +32,12 @@ Color radiance_no_recursion(const Ray &ray, Random *rnd) { } pdf *= russian_roulette_probability; - // 影響加算 + // 放射輝度加算 L = L + multiply(weight, now_object.emission) / pdf; const Hitpoint &hitpoint = intersection.hitpoint; - const Vec orienting_normal = dot(hitpoint.normal , now_ray.dir) < 0.0 ? hitpoint.normal: (-1.0 * hitpoint.normal); // 交差位置の法線(物体からのレイの入出を考慮) + // 交差位置の法線(物体からのレイの入出を考慮) + const Vec orienting_normal = dot(hitpoint.normal , now_ray.dir) < 0.0 ? hitpoint.normal: (-1.0 * hitpoint.normal); switch (now_object.reflection_type) { // 完全拡散面 @@ -62,7 +63,9 @@ Color radiance_no_recursion(const Ray &ray, Random *rnd) { Vec reflection_dir, refraction_dir; double fresnel_reflectance, fresnel_transmittance; - if (check_refraction(into, hitpoint.position, now_ray.dir, hitpoint.normal, orienting_normal, &reflection_dir, &refraction_dir, &fresnel_reflectance, &fresnel_transmittance)) { + if (check_refraction( + into, hitpoint.position, now_ray.dir, hitpoint.normal, orienting_normal, + &reflection_dir, &refraction_dir, &fresnel_reflectance, &fresnel_transmittance)) { // 屈折 + 反射 if (rnd->next01() < reflection_probability) { // 反射 now_ray = Ray(hitpoint.position, reflection_dir); @@ -88,7 +91,6 @@ Color radiance_no_recursion(const Ray &ray, Random *rnd) { } break; } } - return L; }