Anonymous avatar Anonymous committed fab108a

added specularities

Comments (0)

Files changed (1)

 let rgb_arith_mix (c1:color) (c2:color) (mix:float) : color =
   assert (mix <= 1.0 && mix >= 0.0);
   rgb_sum (rgb_coeff c1 mix) (rgb_coeff c2 (1.0 -. mix))
+let rgb_chop ((r,g,b):color) : color =
+  let chop i = min 255 (max 0 i) in
+  (chop r, chop g, chop b)
 
 let fabs (f:float) : float = if f > 0.0 then f else 0.0 -. f
 let sq x = x *. x 
   in
   let specular_coeff = v3_dot light_reflect_dir ray_norm in
   let specular_color = rgb_coeff light.light_color specular_coeff in
-    rgb_arith_mix specular_color lambert_color surf.albedo
+    rgb_chop (rgb_sum lambert_color (rgb_coeff specular_color surf.albedo))
 
 let handle_ambient (isect:intersection) (ambience:float) : color =
   rgb_coeff (shape_surface isect.obj).surface_color ambience
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.