title: Direct3D 9 Shadow Mapping Blend Mode
body: <p>I am currently trying to draw shadows over a scene in direct3d 9. I am trying to do some multi pass rendering and am having trouble understanding how to use/set the blend mode.</p>
  
  <p>I have done a depth pass which fills the depth buffer and I then have a loop which loops through all the lights in the scene. Within that loop I have 2 loops which both loop through all the shapes in the scene</p>
  
  <p>I have this sort of set up</p>
  
  <pre><code>for(number of shapes)
  {
    //render from camera position and fill depth buffer
  }
  for(number of lights)
  {
    for(number of shapes)
    {
      //render to shadow map
    }
    for(number of shapes)
    {
      //render to screen
    }
  }
  </code></pre>
  
  <p>In pix I can see that it loops through each light but when I run it only the last light in the light array is displayed. I think it is something to do with the blend mode.</p>
  
  <p>I have looked into the blend mode and found information about source and destination blend. Is this what I need/could someone help explain it please?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Mark</p>
  
  <p>[<strong>EDIT</strong>]
  I got both lights visible using the following code</p>
  
  <pre><code>hr = device-&gt;SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
  hr = device-&gt;SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
  hr = device-&gt;SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
  </code></pre>
  
  <p>The shadows do not look correct but I am getting closer to the desired result.</p>
  
  <p>Any more advice would be great,</p>
  
  <p>Thanks,</p>
  
  <p>Mark</p>