+ HitPoint shadow_hit;
+ vec3 ldir = light_pos - hit.pos;
+
+ vec3 col = vec3(0.03, 0.03, 0.03); // ambient
+
+ if(!isect_scene(hit.pos + hit.norm * 0.01, ldir, shadow_hit) || shadow_hit.dist > 1.0) {
+ vec3 l = normalize(ldir);
+ vec3 v = normalize(-rd);
+ vec3 h = normalize(v + l);
+ float ndotl = max(dot(hit.norm, l), 0.0);
+ float ndoth = max(dot(hit.norm, h), 0.0);
+
+ col += hit.mtl.diffuse * ndotl + hit.mtl.specular * pow(ndoth, hit.mtl.shin);
+ }
+
+ return col;