Added indirect illumination.

This commit is contained in:
2017-01-05 06:16:14 -04:00
parent 3f13372071
commit 96fe34975e
11 changed files with 268 additions and 59196 deletions

View File

@@ -20,12 +20,19 @@ inline float DirectionalLight::distance(vec3 point) {
return numeric_limits<float>::max();
}
vec3 DirectionalLight::shade(vec3 normal, Ray & r, float t, Material & m) const {
float n_dot_l, r_dot_l;
vec3 color, ref;
vec3 DirectionalLight::diffuse(vec3 normal, Ray & r, float t, Material & m) const {
float n_dot_l;
vec3 color;
n_dot_l = max(dot(normal, m_position), 0.0f);
color += (m.m_diffuse / pi<float>()) * m_diffuse * n_dot_l;
color += m_diffuse * n_dot_l;
return color;
}
vec3 DirectionalLight::specular(vec3 normal, Ray & r, float t, Material & m) const {
float r_dot_l;
vec3 color, ref;
ref = reflect(m_position, normal);
r_dot_l = pow(max(dot(ref, r.m_direction), 0.0f), m.m_shininess);