Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

484 lines
17 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: shader for drawing sprites as cards, with animation frame lerping
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //===========================================================================//
  8. #include "BaseVSShader.h"
  9. #include "convar.h"
  10. // STDSHADER_DX9_DLL_EXPORT
  11. #include "spritecard_ps20.inc"
  12. #include "spritecard_ps20b.inc"
  13. #include "spritecard_vs20.inc"
  14. #include "splinecard_vs20.inc"
  15. #if SUPPORT_DX8
  16. // STDSHADER_DX8_DLL_EXPORT
  17. #include "spritecard_vs11.inc"
  18. #include "spritecard_ps11.inc"
  19. #include "splinecard_vs11.inc"
  20. #endif
  21. #include "tier0/icommandline.h" //command line
  22. // memdbgon must be the last include file in a .cpp file!!!
  23. #include "tier0/memdbgon.h"
  24. #define DEFAULT_PARTICLE_FEATHERING_ENABLED 1
  25. #ifdef STDSHADER_DX8_DLL_EXPORT
  26. DEFINE_FALLBACK_SHADER( Spritecard, Spritecard_DX8 )
  27. #endif
  28. int GetDefaultDepthFeatheringValue( void ) //Allow the command-line to go against the default soft-particle value
  29. {
  30. static int iRetVal = -1;
  31. if( iRetVal == -1 )
  32. {
  33. # if( DEFAULT_PARTICLE_FEATHERING_ENABLED == 1 )
  34. {
  35. if( CommandLine()->CheckParm( "-softparticlesdefaultoff" ) )
  36. iRetVal = 0;
  37. else
  38. iRetVal = 1;
  39. }
  40. # else
  41. {
  42. if( CommandLine()->CheckParm( "-softparticlesdefaulton" ) )
  43. iRetVal = 1;
  44. else
  45. iRetVal = 0;
  46. }
  47. # endif
  48. }
  49. // On low end parts on the Mac, we reduce particles and shut off depth blending here
  50. static ConVarRef mat_reduceparticles( "mat_reduceparticles" );
  51. if ( mat_reduceparticles.GetBool() )
  52. {
  53. iRetVal = 0;
  54. }
  55. return iRetVal;
  56. }
  57. #ifdef STDSHADER_DX9_DLL_EXPORT
  58. BEGIN_VS_SHADER_FLAGS( Spritecard, "Help for Spritecard", SHADER_NOT_EDITABLE )
  59. #else
  60. BEGIN_VS_SHADER_FLAGS( Spritecard_DX8, "Help for Spritecard_DX8", SHADER_NOT_EDITABLE )
  61. #endif
  62. BEGIN_SHADER_PARAMS
  63. SHADER_PARAM( DEPTHBLEND, SHADER_PARAM_TYPE_INTEGER, "0", "fade at intersection boundaries" )
  64. SHADER_PARAM( DEPTHBLENDSCALE, SHADER_PARAM_TYPE_FLOAT, "50.0", "Amplify or reduce DEPTHBLEND fading. Lower values make harder edges." )
  65. SHADER_PARAM( ORIENTATION, SHADER_PARAM_TYPE_INTEGER, "0", "0 = always face camera, 1 = rotate around z, 2= parallel to ground" )
  66. SHADER_PARAM( ADDBASETEXTURE2, SHADER_PARAM_TYPE_FLOAT, "0.0", "amount to blend second texture into frame by" )
  67. SHADER_PARAM( OVERBRIGHTFACTOR, SHADER_PARAM_TYPE_FLOAT, "1.0", "overbright factor for texture. For HDR effects.")
  68. SHADER_PARAM( DUALSEQUENCE, SHADER_PARAM_TYPE_INTEGER, "0", "blend two separate animated sequences.")
  69. SHADER_PARAM( SEQUENCE_BLEND_MODE, SHADER_PARAM_TYPE_INTEGER, "0", "defines the blend mode between the images un dual sequence particles. 0 = avg, 1=alpha from first, rgb from 2nd, 2= first over second" )
  70. SHADER_PARAM( MAXLUMFRAMEBLEND1, SHADER_PARAM_TYPE_INTEGER, "0", "instead of blending between animation frames for the first sequence, select pixels based upon max luminance" )
  71. SHADER_PARAM( MAXLUMFRAMEBLEND2, SHADER_PARAM_TYPE_INTEGER, "0", "instead of blending between animation frames for the 2nd sequence, select pixels based upon max luminance" )
  72. SHADER_PARAM( RAMPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "if specified, then the red value of the image is used to index this ramp to produce the output color" )
  73. SHADER_PARAM( ZOOMANIMATESEQ2, SHADER_PARAM_TYPE_FLOAT, "1.0", "amount to gradually zoom between frames on the second sequence. 2.0 will double the size of a frame over its lifetime.")
  74. SHADER_PARAM( EXTRACTGREENALPHA, SHADER_PARAM_TYPE_INTEGER, "0", "grayscale data sitting in green/alpha channels")
  75. SHADER_PARAM( ADDOVERBLEND, SHADER_PARAM_TYPE_INTEGER, "0", "use ONE:INVSRCALPHA blending")
  76. SHADER_PARAM( ADDSELF, SHADER_PARAM_TYPE_FLOAT, "0.0", "amount of base texture to additively blend in" )
  77. SHADER_PARAM( BLENDFRAMES, SHADER_PARAM_TYPE_BOOL, "1", "whether or not to smoothly blend between animated frames" )
  78. SHADER_PARAM( MINSIZE, SHADER_PARAM_TYPE_FLOAT, "0.0", "minimum screen fractional size of particle")
  79. SHADER_PARAM( STARTFADESIZE, SHADER_PARAM_TYPE_FLOAT, "10.0", "screen fractional size to start fading particle out")
  80. SHADER_PARAM( ENDFADESIZE, SHADER_PARAM_TYPE_FLOAT, "20.0", "screen fractional size to finish fading particle out")
  81. SHADER_PARAM( MAXSIZE, SHADER_PARAM_TYPE_FLOAT, "20.0", "maximum screen fractional size of particle")
  82. SHADER_PARAM( USEINSTANCING, SHADER_PARAM_TYPE_BOOL, "1", "whether to use GPU vertex instancing (submit 1 vert per particle quad)")
  83. SHADER_PARAM( SPLINETYPE, SHADER_PARAM_TYPE_INTEGER, "0", "spline type 0 = none, 1=ctamull rom")
  84. SHADER_PARAM( MAXDISTANCE, SHADER_PARAM_TYPE_FLOAT, "100000.0", "maximum distance to draw particles at")
  85. SHADER_PARAM( FARFADEINTERVAL, SHADER_PARAM_TYPE_FLOAT, "400.0", "interval over which to fade out far away particles")
  86. END_SHADER_PARAMS
  87. SHADER_INIT_PARAMS()
  88. {
  89. INIT_FLOAT_PARM( MAXDISTANCE, 100000.0);
  90. INIT_FLOAT_PARM( FARFADEINTERVAL, 400.0);
  91. INIT_FLOAT_PARM( MAXSIZE, 20.0 );
  92. INIT_FLOAT_PARM( ENDFADESIZE, 20.0 );
  93. INIT_FLOAT_PARM( STARTFADESIZE, 10.0 );
  94. INIT_FLOAT_PARM( DEPTHBLENDSCALE, 50.0 );
  95. INIT_FLOAT_PARM( OVERBRIGHTFACTOR, 1.0 );
  96. INIT_FLOAT_PARM( ADDBASETEXTURE2, 0.0 );
  97. INIT_FLOAT_PARM( ADDSELF, 0.0 );
  98. INIT_FLOAT_PARM( ZOOMANIMATESEQ2, 0.0 );
  99. if ( !params[DEPTHBLEND]->IsDefined() )
  100. {
  101. params[ DEPTHBLEND ]->SetIntValue( GetDefaultDepthFeatheringValue() );
  102. }
  103. if ( !g_pHardwareConfig->SupportsPixelShaders_2_b() )
  104. {
  105. params[ DEPTHBLEND ]->SetIntValue( 0 );
  106. }
  107. if ( !params[DUALSEQUENCE]->IsDefined() )
  108. {
  109. params[DUALSEQUENCE]->SetIntValue( 0 );
  110. }
  111. if ( !params[MAXLUMFRAMEBLEND1]->IsDefined() )
  112. {
  113. params[MAXLUMFRAMEBLEND1]->SetIntValue( 0 );
  114. }
  115. if ( !params[MAXLUMFRAMEBLEND2]->IsDefined() )
  116. {
  117. params[MAXLUMFRAMEBLEND2]->SetIntValue( 0 );
  118. }
  119. if ( !params[EXTRACTGREENALPHA]->IsDefined() )
  120. {
  121. params[EXTRACTGREENALPHA]->SetIntValue( 0 );
  122. }
  123. if ( !params[ADDOVERBLEND]->IsDefined() )
  124. {
  125. params[ADDOVERBLEND]->SetIntValue( 0 );
  126. }
  127. if ( !params[BLENDFRAMES]->IsDefined() )
  128. {
  129. params[ BLENDFRAMES ]->SetIntValue( 1 );
  130. }
  131. if ( !params[USEINSTANCING]->IsDefined() )
  132. {
  133. params[ USEINSTANCING ]->SetIntValue( IsX360() ? 1 : 0 );
  134. }
  135. SET_FLAGS2( MATERIAL_VAR2_IS_SPRITECARD );
  136. }
  137. SHADER_FALLBACK
  138. {
  139. #ifdef STDSHADER_DX9_DLL_EXPORT
  140. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  141. return "SpriteCard_DX8";
  142. #endif
  143. #ifdef STDSHADER_DX8_DLL_EXPORT
  144. // STDSHADER_DX8_DLL_EXPORT
  145. if ( g_pHardwareConfig->GetDXSupportLevel() < 80 )
  146. return "Wireframe";
  147. #endif
  148. return 0;
  149. }
  150. SHADER_INIT
  151. {
  152. #ifdef STDSHADER_DX9_DLL_EXPORT
  153. const bool bDX8 = false;
  154. #endif
  155. #ifdef STDSHADER_DX8_DLL_EXPORT
  156. const bool bDX8 = true;
  157. #endif
  158. SET_FLAGS2( MATERIAL_VAR2_LIGHTING_VERTEX_LIT );
  159. if ( params[BASETEXTURE]->IsDefined() )
  160. {
  161. bool bExtractGreenAlpha = false;
  162. if ( params[EXTRACTGREENALPHA]->IsDefined() )
  163. {
  164. bExtractGreenAlpha = params[EXTRACTGREENALPHA]->GetIntValue() != 0;
  165. }
  166. LoadTexture( BASETEXTURE, !bExtractGreenAlpha && !bDX8 ? TEXTUREFLAGS_SRGB : 0 );
  167. }
  168. if ( params[RAMPTEXTURE]->IsDefined() )
  169. {
  170. LoadTexture( RAMPTEXTURE, TEXTUREFLAGS_SRGB );
  171. }
  172. }
  173. SHADER_DRAW
  174. {
  175. #ifdef STDSHADER_DX9_DLL_EXPORT
  176. const bool bDX8 = false;
  177. #endif
  178. #ifdef STDSHADER_DX8_DLL_EXPORT
  179. const bool bDX8 = true;
  180. #endif
  181. bool bUseRampTexture = (! bDX8 ) && ( params[RAMPTEXTURE]->IsDefined() );
  182. bool bZoomSeq2 = (! bDX8 ) && ( ( params[ZOOMANIMATESEQ2]->GetFloatValue()) > 1.0 );
  183. bool bDepthBlend = (! bDX8 ) && ( params[DEPTHBLEND]->GetIntValue() != 0 );
  184. bool bAdditive2ndTexture = params[ADDBASETEXTURE2]->GetFloatValue() != 0.0;
  185. int nSplineType = params[SPLINETYPE]->GetIntValue();
  186. SHADOW_STATE
  187. {
  188. bool bSecondSequence = params[DUALSEQUENCE]->GetIntValue() != 0;
  189. bool bAddOverBlend = params[ADDOVERBLEND]->GetIntValue() != 0;
  190. bool bExtractGreenAlpha = (! bDX8 ) && ( params[EXTRACTGREENALPHA]->GetIntValue() != 0 );
  191. bool bBlendFrames = (! bDX8 ) && ( params[BLENDFRAMES]->GetIntValue() != 0 );
  192. if ( nSplineType )
  193. {
  194. bBlendFrames = false;
  195. }
  196. bool bAddSelf = params[ADDSELF]->GetFloatValue() != 0.0;
  197. bool bUseInstancing = IsX360() ? ( params[ USEINSTANCING ]->GetIntValue() != 0 ) : false;
  198. if ( nSplineType )
  199. bUseInstancing = false;
  200. // draw back-facing because of yaw spin
  201. pShaderShadow->EnableCulling( false );
  202. // Be sure not to write to dest alpha
  203. pShaderShadow->EnableAlphaWrites( false );
  204. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  205. if ( bDX8 )
  206. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  207. if ( bAdditive2ndTexture && bDX8 )
  208. pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
  209. if ( bUseRampTexture )
  210. {
  211. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  212. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true );
  213. }
  214. if ( bDepthBlend )
  215. {
  216. pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
  217. }
  218. if ( bAdditive2ndTexture || bAddSelf )
  219. pShaderShadow->EnableAlphaTest( false );
  220. else
  221. pShaderShadow->EnableAlphaTest( true );
  222. pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GREATER, 0.01f );
  223. if ( bAdditive2ndTexture || bAddOverBlend || bAddSelf )
  224. {
  225. EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  226. }
  227. else
  228. {
  229. if ( IS_FLAG_SET(MATERIAL_VAR_ADDITIVE) )
  230. {
  231. EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE );
  232. }
  233. else
  234. {
  235. EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  236. }
  237. }
  238. unsigned int flags = VERTEX_POSITION | VERTEX_COLOR;
  239. static int s_TexCoordSize[8]={4, // 0 = sheet bounding uvs, frame0
  240. 4, // 1 = sheet bounding uvs, frame 1
  241. 4, // 2 = frame blend, rot, radius, ???
  242. 2, // 3 = corner identifier ( 0/0,1/0,1/1, 1/0 )
  243. 4, // 4 = texture 2 bounding uvs
  244. 4, // 5 = second sequence bounding uvs, frame0
  245. 4, // 6 = second sequence bounding uvs, frame1
  246. 4, // 7 = second sequence frame blend, ?,?,?
  247. };
  248. static int s_TexCoordSizeSpline[]={4, // 0 = sheet bounding uvs, frame0
  249. 4, // 1 = sheet bounding uvs, frame 1
  250. 4, // 2 = frame blend, rot, radius, ???
  251. 4, // 3 = corner identifier ( 0/0,1/0,1/1, 1/0 )
  252. 4, // 4 = texture 2 bounding uvs
  253. 4, // 5 = second sequence bounding uvs, frame0
  254. 4, // 6 = second sequence bounding uvs, frame1
  255. 4, // 7 = second sequence frame blend, ?,?,?
  256. };
  257. int numTexCoords = 4;
  258. if ( true /* bAdditive2ndTexture */ ) // there is no branch for 2nd texture in the VS! -henryg
  259. {
  260. numTexCoords = 5;
  261. }
  262. if ( bSecondSequence )
  263. {
  264. // the whole shebang - 2 sequences, with a possible multi-image sequence first
  265. numTexCoords = 8;
  266. }
  267. pShaderShadow->VertexShaderVertexFormat( flags,
  268. numTexCoords,
  269. nSplineType? s_TexCoordSizeSpline : s_TexCoordSize, 0 );
  270. if ( bDX8 )
  271. {
  272. #if SUPPORT_DX8
  273. if ( nSplineType )
  274. {
  275. DECLARE_STATIC_VERTEX_SHADER( splinecard_vs11 );
  276. SET_STATIC_VERTEX_SHADER( splinecard_vs11 );
  277. }
  278. else
  279. {
  280. DECLARE_STATIC_VERTEX_SHADER( spritecard_vs11 );
  281. if ( bSecondSequence )
  282. bAdditive2ndTexture = false;
  283. SET_STATIC_VERTEX_SHADER_COMBO( DUALSEQUENCE, false );
  284. SET_STATIC_VERTEX_SHADER_COMBO( ZOOM_ANIMATE_SEQ2, false );
  285. SET_STATIC_VERTEX_SHADER_COMBO( EXTRACTGREENALPHA, bExtractGreenAlpha );
  286. SET_STATIC_VERTEX_SHADER( spritecard_vs11 );
  287. }
  288. DECLARE_STATIC_PIXEL_SHADER( spritecard_ps11 );
  289. SET_STATIC_PIXEL_SHADER_COMBO( ADDBASETEXTURE2, bAdditive2ndTexture );
  290. SET_STATIC_PIXEL_SHADER_COMBO( ADDSELF, bAddSelf );
  291. SET_STATIC_PIXEL_SHADER_COMBO( USEALPHAASRGB, bSecondSequence );
  292. SET_STATIC_PIXEL_SHADER( spritecard_ps11 );
  293. #endif
  294. }
  295. else
  296. {
  297. if ( nSplineType )
  298. {
  299. DECLARE_STATIC_VERTEX_SHADER( splinecard_vs20 );
  300. SET_STATIC_VERTEX_SHADER( splinecard_vs20 );
  301. }
  302. else
  303. {
  304. DECLARE_STATIC_VERTEX_SHADER( spritecard_vs20 );
  305. SET_STATIC_VERTEX_SHADER_COMBO( DUALSEQUENCE, bSecondSequence );
  306. SET_STATIC_VERTEX_SHADER_COMBO( ZOOM_ANIMATE_SEQ2, bZoomSeq2 );
  307. SET_STATIC_VERTEX_SHADER_COMBO( EXTRACTGREENALPHA, bExtractGreenAlpha );
  308. SET_STATIC_VERTEX_SHADER_COMBO( USE_INSTANCING, bUseInstancing );
  309. SET_STATIC_VERTEX_SHADER( spritecard_vs20 );
  310. }
  311. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  312. {
  313. DECLARE_STATIC_PIXEL_SHADER( spritecard_ps20b );
  314. SET_STATIC_PIXEL_SHADER_COMBO( ADDBASETEXTURE2, bAdditive2ndTexture );
  315. SET_STATIC_PIXEL_SHADER_COMBO( ADDSELF, bAddSelf );
  316. SET_STATIC_PIXEL_SHADER_COMBO( ANIMBLEND, bBlendFrames );
  317. SET_STATIC_PIXEL_SHADER_COMBO( DUALSEQUENCE, bSecondSequence );
  318. SET_STATIC_PIXEL_SHADER_COMBO( SEQUENCE_BLEND_MODE, bSecondSequence ? params[SEQUENCE_BLEND_MODE]->GetIntValue() : 0 );
  319. SET_STATIC_PIXEL_SHADER_COMBO( MAXLUMFRAMEBLEND1, params[MAXLUMFRAMEBLEND1]->GetIntValue() );
  320. SET_STATIC_PIXEL_SHADER_COMBO( MAXLUMFRAMEBLEND2, bSecondSequence? params[MAXLUMFRAMEBLEND1]->GetIntValue() : 0 );
  321. SET_STATIC_PIXEL_SHADER_COMBO( COLORRAMP, bUseRampTexture );
  322. SET_STATIC_PIXEL_SHADER_COMBO( EXTRACTGREENALPHA, bExtractGreenAlpha );
  323. SET_STATIC_PIXEL_SHADER_COMBO( DEPTHBLEND, bDepthBlend );
  324. SET_STATIC_PIXEL_SHADER( spritecard_ps20b );
  325. }
  326. else
  327. {
  328. DECLARE_STATIC_PIXEL_SHADER( spritecard_ps20 );
  329. SET_STATIC_PIXEL_SHADER_COMBO( ADDBASETEXTURE2, bAdditive2ndTexture );
  330. SET_STATIC_PIXEL_SHADER_COMBO( DUALSEQUENCE, bSecondSequence );
  331. SET_STATIC_PIXEL_SHADER_COMBO( ADDSELF, bAddSelf );
  332. SET_STATIC_PIXEL_SHADER_COMBO( ANIMBLEND, bBlendFrames );
  333. SET_STATIC_PIXEL_SHADER_COMBO( SEQUENCE_BLEND_MODE, bSecondSequence ? params[SEQUENCE_BLEND_MODE]->GetIntValue() : 0 );
  334. SET_STATIC_PIXEL_SHADER_COMBO( MAXLUMFRAMEBLEND1, params[MAXLUMFRAMEBLEND1]->GetIntValue() );
  335. SET_STATIC_PIXEL_SHADER_COMBO( MAXLUMFRAMEBLEND2, bSecondSequence? params[MAXLUMFRAMEBLEND1]->GetIntValue() : 0 );
  336. SET_STATIC_PIXEL_SHADER_COMBO( COLORRAMP, bUseRampTexture );
  337. SET_STATIC_PIXEL_SHADER_COMBO( EXTRACTGREENALPHA, bExtractGreenAlpha );
  338. SET_STATIC_PIXEL_SHADER( spritecard_ps20 );
  339. }
  340. if ( !bDX8 )
  341. pShaderShadow->EnableSRGBWrite( true );
  342. if( !bExtractGreenAlpha && !bDX8 )
  343. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
  344. }
  345. }
  346. DYNAMIC_STATE
  347. {
  348. BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
  349. if ( bDX8 ) // bind on 2nd sampelr so we can lerp
  350. BindTexture( SHADER_SAMPLER1, BASETEXTURE, FRAME );
  351. if ( bDX8 && bAdditive2ndTexture )
  352. BindTexture( SHADER_SAMPLER3, BASETEXTURE, FRAME );
  353. if ( bUseRampTexture && ( !bDX8 ) )
  354. {
  355. BindTexture( SHADER_SAMPLER1, RAMPTEXTURE, FRAME );
  356. }
  357. if ( bDepthBlend )
  358. {
  359. pShaderAPI->BindStandardTexture( SHADER_SAMPLER2, TEXTURE_FRAME_BUFFER_FULL_DEPTH );
  360. }
  361. LoadViewportTransformScaledIntoVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10 );
  362. int nOrientation = params[ORIENTATION]->GetIntValue();
  363. nOrientation = clamp( nOrientation, 0, 2 );
  364. // We need these only when screen-orienting
  365. if ( nOrientation == 0 )
  366. {
  367. LoadModelViewMatrixIntoVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0 );
  368. LoadProjectionMatrixIntoVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3 );
  369. }
  370. if ( bZoomSeq2 )
  371. {
  372. float flZScale=1.0/(params[ZOOMANIMATESEQ2]->GetFloatValue());
  373. float C0[4]={ (float)(0.5*(1.0+flZScale)), flZScale, 0, 0 };
  374. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, C0,
  375. ARRAYSIZE(C0)/4 );
  376. }
  377. // set fade constants in vsconsts 8 and 9
  378. float flMaxDistance = params[MAXDISTANCE]->GetFloatValue();
  379. float flStartFade = max( 1.f, flMaxDistance - params[FARFADEINTERVAL]->GetFloatValue() );
  380. float VC0[8]={ params[MINSIZE]->GetFloatValue(), params[MAXSIZE]->GetFloatValue(),
  381. params[STARTFADESIZE]->GetFloatValue(), params[ENDFADESIZE]->GetFloatValue(),
  382. flStartFade, (float)(1.0/(flMaxDistance-flStartFade)),
  383. 0,0 };
  384. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_8, VC0, ARRAYSIZE(VC0)/4 );
  385. pShaderAPI->SetDepthFeatheringPixelShaderConstant( 2, params[DEPTHBLENDSCALE]->GetFloatValue() );
  386. float C0[4]={ params[ADDBASETEXTURE2]->GetFloatValue(),
  387. params[OVERBRIGHTFACTOR]->GetFloatValue(),
  388. params[ADDSELF]->GetFloatValue(),
  389. 0.0f };
  390. if ( bDX8 && ( !bAdditive2ndTexture ) ) // deal with 0..1 limit for pix shader constants
  391. {
  392. C0[2] *= 0.25;
  393. C0[1] *= 0.25;
  394. }
  395. pShaderAPI->SetPixelShaderConstant( 0, C0, ARRAYSIZE(C0)/4 );
  396. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  397. {
  398. #if SUPPORT_DX8
  399. if ( nSplineType )
  400. {
  401. DECLARE_DYNAMIC_VERTEX_SHADER( splinecard_vs11 );
  402. SET_DYNAMIC_VERTEX_SHADER( splinecard_vs11 );
  403. }
  404. else
  405. {
  406. DECLARE_DYNAMIC_VERTEX_SHADER( spritecard_vs11 );
  407. SET_DYNAMIC_VERTEX_SHADER_COMBO( ORIENTATION, nOrientation );
  408. SET_DYNAMIC_VERTEX_SHADER( spritecard_vs11 );
  409. }
  410. #endif
  411. }
  412. else
  413. {
  414. if ( nSplineType )
  415. {
  416. DECLARE_DYNAMIC_VERTEX_SHADER( splinecard_vs20 );
  417. SET_DYNAMIC_VERTEX_SHADER( splinecard_vs20 );
  418. }
  419. else
  420. {
  421. DECLARE_DYNAMIC_VERTEX_SHADER( spritecard_vs20 );
  422. SET_DYNAMIC_VERTEX_SHADER_COMBO( ORIENTATION, nOrientation );
  423. SET_DYNAMIC_VERTEX_SHADER( spritecard_vs20 );
  424. }
  425. }
  426. }
  427. Draw( );
  428. }
  429. END_SHADER