sun.fx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //-----------------------------------------------------------------------------
  2. // Sun.fx
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. //Input variables
  8. float4x4 world;
  9. float4x4 worldViewProjection;
  10. float blendFactor;
  11. texture Sun_Tex0;
  12. sampler Sun0 = sampler_state
  13. {
  14. Texture = (Sun_Tex0);
  15. ADDRESSU = CLAMP;
  16. ADDRESSV = CLAMP;
  17. MAGFILTER = LINEAR;
  18. MINFILTER = LINEAR;
  19. MIPFILTER = LINEAR;
  20. };
  21. texture Sun_Tex1;
  22. sampler Sun1 = sampler_state
  23. {
  24. Texture = (Sun_Tex1);
  25. ADDRESSU = CLAMP;
  26. ADDRESSV = CLAMP;
  27. MAGFILTER = LINEAR;
  28. MINFILTER = LINEAR;
  29. MIPFILTER = LINEAR;
  30. };
  31. struct VS_OUTPUT
  32. {
  33. float4 Pos: POSITION;
  34. float2 tex: TEXCOORD0;
  35. float2 tex1: TEXCOORD1;
  36. };
  37. VS_OUTPUT SunVS(float4 Pos: POSITION)
  38. {
  39. VS_OUTPUT Out;
  40. //Move to screen space
  41. Out.Pos = mul(Pos, worldViewProjection);
  42. //Texture coords deduced from postion
  43. Out.tex = Pos.xy;
  44. Out.tex1 = Pos.xy;
  45. return Out;
  46. }
  47. float4 SunPS( float2 tex: TEXCOORD0, float2 tex1: TEXCOORD1 ) : COLOR
  48. {
  49. float4 color0 = tex2D(Sun0, tex);
  50. float4 color1 = tex2D(Sun1, tex1);
  51. float4 color = saturate( (color0 * blendFactor) + (color1 * (1.0f - blendFactor)) );
  52. return color;
  53. }
  54. //--------------------------------------------------------------//
  55. // Technique Section for Sun Effects
  56. //--------------------------------------------------------------//
  57. technique Sun
  58. {
  59. pass Single_Pass
  60. {
  61. CULLMODE = NONE;
  62. ALPHABLENDENABLE = TRUE;
  63. SRCBLEND = SRCALPHA;
  64. DESTBLEND = INVSRCALPHA;
  65. ZENABLE = FALSE; //Always want this on top
  66. VertexShader = compile vs_1_1 SunVS();
  67. PixelShader = compile ps_2_0 SunPS();
  68. }
  69. }