FXBeamHit.fx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. //////////////////////////////////////////////////////////////////////////////
  2. // ©2005 Electronic Arts Inc
  3. //
  4. // FX Shader for shadow map debugging
  5. //////////////////////////////////////////////////////////////////////////////
  6. #include "Common.fxh"
  7. #include "CommonParticle.fxh"
  8. #if !defined(USE_INDIRECT_CONSTANT)
  9. float OpacityOverride
  10. <
  11. string UIWidget = "None";
  12. string SasBindAddress = "WW3D.OpacityOverride";
  13. > = 1.0;
  14. #endif // #if !defined(USE_INDIRECT_CONSTANT)
  15. SAMPLER_2D_BEGIN( BaseTexture,
  16. string UIName = "Base Texture";
  17. )
  18. MinFilter = Linear;
  19. MagFilter = Linear;
  20. MipFilter = Linear;
  21. AddressU = Mirror;
  22. AddressV = Mirror;
  23. SAMPLER_2D_END
  24. SAMPLER_2D_BEGIN( SwirlTexture,
  25. string UIName = "Swirl Texture";
  26. )
  27. MinFilter = Linear;
  28. MagFilter = Linear;
  29. MipFilter = Linear;
  30. AddressU = Mirror;
  31. AddressV = Mirror;
  32. SAMPLER_2D_END
  33. // ----------------------------------------------------------------------------
  34. // Transformations
  35. // ----------------------------------------------------------------------------
  36. float4x4 WorldViewProjection : WorldViewProjection;
  37. float Time : Time;
  38. // ----------------------------------------------------------------------------
  39. struct VSOutput_FlatColor
  40. {
  41. float4 Position : POSITION;
  42. };
  43. // ----------------------------------------------------------------------------
  44. VSOutput_FlatColor VS_FlatColor(float3 Position : POSITION)
  45. {
  46. VSOutput_FlatColor Out;
  47. Out.Position = mul(float4(Position, 1), WorldViewProjection); // float4(Position, 1);
  48. return Out;
  49. }
  50. // ----------------------------------------------------------------------------
  51. float4 PS_FlatColor(VSOutput_FlatColor In) : COLOR
  52. {
  53. return float4(1, 0, 0, 1);
  54. }
  55. // ----------------------------------------------------------------------------
  56. // ----------------------------------------------------------------------------
  57. struct VSOutput_Texture1
  58. {
  59. float4 Position : POSITION;
  60. float4 Color : COLOR0;
  61. float2 BaseTexCoord : TEXCOORD0;
  62. };
  63. // ----------------------------------------------------------------------------
  64. VSOutput_Texture1 VS_Texture1(float3 Position : POSITION, float2 TexCoord0 : TEXCOORD0, float4 Color : COLOR0)
  65. {
  66. VSOutput_Texture1 Out;
  67. float3 warpPos = Position * .25;
  68. float timeMul = Time * 20;
  69. warpPos.x = GetRandomFloatValue(float2(-1,1),timeMul,5);
  70. warpPos.y = GetRandomFloatValue(float2(-1,1),timeMul,6);
  71. warpPos.z = GetRandomFloatValue(float2(-1,1),timeMul,7);
  72. warpPos = warpPos + Position;
  73. Out.Position = mul(float4(warpPos, 1), WorldViewProjection);
  74. Out.BaseTexCoord = TexCoord0;
  75. Out.Color = .25;
  76. Out.Color.r += Color.r * GetRandomFloatValue(float2(0,1),Time*10,5);
  77. Out.Color.g += Color.g * GetRandomFloatValue(float2(0,1),Time*10,6);
  78. Out.Color.b += Color.b* GetRandomFloatValue(float2(0,1),Time*10,7);
  79. Out.Color.w = OpacityOverride;
  80. return Out;
  81. }
  82. // ----------------------------------------------------------------------------
  83. float4 PS_Texture1(VSOutput_Texture1 In) : COLOR
  84. {
  85. Time *= 10.75f;
  86. float2 warpOff1 = float2(Time,Time * 0.1234f) * 0.010f + float2(0.0f,Time * 0.5f);
  87. float2 warpOff2 = float2(0.0f,-(Time+ 1000.0f)) * 0.010f + float2(0.0f,Time * 0.05f);
  88. float4 WarpColor1 = tex2D( SAMPLER(SwirlTexture), (In.BaseTexCoord* 1 + warpOff1 ));
  89. float4 WarpColor2 = tex2D( SAMPLER(SwirlTexture), (In.BaseTexCoord * 1 + warpOff2));
  90. float WarpCol= (WarpColor2.x-WarpColor1.x) * .75;
  91. float2 Texoff = In.BaseTexCoord - float2(0.5 , 0.5);
  92. float warp = WarpCol ;
  93. float2x2 xyRotationMatrix = { 0.0f, 0.0f, 0.0f, 0.0f };
  94. xyRotationMatrix[0][0] = cos(warp);
  95. xyRotationMatrix[0][1] = -sin(warp);
  96. xyRotationMatrix[1][1] = xyRotationMatrix[0][0];
  97. xyRotationMatrix[1][0] = -xyRotationMatrix[0][1];
  98. float2 TexoffRot = mul(Texoff,xyRotationMatrix);
  99. float2 warpTex = TexoffRot + float2(0.5 ,0.5) ;
  100. float4 TextureColor = tex2D( SAMPLER(BaseTexture),warpTex );
  101. float4 color = TextureColor * In.Color * 5;
  102. color.a = clamp(0,1,TextureColor.r)*5;
  103. color = float4(In.Color.rgb ,color.a);
  104. return color ;
  105. }
  106. // ----------------------------------------------------------------------------
  107. technique Simplest
  108. {
  109. pass P0
  110. {
  111. VertexShader = compile VS_2_0 VS_FlatColor();
  112. PixelShader = compile PS_2_0 PS_FlatColor();
  113. ZEnable = false;
  114. ZWriteEnable = false;
  115. CullMode = None;
  116. AlphaBlendEnable = false;
  117. ColorWriteEnable = RGBA;
  118. AlphaTestEnable = false;
  119. }
  120. }
  121. technique DynamicParameter
  122. {
  123. pass P0
  124. {
  125. VertexShader = compile VS_2_0 VS_FlatColor();
  126. PixelShader = compile PS_2_0 PS_FlatColor();
  127. ZEnable = false;
  128. ZWriteEnable = false;
  129. CullMode = None;
  130. AlphaBlendEnable = false;
  131. ColorWriteEnable = RGBA;
  132. AlphaTestEnable = false;
  133. }
  134. }
  135. technique Textured
  136. {
  137. pass P0
  138. {
  139. VertexShader = compile VS_2_0 VS_Texture1();
  140. PixelShader = compile PS_2_0 PS_Texture1();
  141. ZEnable = true;
  142. // ZFunc = ZFUNC_INFRONT;
  143. ZWriteEnable = false;
  144. CullMode = None;
  145. SrcBlend = SrcAlpha;
  146. DestBlend = InvSrcAlpha;
  147. AlphaBlendEnable = true;
  148. ColorWriteEnable = RGBA;
  149. AlphaTestEnable = false;
  150. }
  151. }