title: How can I create a drop shadow effect on my textures in XNA for Windows Phone?
body: <p>I'm writing a simple 2D game for Windows Phone 7 using the XNA Framework.</p>
  
  <p>Basically there are multiple items that the user can drag. I create their texture dynamically by drawing stuff on a <code>RenderTarget2D</code> and then just draw the <code>RenderTarget2D</code> afterwards. I use the <em>stencil buffer</em> to draw a part of a bigger texture onto the render target.</p>
  
  <p><strong>Code snippet</strong></p>
  
  <pre><code>util.GraphicsDevice.SetRenderTarget(result);
  util.GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.Stencil | ClearOptions.DepthBuffer, Color.Transparent, 0, 0);
  
  // The "mask"
  
  spriteBatch.Begin(SpriteSortMode.Deferred, util.DontWriteColorsState, null, util.StencilAlways, null, alphaTestEffect);
  spriteBatch.Draw(maskTexture, destination, Color.White);
  spriteBatch.End();
  
  // The actual texture
  
  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, util.StencilKeepWhere1, null, alphaTestEffect);
  spriteBatch.Draw(bigTexture, destination, source, Color.White);
  spriteBatch.End();
  
  util.GraphicsDevice.SetRenderTarget(null);
  </code></pre>
  
  <p><em>(<code>util</code> is just an instance of a helper class which I use in order to not have to copy-paste the same code everywhere, it contains the <code>DepthStencilState</code> objects and some other stuff.)</em></p>
  
  <p>I would like to create a drop shadow effect behind these textures. I'd like to draw the shadow on the render target.</p>
  
  <p>Unfortunately Windows Phone 7 doesn't support custom shader effects so I can't use any examples from the internet. So I decided to try to implement it in software. But I'm completely inexperienced with this kind of thing, so the result was both slow and ugly.</p>
  
  <p>What I did in software was this:</p>
  
  <ul>
  <li>Created a stroke around the mask texture and drew it with a low opacity</li>
  <li>Created a stroke around the previous stroke and drew it with a low opacity</li>
  <li>... This step was repeated the same number of times as the size of the drop shadow</li>
  </ul>
  
  <p>However, it was VERY slow and basically unacceptably slow.</p>
  
  <p><strong>So the question is</strong></p>
  
  <p>Is it possible to create a dropshadow or a dropshadow-ish effect using the built-in effects in XNA? Also, if not, is there an algorithm that can create a nice-looking drop shadow in software?</p>
  
  <p>Thanks in advance for your answers! :)</p>
  
  <p>EDIT:</p>
  
  <p>I'm taking about this kind of drop shadow:<br>
  <img src="https://i.stack.imgur.com/qTK9b.png" alt="Drop shadow effect"></p>
  
  <p>Obviously, this is just an illustration, I don't want it to be exactly this size. :)</p>