title: Direct3D rendering 2D images with "multiply" blending mode and alpha
body: <p>I'm trying to replicate the Photoshop filter multiply with Direct3D. I've been reading and googling about the different render states and I've got the effect almost working. The problem is that it's ignoring the alpha value of the textures.</p>
  
  <p>Here's an image that explains the sitution:</p>
  
  <p><a href="http://www.kloonigames.com/petri/stackoverflow_doesnt_allow_.jpg" rel="noreferrer"><a href="http://www.kloonigames.com/petri/stackoverflow_doesnt_allow_.jpg" rel="noreferrer">http://www.kloonigames.com/petri/stackoverflow_doesnt_allow_.jpg</a></a></p>
  
  <p>I found one solution to this, which was to save the images with no transparency and white background. But I'm not satisfied with this solution. The problem is that I really need to use the alpha value. I want to fade out the images gradually. And I cannot do this if the blending mode is ignoring the alpha value. </p>
  
  <p>So the question is how to render the images with alpha?</p>
  
  <p>Here's the blending mode code:</p>
  
  <pre><code>dev-&gt;SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
  dev-&gt;SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
  dev-&gt;SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);
  </code></pre>
  
  <p><strong>Edit added the SetTextureStageState</strong></p>
  
  <pre><code>dev-&gt;SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
  dev-&gt;SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
  dev-&gt;SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
  dev-&gt;SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
  </code></pre>