Counter Strike : Global Offensive Source Code
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.

142 lines
7.2 KiB

  1. //========= Copyright � Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Shader for creating energy effects
  4. //
  5. //==========================================================================//
  6. #include "BaseVSShader.h"
  7. #include "solidenergy_dx9_helper.h"
  8. #include "cpp_shader_constant_register_map.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. DEFINE_FALLBACK_SHADER( SolidEnergy, SolidEnergy_dx9 )
  12. BEGIN_VS_SHADER( SolidEnergy_dx9, "SolidEnergy" )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( DETAIL1, SHADER_PARAM_TYPE_TEXTURE, "shader/BaseTexture", "detail map 1" )
  15. SHADER_PARAM( DETAIL1SCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "scale detail1 as multiplier of base UVs" )
  16. SHADER_PARAM( DETAIL1FRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for detail1" )
  17. SHADER_PARAM( DETAIL1BLENDMODE, SHADER_PARAM_TYPE_INTEGER, "0", "detail 1 blend mode: 0=add, 1=mod2x, 2=mul, 3=alphamul (mul masked by base alpha)" )
  18. SHADER_PARAM( DETAIL1BLENDFACTOR, SHADER_PARAM_TYPE_FLOAT, "1.0", "detail 1 blend factor" )
  19. SHADER_PARAM( DETAIL1TEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "detail1 texcoord transform" )
  20. SHADER_PARAM( DETAIL2, SHADER_PARAM_TYPE_TEXTURE, "shader/BaseTexture", "detail map 2" )
  21. SHADER_PARAM( DETAIL2SCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "scale detail1 as multiplier of base UVs" )
  22. SHADER_PARAM( DETAIL2FRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for detail1" )
  23. SHADER_PARAM( DETAIL2BLENDMODE, SHADER_PARAM_TYPE_INTEGER, "0", "detail 1 blend mode: 0=add, 1=mod2x, 2=mul, 3=detailmul (mul with detail1)" )
  24. SHADER_PARAM( DETAIL2BLENDFACTOR, SHADER_PARAM_TYPE_FLOAT, "1.0", "detail 1 blend factor" )
  25. SHADER_PARAM( DETAIL2TEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "detail1 texcoord transform" )
  26. SHADER_PARAM( TANGENTTOPACITYRANGES, SHADER_PARAM_TYPE_VEC4, "[1 0.9 0 0.6]", "enables view-based opacity falloff based on tangent t direction, great for cylinders, includes last term for scaling backface opacity")
  27. SHADER_PARAM( TANGENTSOPACITYRANGES, SHADER_PARAM_TYPE_VEC4, "[1 0.9 0 0.6]", "enables view-based opacity falloff based on tangent s direction, great for cylinders, includes last term for scaling backface opacity")
  28. SHADER_PARAM( FRESNELOPACITYRANGES, SHADER_PARAM_TYPE_VEC4, "[1 0.9 0 0.6]", "enables fresnel-based opacity falloff, includes last term for scaling backface opacity")
  29. SHADER_PARAM( NEEDSTANGENTT, SHADER_PARAM_TYPE_BOOL, "0", "don't need to set this explicitly, it gets set when tangenttopacityranges is defined" )
  30. SHADER_PARAM( NEEDSTANGENTS, SHADER_PARAM_TYPE_BOOL, "0", "don't need to set this explicitly, it gets set when tangentSopacityranges is defined" )
  31. SHADER_PARAM( NEEDSNORMALS, SHADER_PARAM_TYPE_BOOL, "0", "don't need to set this explicitly, it gets set when fresnelopacityranges is defined" )
  32. SHADER_PARAM( DEPTHBLEND, SHADER_PARAM_TYPE_BOOL, "0", "enables depth-feathering" )
  33. SHADER_PARAM( DEPTHBLENDSCALE, SHADER_PARAM_TYPE_FLOAT, "50.0", "Amplify or reduce DEPTHBLEND fading. Lower values make harder edges." )
  34. SHADER_PARAM( FLOWMAP, SHADER_PARAM_TYPE_TEXTURE, "", "flowmap" )
  35. SHADER_PARAM( FLOWMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $flowmap" )
  36. SHADER_PARAM( FLOWMAPSCROLLRATE, SHADER_PARAM_TYPE_VEC2, "[0 0", "2D rate to scroll $flowmap" )
  37. SHADER_PARAM( FLOW_NOISE_TEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "flow noise texture" )
  38. SHADER_PARAM( TIME, SHADER_PARAM_TYPE_FLOAT, "", "" )
  39. SHADER_PARAM( FLOW_WORLDUVSCALE, SHADER_PARAM_TYPE_FLOAT, "", "" )
  40. SHADER_PARAM( FLOW_NORMALUVSCALE, SHADER_PARAM_TYPE_FLOAT, "", "" )
  41. SHADER_PARAM( FLOW_TIMEINTERVALINSECONDS, SHADER_PARAM_TYPE_FLOAT, "", "" )
  42. SHADER_PARAM( FLOW_UVSCROLLDISTANCE, SHADER_PARAM_TYPE_FLOAT, "", "" )
  43. SHADER_PARAM( FLOW_NOISE_SCALE, SHADER_PARAM_TYPE_FLOAT, "", "" )
  44. SHADER_PARAM( FLOW_LERPEXP, SHADER_PARAM_TYPE_FLOAT, "", "" )
  45. SHADER_PARAM( FLOWBOUNDS, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  46. SHADER_PARAM( POWERUP, SHADER_PARAM_TYPE_FLOAT, "", "" )
  47. SHADER_PARAM( FLOW_COLOR_INTENSITY, SHADER_PARAM_TYPE_FLOAT, "", "" )
  48. SHADER_PARAM( FLOW_COLOR, SHADER_PARAM_TYPE_VEC3, "", "" )
  49. SHADER_PARAM( FLOW_VORTEX_COLOR, SHADER_PARAM_TYPE_VEC3, "", "" )
  50. SHADER_PARAM( FLOW_VORTEX_SIZE, SHADER_PARAM_TYPE_FLOAT, "", "" )
  51. SHADER_PARAM( FLOW_VORTEX1, SHADER_PARAM_TYPE_BOOL, "", "" )
  52. SHADER_PARAM( FLOW_VORTEX_POS1, SHADER_PARAM_TYPE_VEC3, "", "" )
  53. SHADER_PARAM( FLOW_VORTEX2, SHADER_PARAM_TYPE_BOOL, "", "" )
  54. SHADER_PARAM( FLOW_VORTEX_POS2, SHADER_PARAM_TYPE_VEC3, "", "" )
  55. SHADER_PARAM( FLOW_CHEAP, SHADER_PARAM_TYPE_BOOL, "", "" )
  56. SHADER_PARAM( MODELFORMAT, SHADER_PARAM_TYPE_BOOL, "", "" )
  57. SHADER_PARAM( OUTPUTINTENSITY, SHADER_PARAM_TYPE_FLOAT, "1.0", "" );
  58. END_SHADER_PARAMS
  59. void SetupVarsSolidEnergy( SolidEnergyVars_t &info )
  60. {
  61. info.m_nBaseTexture = BASETEXTURE;
  62. info.m_nBaseTextureTransform = BASETEXTURETRANSFORM;
  63. info.m_nDetail1Texture = DETAIL1;
  64. info.m_nDetail1Scale = DETAIL1SCALE;
  65. info.m_nDetail1Frame = DETAIL1FRAME;
  66. info.m_nDetail1BlendMode = DETAIL1BLENDMODE;
  67. info.m_nDetail1TextureTransform = DETAIL1TEXTURETRANSFORM;
  68. info.m_nDetail2Texture = DETAIL2;
  69. info.m_nDetail2Scale = DETAIL2SCALE;
  70. info.m_nDetail2Frame = DETAIL2FRAME;
  71. info.m_nDetail2BlendMode = DETAIL2BLENDMODE;
  72. info.m_nDetail2TextureTransform = DETAIL2TEXTURETRANSFORM;
  73. info.m_nTangentTOpacityRanges = TANGENTTOPACITYRANGES;
  74. info.m_nTangentSOpacityRanges = TANGENTSOPACITYRANGES;
  75. info.m_nFresnelOpacityRanges = FRESNELOPACITYRANGES;
  76. info.m_nNeedsTangentT = NEEDSTANGENTT;
  77. info.m_nNeedsTangentS = NEEDSTANGENTS;
  78. info.m_nNeedsNormals = NEEDSNORMALS;
  79. info.m_nDepthBlend = DEPTHBLEND;
  80. info.m_nDepthBlendScale = DEPTHBLENDSCALE;
  81. info.m_nFlowMap = FLOWMAP;
  82. info.m_nFlowMapFrame = FLOWMAPFRAME;
  83. info.m_nFlowMapScrollRate = FLOWMAPSCROLLRATE;
  84. info.m_nFlowNoiseTexture = FLOW_NOISE_TEXTURE;
  85. info.m_nTime = TIME;
  86. info.m_nFlowWorldUVScale = FLOW_WORLDUVSCALE;
  87. info.m_nFlowNormalUVScale = FLOW_NORMALUVSCALE;
  88. info.m_nFlowTimeIntervalInSeconds = FLOW_TIMEINTERVALINSECONDS;
  89. info.m_nFlowUVScrollDistance = FLOW_UVSCROLLDISTANCE;
  90. info.m_nFlowNoiseScale = FLOW_NOISE_SCALE;
  91. info.m_nFlowLerpExp = FLOW_LERPEXP;
  92. info.m_nFlowBoundsTexture = FLOWBOUNDS;
  93. info.m_nPowerUp = POWERUP;
  94. info.m_nFlowColorIntensity = FLOW_COLOR_INTENSITY;
  95. info.m_nFlowColor = FLOW_COLOR;
  96. info.m_nFlowVortexColor = FLOW_VORTEX_COLOR;
  97. info.m_nFlowVortexSize = FLOW_VORTEX_SIZE;
  98. info.m_nFlowVortex1 = FLOW_VORTEX1;
  99. info.m_nFlowVortexPos1 = FLOW_VORTEX_POS1;
  100. info.m_nFlowVortex2 = FLOW_VORTEX2;
  101. info.m_nFlowVortexPos2 = FLOW_VORTEX_POS2;
  102. info.m_nFlowCheap = FLOW_CHEAP;
  103. info.m_nModel = MODELFORMAT;
  104. info.m_nOutputIntensity = OUTPUTINTENSITY;
  105. }
  106. SHADER_INIT_PARAMS()
  107. {
  108. SolidEnergyVars_t info;
  109. SetupVarsSolidEnergy( info );
  110. InitParamsSolidEnergy( this, params, pMaterialName, info );
  111. }
  112. SHADER_FALLBACK
  113. {
  114. return 0;
  115. }
  116. SHADER_INIT
  117. {
  118. SolidEnergyVars_t info;
  119. SetupVarsSolidEnergy( info );
  120. InitSolidEnergy( this, params, info );
  121. }
  122. SHADER_DRAW
  123. {
  124. SolidEnergyVars_t info;
  125. SetupVarsSolidEnergy( info );
  126. DrawSolidEnergy( this, params, pShaderAPI, pShaderShadow, info, vertexCompression, pContextDataPtr );
  127. }
  128. END_SHADER