title: HLSL water refraction shader
body: <p>I'm currently working on a water rendering project with XNA (DirectX9) and I spend a lot of time on a problem that I don't understand.</p>
  
  <p>In my project, I render a terrain and an horizontal plane that represent the water. I'm currently trying to create the refractive texture that I will apply to this plane. To do that, I used a render target in which I render the part of the terrain that is under the water plane (clipping => into my HLSL file, during pixel shader operation). I transform this render target into a texture that I apply directly on the water plane.</p>
  
  <p>The result that I would like to have is exactly the same than if I didn't draw the water plane, I just want to see the terrain that is under the water (no light beam deviation for the moment). But for now, I have a very strange result. I record some video to show you, it's better than any explanations: <a href="http://www.youtube.com/watch?v=XGesGvEnAEg" rel="nofollow">http://www.youtube.com/watch?v=XGesGvEnAEg</a></p>
  
  <p>Here is the code of the HLSL file of refraction: <a href="https://gist.github.com/Noxalus/8213296" rel="nofollow">https://gist.github.com/Noxalus/8213296</a></p>
  
  <p>Do you know from where the problem come from?</p>
  
  <p>Thanks in advance for your help!</p>