diff --git a/directional_light.cpp b/directional_light.cpp index 7653087..d069014 100644 --- a/directional_light.cpp +++ b/directional_light.cpp @@ -25,5 +25,5 @@ vec3 DirectionalLight::diffuse(vec3 normal, Ray & r, vec3 i_pos, Material & m) c } vec3 DirectionalLight::specular(vec3 normal, Ray & r, vec3 i_pos, Material & m) const { - return m.m_specular * m_brdf->specular(m_position, normal, r, m_specular, m.m_shininess); + return m_brdf->specular(m_position, normal, r, m_specular, m.m_shininess); } diff --git a/output.png b/output.png index 390a4be..13cba99 100644 Binary files a/output.png and b/output.png differ diff --git a/path_tracer.cpp b/path_tracer.cpp index e4d76d5..72d2d87 100644 --- a/path_tracer.cpp +++ b/path_tracer.cpp @@ -37,7 +37,7 @@ vec3 PathTracer::trace_ray(Ray & r, vector
& v_figures, vectornormal_at_int(r, t); // Check if the material is not reflective/refractive. - if( !_f->m_mat.m_refract) { + if (!_f->m_mat.m_refract) { // Calculate the direct lighting. for (size_t l = 0; l < v_lights.size(); l++) { // For every light source @@ -88,7 +88,7 @@ vec3 PathTracer::trace_ray(Ray & r, vector
& v_figures, vectorm_mat.m_diffuse / pi())) + dir_spec_color; + color += ((dir_diff_color + ind_color + amb_color) * (_f->m_mat.m_diffuse / pi())) + (_f->m_mat.m_diffuse * dir_spec_color); // Determine the specular reflection color. if (_f->m_mat.m_rho > 0.0f && rec_level < MAX_RECURSION) { diff --git a/point_light.cpp b/point_light.cpp index 9aaa305..5d07554 100644 --- a/point_light.cpp +++ b/point_light.cpp @@ -40,5 +40,5 @@ vec3 PointLight::specular(vec3 normal, Ray & r, vec3 i_pos, Material & m) const l_dir = normalize(l_dir); att = 1.0f / (m_const_att + (m_lin_att * d) + (m_quad_att * (d * d))); - return att * m.m_specular * m_brdf->specular(l_dir, normal, r, m_specular, m.m_shininess); + return att * m_brdf->specular(l_dir, normal, r, m_specular, m.m_shininess); } diff --git a/whitted_tracer.cpp b/whitted_tracer.cpp index 8fbaf05..b2f4e3b 100644 --- a/whitted_tracer.cpp +++ b/whitted_tracer.cpp @@ -35,7 +35,7 @@ vec3 WhittedTracer::trace_ray(Ray & r, vector
& v_figures, vectornormal_at_int(r, t); // Check if the material is not reflective/refractive. - if( !_f->m_mat.m_refract) { + if (!_f->m_mat.m_refract) { // Calculate the direct lighting. for (size_t l = 0; l < v_lights.size(); l++) { // For every light source @@ -55,7 +55,7 @@ vec3 WhittedTracer::trace_ray(Ray & r, vector
& v_figures, vectorspecular(n, r, i_pos, _f->m_mat) : vec3(0.0f); } - color += (dir_diff_color * (_f->m_mat.m_diffuse / pi())) + dir_spec_color; + color += (dir_diff_color * (_f->m_mat.m_diffuse / pi())) + (_f->m_mat.m_diffuse * dir_spec_color); // Determine the specular reflection color. if (_f->m_mat.m_rho > 0.0f && rec_level < MAX_RECURSION) {