Clouds.fx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //-----------------------------------------------------------------------------
  2. // Clouds.fx
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. // the relative position for the texture coordinates, inducing a slight parallax
  8. float2 Position;
  9. // modify the sampler state on the zero texture sampler, used by SpriteBatch
  10. sampler TextureSampler : register(s0) =
  11. sampler_state
  12. {
  13. AddressU = Wrap;
  14. AddressV = Wrap;
  15. };
  16. float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
  17. {
  18. // sample from the cloud texture for the blue component
  19. texCoord.x += Position.x * 0.00025f;
  20. texCoord.y += Position.y * 0.00025f;
  21. texCoord *= 0.5f;
  22. float4 results = float4(0,0,1,0.25) * tex2D(TextureSampler, texCoord);
  23. // sample from the cloud texture for the green component
  24. texCoord.x += Position.x * 0.00025f + 0.25f;
  25. texCoord.y += Position.y * 0.00025f - 0.15;
  26. texCoord *= 0.4f;
  27. results += float4(0,1,0,0.15) * tex2D(TextureSampler, texCoord);
  28. return results;
  29. }
  30. technique Technique1
  31. {
  32. pass Pass1
  33. {
  34. PixelShader = compile ps_2_0 PixelShaderFunction();
  35. }
  36. }