refraction.fsh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. uniform sampler2D TextureSampler;
  5. uniform sampler2D DisplacementSampler;
  6. uniform vec2 DisplacementScroll;
  7. void main()
  8. {
  9. // place a reference here to TextureSampler so that it is the first texture
  10. vec4 tex2 = texture2D(TextureSampler, gl_TexCoord[0].xy);
  11. // Look up the displacement amount.
  12. vec4 displacement = texture2D(DisplacementSampler, DisplacementScroll + gl_TexCoord[0].xy / 3.0);
  13. // Offset the main texture coordinates.
  14. vec2 offset = gl_TexCoord[0].xy;
  15. offset += displacement.xy * 0.2 - 0.109;
  16. gl_FragColor = texture2D(TextureSampler, offset ) * gl_Color;
  17. }
  18. //float2 DisplacementScroll;
  19. //sampler TextureSampler : register(s0);
  20. //sampler DisplacementSampler : register(s1);
  21. //float4 main(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
  22. //{
  23. // Look up the displacement amount.
  24. // float2 displacement = tex2D(DisplacementSampler, DisplacementScroll + texCoord / 3);
  25. // Offset the main texture coordinates.
  26. // texCoord += displacement * 0.2 - 0.15;
  27. // Look up into the main texture.
  28. // return tex2D(TextureSampler, texCoord) * color;
  29. //}
  30. //technique Refraction
  31. //{
  32. // pass Pass1
  33. // {
  34. // PixelShader = compile ps_2_0 main();
  35. // }
  36. //}