Minor changes.
This commit is contained in:
@@ -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 {
|
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);
|
||||||
}
|
}
|
||||||
|
BIN
output.png
BIN
output.png
Binary file not shown.
Before Width: | Height: | Size: 542 KiB After Width: | Height: | Size: 537 KiB |
@@ -37,7 +37,7 @@ vec3 PathTracer::trace_ray(Ray & r, vector<Figure *> & v_figures, vector<Light *
|
|||||||
n = _f->normal_at_int(r, t);
|
n = _f->normal_at_int(r, t);
|
||||||
|
|
||||||
// Check if the material is not reflective/refractive.
|
// Check if the material is not reflective/refractive.
|
||||||
if( !_f->m_mat.m_refract) {
|
if (!_f->m_mat.m_refract) {
|
||||||
// Calculate the direct lighting.
|
// Calculate the direct lighting.
|
||||||
for (size_t l = 0; l < v_lights.size(); l++) {
|
for (size_t l = 0; l < v_lights.size(); l++) {
|
||||||
// For every light source
|
// For every light source
|
||||||
@@ -88,7 +88,7 @@ vec3 PathTracer::trace_ray(Ray & r, vector<Figure *> & v_figures, vector<Light *
|
|||||||
amb_color = vis ? BCKG_COLOR * max(dot(n, rr.m_direction), 0.0f) / PDF : vec3(0.0f);
|
amb_color = vis ? BCKG_COLOR * max(dot(n, rr.m_direction), 0.0f) / PDF : vec3(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
color += ((dir_diff_color + ind_color + amb_color) * (_f->m_mat.m_diffuse / pi<float>())) + dir_spec_color;
|
color += ((dir_diff_color + ind_color + amb_color) * (_f->m_mat.m_diffuse / pi<float>())) + (_f->m_mat.m_diffuse * dir_spec_color);
|
||||||
|
|
||||||
// Determine the specular reflection color.
|
// Determine the specular reflection color.
|
||||||
if (_f->m_mat.m_rho > 0.0f && rec_level < MAX_RECURSION) {
|
if (_f->m_mat.m_rho > 0.0f && rec_level < MAX_RECURSION) {
|
||||||
|
@@ -40,5 +40,5 @@ vec3 PointLight::specular(vec3 normal, Ray & r, vec3 i_pos, Material & m) const
|
|||||||
l_dir = normalize(l_dir);
|
l_dir = normalize(l_dir);
|
||||||
att = 1.0f / (m_const_att + (m_lin_att * d) + (m_quad_att * (d * d)));
|
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);
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ vec3 WhittedTracer::trace_ray(Ray & r, vector<Figure *> & v_figures, vector<Ligh
|
|||||||
n = _f->normal_at_int(r, t);
|
n = _f->normal_at_int(r, t);
|
||||||
|
|
||||||
// Check if the material is not reflective/refractive.
|
// Check if the material is not reflective/refractive.
|
||||||
if( !_f->m_mat.m_refract) {
|
if (!_f->m_mat.m_refract) {
|
||||||
// Calculate the direct lighting.
|
// Calculate the direct lighting.
|
||||||
for (size_t l = 0; l < v_lights.size(); l++) {
|
for (size_t l = 0; l < v_lights.size(); l++) {
|
||||||
// For every light source
|
// For every light source
|
||||||
@@ -55,7 +55,7 @@ vec3 WhittedTracer::trace_ray(Ray & r, vector<Figure *> & v_figures, vector<Ligh
|
|||||||
dir_spec_color += vis ? v_lights[l]->specular(n, r, i_pos, _f->m_mat) : vec3(0.0f);
|
dir_spec_color += vis ? v_lights[l]->specular(n, r, i_pos, _f->m_mat) : vec3(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
color += (dir_diff_color * (_f->m_mat.m_diffuse / pi<float>())) + dir_spec_color;
|
color += (dir_diff_color * (_f->m_mat.m_diffuse / pi<float>())) + (_f->m_mat.m_diffuse * dir_spec_color);
|
||||||
|
|
||||||
// Determine the specular reflection color.
|
// Determine the specular reflection color.
|
||||||
if (_f->m_mat.m_rho > 0.0f && rec_level < MAX_RECURSION) {
|
if (_f->m_mat.m_rho > 0.0f && rec_level < MAX_RECURSION) {
|
||||||
|
Reference in New Issue
Block a user