title: Ray Tracing Noise
body: <p>I was wondering if someone with ray tracing experience could help me figure out a couple problems in my program, however I cannot post much code as this program is a school assignment. I was just wondering if I could get some tips that could help steer me in the right direction. So thanks in advance!</p>
  
  <p>First) As you can see, there's a ton of noise in my ray tracing image below. The scene consists of a single triangle hovering over a plane. There also exists a single point-light source.</p>
  
  <p>Second) The noise doesn't occur when I compute shadow rays, however it calculates the wrong color for the shadow. </p>
  
  <p>My ray-tracing algorithm:</p>
  
  <pre><code>for each pixel,
      color c;
      for each shape in the scene
          send a ray through each pixel and see if it collides with a shape
          if it does
              color = calculate color of ray
          else, color = background color
      return color
  
  To calculate color of ray...
      color c = 0,0,0 // rgb
      for each light source in the scene
          make a new ray (shad_ray) that starts at where the original ray hit the shape...
          ... and ends at the light source
          see if the shadow ray hits a shape on its way to the light
          if it does, 
              calculate ambient color using ambient color of shape material and...
              ... ambient light intensity 
          if not,
              calculate shading with sum of ambient/diffuse/specular components 
  </code></pre>
  
  <p>I know that's a really loose description of the algorithm. But I can provide more info if needed.</p>
  
  <p><img src="https://i.stack.imgur.com/RZZ2U.png" alt="Bad ray tracing &lt;/3"></p>