Simplest.fx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. //////////////////////////////////////////////////////////////////////////////
  2. // ©2005 Electronic Arts Inc
  3. //
  4. // FX Shader for shadow map debugging
  5. //////////////////////////////////////////////////////////////////////////////
  6. #include "Common.fxh"
  7. #if defined(EA_PLATFORM_WINDOWS) && defined(_3DSMAX_)
  8. // ----------------------------------------------------------------------------
  9. // SAMPLER : nhendricks : had to pull these in here for MAX to compile
  10. // ----------------------------------------------------------------------------
  11. #define SAMPLER_2D_BEGIN(samplerName, annotations) \
  12. texture samplerName \
  13. < \
  14. annotations \
  15. >; \
  16. sampler2D samplerName##Sampler = sampler_state \
  17. { \
  18. Texture = < samplerName >;
  19. #define SAMPLER_2D_END };
  20. #define SAMPLER( samplerName ) samplerName##Sampler
  21. #define SAMPLER_CUBE_BEGIN(samplerName, annotations) \
  22. texture samplerName \
  23. < \
  24. annotations \
  25. >; \
  26. samplerCUBE samplerName##Sampler = sampler_state \
  27. { \
  28. Texture = < samplerName >;
  29. #define SAMPLER_CUBE_END };
  30. #endif
  31. float4 FlatColorOverride
  32. <
  33. string UIWidget = "None";
  34. string SasBindAddress = "WW3D.FlatColor";
  35. int WW3DDynamicSet = DS_CUSTOM_FIRST;
  36. >;
  37. SAMPLER_2D_BEGIN( BaseTexture,
  38. string UIName = "Base Texture";
  39. )
  40. MinFilter = Linear;
  41. MagFilter = Linear;
  42. MipFilter = Linear;
  43. AddressU = Clamp;
  44. AddressV = Clamp;
  45. SAMPLER_2D_END
  46. // ----------------------------------------------------------------------------
  47. // Transformations
  48. // ----------------------------------------------------------------------------
  49. float4x4 WorldViewProjection : WorldViewProjection;
  50. // ----------------------------------------------------------------------------
  51. struct VSOutput_FlatColor
  52. {
  53. float4 Position : POSITION;
  54. };
  55. // ----------------------------------------------------------------------------
  56. VSOutput_FlatColor VS_FlatColor(float3 Position : POSITION)
  57. {
  58. VSOutput_FlatColor Out;
  59. Out.Position = mul(float4(Position, 1), WorldViewProjection); //float4(Position, 1);//
  60. //Out.Position = mul(mul(mul(float4(Position, 1), World), View), Projection);
  61. return Out;
  62. }
  63. // ----------------------------------------------------------------------------
  64. float4 PS_FlatColor(VSOutput_FlatColor In) : COLOR
  65. {
  66. return float4(1, 0, 0, 1);
  67. }
  68. // ----------------------------------------------------------------------------
  69. float4 PS_FlatColorOverride(VSOutput_FlatColor In) : COLOR
  70. {
  71. return FlatColorOverride;
  72. }
  73. // ----------------------------------------------------------------------------
  74. // ----------------------------------------------------------------------------
  75. struct VSOutput_Texture1
  76. {
  77. float4 Position : POSITION;
  78. float2 BaseTexCoord : TEXCOORD0;
  79. };
  80. // ----------------------------------------------------------------------------
  81. VSOutput_Texture1 VS_Texture1(float3 Position : POSITION, float2 TexCoord0 : TEXCOORD0)
  82. {
  83. VSOutput_Texture1 Out;
  84. Out.Position = mul(float4(Position, 1), WorldViewProjection);
  85. Out.BaseTexCoord = TexCoord0;
  86. return Out;
  87. }
  88. // ----------------------------------------------------------------------------
  89. float4 PS_Texture1(VSOutput_Texture1 In) : COLOR
  90. {
  91. float4 color = tex2D(SAMPLER(BaseTexture), In.BaseTexCoord);
  92. return color;
  93. }
  94. // ----------------------------------------------------------------------------
  95. technique Simplest
  96. {
  97. pass P0
  98. {
  99. VertexShader = compile VS_2_0 VS_FlatColor();
  100. PixelShader = compile PS_2_0 PS_FlatColor();
  101. ZEnable = false;
  102. ZWriteEnable = false;
  103. CullMode = None;
  104. AlphaBlendEnable = false;
  105. ColorWriteEnable = RGBA;
  106. AlphaTestEnable = false;
  107. }
  108. }
  109. /*technique DynamicParameter
  110. {
  111. pass P0
  112. {
  113. VertexShader = compile VS_2_0 VS_FlatColor();
  114. PixelShader = compile PS_2_0 PS_FlatColorOverride();
  115. ZEnable = false;
  116. ZWriteEnable = false;
  117. CullMode = None;
  118. AlphaBlendEnable = false;
  119. ColorWriteEnable = RGBA;
  120. AlphaTestEnable = false;
  121. }
  122. }*/
  123. technique DynamicParameter
  124. {
  125. pass P0
  126. <
  127. USE_EXPRESSION_EVALUATOR("Simplest")
  128. >
  129. {
  130. VertexShader = compile VS_2_0 VS_FlatColor();
  131. PixelShader = compile PS_2_0 PS_FlatColor();
  132. ZEnable = false;
  133. ZWriteEnable = false;
  134. CullMode = None;
  135. #if !EXPRESSION_EVALUATOR_ENABLED
  136. AlphaBlendEnable = ( FlatColorOverride.z > 0.5 );
  137. #endif
  138. SrcBlend = One;
  139. DestBlend = One;
  140. ColorWriteEnable = RGBA;
  141. AlphaTestEnable = false;
  142. }
  143. }
  144. technique Textured
  145. {
  146. pass P0
  147. {
  148. VertexShader = compile VS_2_0 VS_Texture1();
  149. PixelShader = compile PS_2_0 PS_Texture1();
  150. ZEnable = false;
  151. ZWriteEnable = false;
  152. CullMode = None;
  153. AlphaBlendEnable = false;
  154. ColorWriteEnable = RGBA;
  155. AlphaTestEnable = false;
  156. }
  157. }