refraction.fx 877 B

123456789101112131415161718192021222324252627282930
  1. // Effect uses a scrolling displacement texture to offset the position of the main
  2. // texture. Depending on the contents of the displacement texture, this can give a
  3. // wide range of refraction, rippling, warping, and swirling type effects.
  4. float2 DisplacementScroll;
  5. sampler TextureSampler : register(s0);
  6. sampler DisplacementSampler : register(s1);
  7. float4 main(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
  8. {
  9. // Look up the displacement amount.
  10. float2 displacement = tex2D(DisplacementSampler, DisplacementScroll + texCoord / 3);
  11. // Offset the main texture coordinates.
  12. texCoord += displacement * 0.2 - 0.15;
  13. // Look up into the main texture.
  14. return tex2D(TextureSampler, texCoord) * color;
  15. }
  16. technique Refraction
  17. {
  18. pass Pass1
  19. {
  20. PixelShader = compile ps_2_0 main();
  21. }
  22. }