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.

630 lines
29 KiB

  1. //========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //=====================================================================================//
  8. #include "BaseVSShader.h"
  9. #include "vertexlitgeneric_dx9_helper.h"
  10. #include "emissive_scroll_blended_pass_helper.h"
  11. #include "cloak_blended_pass_helper.h"
  12. #include "flesh_interior_blended_pass_helper.h"
  13. // NOTE: This has to be the last file included!
  14. #include "tier0/memdbgon.h"
  15. BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" )
  16. BEGIN_SHADER_PARAMS
  17. SHADER_PARAM( ALBEDO, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "albedo (Base texture with no baked lighting)" )
  18. SHADER_PARAM( COMPRESS, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "compression wrinklemap" )
  19. SHADER_PARAM( STRETCH, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "expansion wrinklemap" )
  20. SHADER_PARAM( SELFILLUMTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Self-illumination tint" )
  21. SHADER_PARAM( DETAIL, SHADER_PARAM_TYPE_TEXTURE, "shadertest/detail", "detail texture" )
  22. SHADER_PARAM( DETAILFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $detail" )
  23. SHADER_PARAM( DETAILSCALE, SHADER_PARAM_TYPE_FLOAT, "4", "scale of the detail texture" )
  24. SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "envmap" )
  25. SHADER_PARAM( ENVMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "envmap frame number" )
  26. SHADER_PARAM( ENVMAPMASK, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_envmask", "envmap mask" )
  27. SHADER_PARAM( ENVMAPMASKFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
  28. SHADER_PARAM( ENVMAPMASKTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$envmapmask texcoord transform" )
  29. SHADER_PARAM( ENVMAPTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "envmap tint" )
  30. SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "bump map" )
  31. SHADER_PARAM( BUMPCOMPRESS, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader3_normal", "compression bump map" )
  32. SHADER_PARAM( BUMPSTRETCH, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "expansion bump map" )
  33. SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $bumpmap" )
  34. SHADER_PARAM( BUMPTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$bumpmap texcoord transform" )
  35. SHADER_PARAM( ENVMAPCONTRAST, SHADER_PARAM_TYPE_FLOAT, "0.0", "contrast 0 == normal 1 == color*color" )
  36. SHADER_PARAM( ENVMAPSATURATION, SHADER_PARAM_TYPE_FLOAT, "1.0", "saturation 0 == greyscale 1 == normal" )
  37. SHADER_PARAM( SELFILLUM_ENVMAPMASK_ALPHA, SHADER_PARAM_TYPE_FLOAT,"0.0","defines that self illum value comes from env map mask alpha" )
  38. SHADER_PARAM( SELFILLUMFRESNEL, SHADER_PARAM_TYPE_BOOL, "0", "Self illum fresnel" )
  39. SHADER_PARAM( SELFILLUMFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC4, "0", "Self illum fresnel min, max, exp" )
  40. SHADER_PARAM( SELFILLUMMASKSCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Scale self illum effect strength" )
  41. SHADER_PARAM( SELFILLUMFRESNELENABLEDTHISFRAME, SHADER_PARAM_TYPE_BOOL, "0", "Self illum fresnel" )
  42. SHADER_PARAM( ALPHATESTREFERENCE, SHADER_PARAM_TYPE_FLOAT, "0.0", "" )
  43. SHADER_PARAM( ALLOWFENCERENDERSTATEHACK, SHADER_PARAM_TYPE_BOOL, "0", "" )
  44. SHADER_PARAM( FLASHLIGHTNOLAMBERT, SHADER_PARAM_TYPE_BOOL, "0", "Flashlight pass sets N.L=1.0" )
  45. SHADER_PARAM( LOWQUALITYFLASHLIGHTSHADOWS, SHADER_PARAM_TYPE_BOOL, "0", "Force low quality flashlight shadows (faster)" )
  46. SHADER_PARAM( DISABLECSMLOOKUP, SHADER_PARAM_TYPE_BOOL, "0", "Force no CSM lookup/filter (faster)" )
  47. // Debugging term for visualizing ambient data on its own
  48. SHADER_PARAM( AMBIENTONLY, SHADER_PARAM_TYPE_INTEGER, "0", "Control drawing of non-ambient light ()" )
  49. SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "5.0", "Phong exponent for local specular lights" )
  50. SHADER_PARAM( PHONGTINT, SHADER_PARAM_TYPE_VEC3, "5.0", "Phong tint for local specular lights" )
  51. SHADER_PARAM( PHONGALBEDOTINT, SHADER_PARAM_TYPE_BOOL, "1.0", "Apply tint by albedo (controlled by spec exponent texture" )
  52. SHADER_PARAM( LIGHTWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for tinting scalar diffuse term" )
  53. SHADER_PARAM( PHONGWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "warp the specular term" )
  54. SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[0 0.5 1]", "Parameters for remapping fresnel output" )
  55. SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong overbrightening factor (specular mask channel should be authored to account for this)" )
  56. SHADER_PARAM( PHONGALBEDOBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong albedo overbrightening factor (specular mask channel should be authored to account for this)" )
  57. SHADER_PARAM( PHONGEXPONENTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Phong Exponent map" )
  58. SHADER_PARAM( PHONG, SHADER_PARAM_TYPE_BOOL, "0", "enables phong lighting" )
  59. SHADER_PARAM( FORCEPHONG, SHADER_PARAM_TYPE_BOOL, "0", "forces Phong lighting, even at low GPU levels (Phong must already be enabled)" )
  60. SHADER_PARAM( BASEMAPALPHAPHONGMASK, SHADER_PARAM_TYPE_INTEGER, "0", "indicates that there is no normal map and that the phong mask is in base alpha" )
  61. SHADER_PARAM( INVERTPHONGMASK, SHADER_PARAM_TYPE_INTEGER, "0", "invert the phong mask (0=full phong, 1=no phong)" )
  62. SHADER_PARAM( ENVMAPFRESNEL, SHADER_PARAM_TYPE_FLOAT, "0", "Degree to which Fresnel should be applied to env map" )
  63. SHADER_PARAM( SELFILLUMMASK, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "If we bind a texture here, it overrides base alpha (if any) for self illum" )
  64. SHADER_PARAM( BASEMAPLUMINANCEPHONGMASK, SHADER_PARAM_TYPE_INTEGER, "0", "indicates that the base luminance should be used to mask phong" )
  65. // detail texturing
  66. SHADER_PARAM( DETAILBLENDMODE, SHADER_PARAM_TYPE_INTEGER, "0", "mode for combining detail texture with base. 0=normal, 1= additive, 2=alpha blend detail over base, 3=crossfade" )
  67. SHADER_PARAM( DETAILBLENDFACTOR, SHADER_PARAM_TYPE_FLOAT, "1", "blend amount for detail texture." )
  68. SHADER_PARAM( DETAILTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "detail texture tint" )
  69. SHADER_PARAM( DETAILTEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$detail texcoord transform" )
  70. // Rim lighting terms
  71. SHADER_PARAM( RIMLIGHT, SHADER_PARAM_TYPE_BOOL, "0", "enables rim lighting" )
  72. SHADER_PARAM( RIMLIGHTEXPONENT, SHADER_PARAM_TYPE_FLOAT, "4.0", "Exponent for rim lights" )
  73. SHADER_PARAM( RIMLIGHTBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Boost for rim lights" )
  74. SHADER_PARAM( RIMMASK, SHADER_PARAM_TYPE_BOOL, "0", "Indicates whether or not to use alpha channel of exponent texture to mask the rim term" )
  75. // Seamless mapping scale
  76. SHADER_PARAM( SEAMLESS_BASE, SHADER_PARAM_TYPE_BOOL, "0", "whether to apply seamless mapping to the base texture. requires a smooth model." )
  77. SHADER_PARAM( SEAMLESS_DETAIL, SHADER_PARAM_TYPE_BOOL, "0", "where to apply seamless mapping to the detail texture." )
  78. SHADER_PARAM( SEAMLESS_SCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "the scale for the seamless mapping. # of repetions of texture per inch." )
  79. // Emissive Scroll Pass
  80. SHADER_PARAM( EMISSIVEBLENDENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enable emissive blend pass" )
  81. SHADER_PARAM( EMISSIVEBLENDBASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "self-illumination map" )
  82. SHADER_PARAM( EMISSIVEBLENDSCROLLVECTOR, SHADER_PARAM_TYPE_VEC2, "[0.11 0.124]", "Emissive scroll vec" )
  83. SHADER_PARAM( EMISSIVEBLENDSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "Emissive blend strength" )
  84. SHADER_PARAM( EMISSIVEBLENDTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "self-illumination map" )
  85. SHADER_PARAM( EMISSIVEBLENDTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Self-illumination tint" )
  86. SHADER_PARAM( EMISSIVEBLENDFLOWTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "flow map" )
  87. SHADER_PARAM( TIME, SHADER_PARAM_TYPE_FLOAT, "0.0", "Needs CurrentTime Proxy" )
  88. // Cloak Pass
  89. SHADER_PARAM( CLOAKPASSENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enables cloak render in a second pass" )
  90. SHADER_PARAM( CLOAKFACTOR, SHADER_PARAM_TYPE_FLOAT, "0.0", "" )
  91. SHADER_PARAM( CLOAKCOLORTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Cloak color tint" )
  92. SHADER_PARAM( REFRACTAMOUNT, SHADER_PARAM_TYPE_FLOAT, "2", "" )
  93. // Flesh Interior Pass
  94. SHADER_PARAM( FLESHINTERIORENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enable Flesh interior blend pass" )
  95. SHADER_PARAM( FLESHINTERIORTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh color texture" )
  96. SHADER_PARAM( FLESHINTERIORNOISETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh noise texture" )
  97. SHADER_PARAM( FLESHBORDERTEXTURE1D, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh border 1D texture" )
  98. SHADER_PARAM( FLESHNORMALTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh normal texture" )
  99. SHADER_PARAM( FLESHSUBSURFACETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh subsurface texture" )
  100. SHADER_PARAM( FLESHCUBETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh cubemap texture" )
  101. SHADER_PARAM( FLESHBORDERNOISESCALE, SHADER_PARAM_TYPE_FLOAT, "1.5", "Flesh Noise UV scalar for border" )
  102. SHADER_PARAM( FLESHDEBUGFORCEFLESHON, SHADER_PARAM_TYPE_BOOL, "0", "Flesh Debug full flesh" )
  103. SHADER_PARAM( FLESHEFFECTCENTERRADIUS1, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0.001]", "Flesh effect center and radius" )
  104. SHADER_PARAM( FLESHEFFECTCENTERRADIUS2, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0.001]", "Flesh effect center and radius" )
  105. SHADER_PARAM( FLESHEFFECTCENTERRADIUS3, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0.001]", "Flesh effect center and radius" )
  106. SHADER_PARAM( FLESHEFFECTCENTERRADIUS4, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0.001]", "Flesh effect center and radius" )
  107. SHADER_PARAM( FLESHSUBSURFACETINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Subsurface Color" )
  108. SHADER_PARAM( FLESHBORDERWIDTH, SHADER_PARAM_TYPE_FLOAT, "0.3", "Flesh border" )
  109. SHADER_PARAM( FLESHBORDERSOFTNESS, SHADER_PARAM_TYPE_FLOAT, "0.42", "Flesh border softness (> 0.0 && <= 0.5)" )
  110. SHADER_PARAM( FLESHBORDERTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Flesh border Color" )
  111. SHADER_PARAM( FLESHGLOBALOPACITY, SHADER_PARAM_TYPE_FLOAT, "1.0", "Flesh global opacity" )
  112. SHADER_PARAM( FLESHGLOSSBRIGHTNESS, SHADER_PARAM_TYPE_FLOAT, "0.66", "Flesh gloss brightness" )
  113. SHADER_PARAM( FLESHSCROLLSPEED, SHADER_PARAM_TYPE_FLOAT, "1.0", "Flesh scroll speed" )
  114. SHADER_PARAM( SEPARATEDETAILUVS, SHADER_PARAM_TYPE_BOOL, "0", "Use texcoord1 for detail texture" )
  115. SHADER_PARAM( LINEARWRITE, SHADER_PARAM_TYPE_INTEGER, "0", "Disables SRGB conversion of shader results." )
  116. #if defined( CSTRIKE15 )
  117. SHADER_PARAM( SHADERSRGBREAD360, SHADER_PARAM_TYPE_BOOL, "1", "Simulate srgb read in shader code")
  118. #else
  119. SHADER_PARAM( SHADERSRGBREAD360, SHADER_PARAM_TYPE_BOOL, "0", "Simulate srgb read in shader code")
  120. #endif
  121. SHADER_PARAM( AMBIENTOCCLUSION, SHADER_PARAM_TYPE_FLOAT, "0.0", "Amount of screen space ambient occlusion to use (0..1 range)")
  122. SHADER_PARAM( DISPLACEMENTMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Displacement map" )
  123. SHADER_PARAM( DISPLACEMENTWRINKLE, SHADER_PARAM_TYPE_BOOL, "0", "Displacement map contains wrinkle displacements")
  124. SHADER_PARAM( BLENDTINTBYBASEALPHA, SHADER_PARAM_TYPE_BOOL, "0", "Use the base alpha to blend in the $color modulation")
  125. SHADER_PARAM( NOTINT, SHADER_PARAM_TYPE_BOOL, "0", "Disable tinting" )
  126. SHADER_PARAM( DESATURATEWITHBASEALPHA, SHADER_PARAM_TYPE_FLOAT, "0.0", "Use the base alpha to desaturate the base texture. Set to non-zero to enable, value gets multiplied into the alpha channel before desaturating.")
  127. SHADER_PARAM( ALLOWDIFFUSEMODULATION, SHADER_PARAM_TYPE_BOOL, "1", "Allow per-instance color modulation")
  128. // vertexlitgeneric envmap fresnel control
  129. SHADER_PARAM( ENVMAPFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.0 1.0 2.0]", "Min/max fresnel range and exponent for vertexlitgeneric" )
  130. SHADER_PARAM( BASEALPHAENVMAPMASKMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[1.0 0.0 1.0]", "" )
  131. // This is to allow phong materials to disable half lambert. Half lambert has always been forced on in phong,
  132. // so the only safe way to allow artists to disable half lambert is to create this param that disables the
  133. // default behavior of forcing half lambert on.
  134. SHADER_PARAM( PHONGDISABLEHALFLAMBERT, SHADER_PARAM_TYPE_BOOL, "0", "Disable half lambert for phong")
  135. // vertexlitgeneric tree sway animation control
  136. SHADER_PARAM( TREESWAY, SHADER_PARAM_TYPE_INTEGER, "0", "" );
  137. SHADER_PARAM( TREESWAYHEIGHT, SHADER_PARAM_TYPE_FLOAT, "1000", "" );
  138. SHADER_PARAM( TREESWAYSTARTHEIGHT, SHADER_PARAM_TYPE_FLOAT, "0.2", "" );
  139. SHADER_PARAM( TREESWAYRADIUS, SHADER_PARAM_TYPE_FLOAT, "300", "" );
  140. SHADER_PARAM( TREESWAYSTARTRADIUS, SHADER_PARAM_TYPE_FLOAT, "0.1", "" );
  141. SHADER_PARAM( TREESWAYSPEED, SHADER_PARAM_TYPE_FLOAT, "1", "" );
  142. SHADER_PARAM( TREESWAYSPEEDHIGHWINDMULTIPLIER, SHADER_PARAM_TYPE_FLOAT, "2", "" );
  143. SHADER_PARAM( TREESWAYSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "10", "" );
  144. SHADER_PARAM( TREESWAYSCRUMBLESPEED, SHADER_PARAM_TYPE_FLOAT, "0.1", "" );
  145. SHADER_PARAM( TREESWAYSCRUMBLESTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.1", "" );
  146. SHADER_PARAM( TREESWAYSCRUMBLEFREQUENCY, SHADER_PARAM_TYPE_FLOAT, "0.1", "" );
  147. SHADER_PARAM( TREESWAYFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.5", "" );
  148. SHADER_PARAM( TREESWAYSCRUMBLEFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.0", "" );
  149. SHADER_PARAM( TREESWAYSPEEDLERPSTART, SHADER_PARAM_TYPE_FLOAT, "3", "" );
  150. SHADER_PARAM( TREESWAYSPEEDLERPEND, SHADER_PARAM_TYPE_FLOAT, "6", "" );
  151. SHADER_PARAM( TREESWAYSTATIC, SHADER_PARAM_TYPE_BOOL, "0", "" );
  152. SHADER_PARAM( DECALTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Decal texture" )
  153. SHADER_PARAM( DECALBLENDMODE, SHADER_PARAM_TYPE_INTEGER, "0", "mode for combining decal texture with base. 0=normal(decal*srca + base*(1-srca), 1= mod, 2=mod2x, 3=additive" )
  154. SHADER_PARAM( ENVMAPLIGHTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.0", "How much the lightmap effects environment map reflection, 0.0 is off, 1.0 will allow complete blackness of the environment map if the lightmap is black" )
  155. SHADER_PARAM( ENVMAPLIGHTSCALEMINMAX, SHADER_PARAM_TYPE_VEC2, "[0.0 1.0]", "Thresholds for the lightmap envmap effect. Setting the min higher increases the minimum light amount at which the envmap gets nerfed to nothing." )
  156. SHADER_PARAM( BLENDWITHSMOKEGRENADE, SHADER_PARAM_TYPE_BOOL, "0", "" );
  157. SHADER_PARAM( BLENDWITHSMOKEGRENADEPOSENTITY, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" );
  158. SHADER_PARAM( BLENDWITHSMOKEGRENADEPOSSMOKE, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" );
  159. SHADER_PARAM( MODELDECALIGNOREZ, SHADER_PARAM_TYPE_BOOL, "0", "" );
  160. SHADER_PARAM( TINTMASKTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Separate tint mask texture (as opposed to using basetexture alpha)" )
  161. SHADER_PARAM( ENVMAPMASKINTINTMASKTEXTURE, SHADER_PARAM_TYPE_BOOL, "0", "Envmap mask is stored in ting mask texture (instead of normal map alpha)" )
  162. END_SHADER_PARAMS
  163. void SetupVars( VertexLitGeneric_DX9_Vars_t& info )
  164. {
  165. info.m_nBaseTexture = BASETEXTURE;
  166. info.m_nWrinkle = COMPRESS;
  167. info.m_nStretch = STRETCH;
  168. info.m_nBaseTextureFrame = FRAME;
  169. info.m_nBaseTextureTransform = BASETEXTURETRANSFORM;
  170. info.m_nAlbedo = ALBEDO;
  171. info.m_nSelfIllumTint = SELFILLUMTINT;
  172. info.m_nDetail = DETAIL;
  173. info.m_nDetailFrame = DETAILFRAME;
  174. info.m_nDetailScale = DETAILSCALE;
  175. info.m_nEnvmap = ENVMAP;
  176. info.m_nEnvmapFrame = ENVMAPFRAME;
  177. info.m_nEnvmapMask = ENVMAPMASK;
  178. info.m_nEnvmapMaskFrame = ENVMAPMASKFRAME;
  179. info.m_nEnvmapMaskTransform = ENVMAPMASKTRANSFORM;
  180. info.m_nEnvmapTint = ENVMAPTINT;
  181. info.m_nBumpmap = BUMPMAP;
  182. info.m_nNormalWrinkle = BUMPCOMPRESS;
  183. info.m_nNormalStretch = BUMPSTRETCH;
  184. info.m_nBumpFrame = BUMPFRAME;
  185. info.m_nBumpTransform = BUMPTRANSFORM;
  186. info.m_nEnvmapContrast = ENVMAPCONTRAST;
  187. info.m_nEnvmapSaturation = ENVMAPSATURATION;
  188. info.m_nAlphaTestReference = ALPHATESTREFERENCE;
  189. info.m_nAllowFenceRenderStateHack = ALLOWFENCERENDERSTATEHACK;
  190. info.m_nFlashlightNoLambert = FLASHLIGHTNOLAMBERT;
  191. info.m_nLowQualityFlashlightShadows = LOWQUALITYFLASHLIGHTSHADOWS;
  192. info.m_nDisableCSMLookup = DISABLECSMLOOKUP;
  193. info.m_nFlashlightTexture = FLASHLIGHTTEXTURE;
  194. info.m_nFlashlightTextureFrame = FLASHLIGHTTEXTUREFRAME;
  195. info.m_nSelfIllumEnvMapMask_Alpha = SELFILLUM_ENVMAPMASK_ALPHA;
  196. info.m_nSelfIllumFresnel = SELFILLUMFRESNEL;
  197. info.m_nSelfIllumFresnelMinMaxExp = SELFILLUMFRESNELMINMAXEXP;
  198. info.m_nSelfIllumMaskScale = SELFILLUMMASKSCALE;
  199. info.m_nSelfIllumFresnelEnabledThisFrame = SELFILLUMFRESNELENABLEDTHISFRAME;
  200. info.m_nAmbientOnly = AMBIENTONLY;
  201. info.m_nPhongExponent = PHONGEXPONENT;
  202. info.m_nPhongExponentTexture = PHONGEXPONENTTEXTURE;
  203. info.m_nPhongTint = PHONGTINT;
  204. info.m_nPhongAlbedoTint = PHONGALBEDOTINT;
  205. info.m_nDiffuseWarpTexture = LIGHTWARPTEXTURE;
  206. info.m_nPhongWarpTexture = PHONGWARPTEXTURE;
  207. info.m_nPhongBoost = PHONGBOOST;
  208. info.m_nPhongAlbedoBoost = PHONGALBEDOBOOST;
  209. info.m_nPhongFresnelRanges = PHONGFRESNELRANGES;
  210. info.m_nPhong = PHONG;
  211. info.m_nForcePhong = FORCEPHONG;
  212. info.m_nBaseMapAlphaPhongMask = BASEMAPALPHAPHONGMASK;
  213. info.m_nEnvmapFresnel = ENVMAPFRESNEL;
  214. info.m_nDetailTextureCombineMode = DETAILBLENDMODE;
  215. info.m_nDetailTextureBlendFactor = DETAILBLENDFACTOR;
  216. info.m_nDetailTextureTransform = DETAILTEXTURETRANSFORM;
  217. info.m_nBaseMapLuminancePhongMask = BASEMAPLUMINANCEPHONGMASK;
  218. // Rim lighting parameters
  219. info.m_nRimLight = RIMLIGHT;
  220. info.m_nRimLightPower = RIMLIGHTEXPONENT;
  221. info.m_nRimLightBoost = RIMLIGHTBOOST;
  222. info.m_nRimMask = RIMMASK;
  223. // seamless
  224. info.m_nSeamlessScale = SEAMLESS_SCALE;
  225. info.m_nSeamlessDetail = SEAMLESS_DETAIL;
  226. info.m_nSeamlessBase = SEAMLESS_BASE;
  227. info.m_nSeparateDetailUVs = SEPARATEDETAILUVS;
  228. info.m_nLinearWrite = LINEARWRITE;
  229. info.m_nDetailTint = DETAILTINT;
  230. info.m_nInvertPhongMask = INVERTPHONGMASK;
  231. info.m_nSelfIllumMask = SELFILLUMMASK;
  232. info.m_nShaderSrgbRead360 = SHADERSRGBREAD360;
  233. info.m_nAmbientOcclusion = AMBIENTOCCLUSION;
  234. info.m_nBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA;
  235. info.m_nNoTint = NOTINT;
  236. info.m_nDesaturateWithBaseAlpha = DESATURATEWITHBASEALPHA;
  237. info.m_nAllowDiffuseModulation = ALLOWDIFFUSEMODULATION;
  238. info.m_nEnvMapFresnelMinMaxExp = ENVMAPFRESNELMINMAXEXP;
  239. info.m_nBaseAlphaEnvMapMaskMinMaxExp = BASEALPHAENVMAPMASKMINMAXEXP;
  240. info.m_nDisplacementMap = DISPLACEMENTMAP;
  241. info.m_nDisplacementWrinkleMap = DISPLACEMENTWRINKLE;
  242. info.m_nPhongDisableHalfLambert = PHONGDISABLEHALFLAMBERT;
  243. info.m_nTreeSway = TREESWAY;
  244. info.m_nTreeSwayHeight = TREESWAYHEIGHT;
  245. info.m_nTreeSwayStartHeight = TREESWAYSTARTHEIGHT;
  246. info.m_nTreeSwayRadius = TREESWAYRADIUS;
  247. info.m_nTreeSwayStartRadius = TREESWAYSTARTRADIUS;
  248. info.m_nTreeSwaySpeed = TREESWAYSPEED;
  249. info.m_nTreeSwaySpeedHighWindMultiplier = TREESWAYSPEEDHIGHWINDMULTIPLIER;
  250. info.m_nTreeSwayStrength = TREESWAYSTRENGTH;
  251. info.m_nTreeSwayScrumbleSpeed = TREESWAYSCRUMBLESPEED;
  252. info.m_nTreeSwayScrumbleStrength = TREESWAYSCRUMBLESTRENGTH;
  253. info.m_nTreeSwayScrumbleFrequency = TREESWAYSCRUMBLEFREQUENCY;
  254. info.m_nTreeSwayFalloffExp = TREESWAYFALLOFFEXP;
  255. info.m_nTreeSwayScrumbleFalloffExp = TREESWAYSCRUMBLEFALLOFFEXP;
  256. info.m_nTreeSwaySpeedLerpStart = TREESWAYSPEEDLERPSTART;
  257. info.m_nTreeSwaySpeedLerpEnd = TREESWAYSPEEDLERPEND;
  258. info.m_nTreeSwayStatic = TREESWAYSTATIC;
  259. info.m_nDecalTexture = DECALTEXTURE;
  260. info.m_nDecalTextureCombineMode = DECALBLENDMODE;
  261. info.m_nEnvMapLightScale = ENVMAPLIGHTSCALE;
  262. info.m_nEnvMapLightScaleMinMax = ENVMAPLIGHTSCALEMINMAX;
  263. info.m_nBlendWithSmokeGrenade = BLENDWITHSMOKEGRENADE;
  264. info.m_nBlendWithSmokeGrenadePosEntity = BLENDWITHSMOKEGRENADEPOSENTITY;
  265. info.m_nBlendWithSmokeGrenadePosSmoke = BLENDWITHSMOKEGRENADEPOSSMOKE;
  266. info.m_nModelDecalIgnoreZ = MODELDECALIGNOREZ;
  267. info.m_nTintMaskTexture = TINTMASKTEXTURE;
  268. info.m_nEnvMapMaskInTintMaskTexture = ENVMAPMASKINTINTMASKTEXTURE;
  269. }
  270. // Cloak Pass
  271. void SetupVarsCloakBlendedPass( CloakBlendedPassVars_t &info )
  272. {
  273. info.m_nCloakFactor = CLOAKFACTOR;
  274. info.m_nCloakColorTint = CLOAKCOLORTINT;
  275. info.m_nRefractAmount = REFRACTAMOUNT;
  276. // Delete these lines if not bump mapping!
  277. info.m_nBumpmap = BUMPMAP;
  278. info.m_nBumpFrame = BUMPFRAME;
  279. info.m_nBumpTransform = BUMPTRANSFORM;
  280. }
  281. bool NeedsPowerOfTwoFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame ) const
  282. {
  283. if ( params[CLOAKPASSENABLED]->GetIntValue() ) // If material supports cloaking
  284. {
  285. if ( bCheckSpecificToThisFrame == false ) // For setting model flag at load time
  286. return true;
  287. else if ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) // Per-frame check
  288. return true;
  289. // else, not cloaking this frame, so check flag2 in case the base material still needs it
  290. }
  291. // Check flag2 if not drawing cloak pass
  292. return IS_FLAG2_SET( MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE );
  293. }
  294. bool IsTranslucent( IMaterialVar **params ) const
  295. {
  296. if ( params[CLOAKPASSENABLED]->GetIntValue() ) // If material supports cloaking
  297. {
  298. if ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) // Per-frame check
  299. return true;
  300. // else, not cloaking this frame, so check flag in case the base material still needs it
  301. }
  302. // Check flag if not drawing cloak pass
  303. return IS_FLAG_SET( MATERIAL_VAR_TRANSLUCENT );
  304. }
  305. // Emissive Scroll Pass
  306. void SetupVarsEmissiveScrollBlendedPass( EmissiveScrollBlendedPassVars_t &info )
  307. {
  308. info.m_nBlendStrength = EMISSIVEBLENDSTRENGTH;
  309. info.m_nBaseTexture = EMISSIVEBLENDBASETEXTURE;
  310. info.m_nFlowTexture = EMISSIVEBLENDFLOWTEXTURE;
  311. info.m_nEmissiveTexture = EMISSIVEBLENDTEXTURE;
  312. info.m_nEmissiveTint = EMISSIVEBLENDTINT;
  313. info.m_nEmissiveScrollVector = EMISSIVEBLENDSCROLLVECTOR;
  314. info.m_nTime = TIME;
  315. }
  316. // Flesh Interior Pass
  317. void SetupVarsFleshInteriorBlendedPass( FleshInteriorBlendedPassVars_t &info )
  318. {
  319. info.m_nFleshTexture = FLESHINTERIORTEXTURE;
  320. info.m_nFleshNoiseTexture = FLESHINTERIORNOISETEXTURE;
  321. info.m_nFleshBorderTexture1D = FLESHBORDERTEXTURE1D;
  322. info.m_nFleshNormalTexture = FLESHNORMALTEXTURE;
  323. info.m_nFleshSubsurfaceTexture = FLESHSUBSURFACETEXTURE;
  324. info.m_nFleshCubeTexture = FLESHCUBETEXTURE;
  325. info.m_nflBorderNoiseScale = FLESHBORDERNOISESCALE;
  326. info.m_nflDebugForceFleshOn = FLESHDEBUGFORCEFLESHON;
  327. info.m_nvEffectCenterRadius1 = FLESHEFFECTCENTERRADIUS1;
  328. info.m_nvEffectCenterRadius2 = FLESHEFFECTCENTERRADIUS2;
  329. info.m_nvEffectCenterRadius3 = FLESHEFFECTCENTERRADIUS3;
  330. info.m_nvEffectCenterRadius4 = FLESHEFFECTCENTERRADIUS4;
  331. info.m_ncSubsurfaceTint = FLESHSUBSURFACETINT;
  332. info.m_nflBorderWidth = FLESHBORDERWIDTH;
  333. info.m_nflBorderSoftness = FLESHBORDERSOFTNESS;
  334. info.m_ncBorderTint = FLESHBORDERTINT;
  335. info.m_nflGlobalOpacity = FLESHGLOBALOPACITY;
  336. info.m_nflGlossBrightness = FLESHGLOSSBRIGHTNESS;
  337. info.m_nflScrollSpeed = FLESHSCROLLSPEED;
  338. info.m_nTime = TIME;
  339. }
  340. SHADER_INIT_PARAMS()
  341. {
  342. bool bDisableTreeSway = false;
  343. // Disable tree swaying on consoles, or on "cheap" shadow filter modes (which are too pixelated).
  344. if ( IsGameConsole() || IsPlatformOSX() )
  345. #if defined( CSTRIKE15 )
  346. if( IsPlatformOSX() || IsPS3() )
  347. {
  348. bDisableTreeSway = true;
  349. }
  350. #else
  351. bDisableTreeSway = true;
  352. #endif
  353. else if ( g_pHardwareConfig->GetShadowFilterMode( false /* bForceLowQuality */, g_pHardwareConfig->SupportsPixelShaders_3_0() /* bPS30 */ ) >= SHADOWFILTERMODE_FIRST_CHEAP_MODE )
  354. {
  355. bDisableTreeSway = true;
  356. }
  357. if ( bDisableTreeSway )
  358. {
  359. params[TREESWAY]->SetIntValue( 0 );
  360. }
  361. VertexLitGeneric_DX9_Vars_t vars;
  362. SetupVars( vars );
  363. InitParamsVertexLitGeneric_DX9( this, params, pMaterialName, true, vars );
  364. // Cloak Pass
  365. if ( !params[CLOAKPASSENABLED]->IsDefined() )
  366. {
  367. params[CLOAKPASSENABLED]->SetIntValue( 0 );
  368. }
  369. else if ( params[CLOAKPASSENABLED]->GetIntValue() )
  370. {
  371. CloakBlendedPassVars_t info;
  372. SetupVarsCloakBlendedPass( info );
  373. InitParamsCloakBlendedPass( this, params, pMaterialName, info );
  374. }
  375. // Emissive Scroll Pass
  376. if ( !params[EMISSIVEBLENDENABLED]->IsDefined() )
  377. {
  378. params[EMISSIVEBLENDENABLED]->SetIntValue( 0 );
  379. }
  380. else if ( params[EMISSIVEBLENDENABLED]->GetIntValue() )
  381. {
  382. EmissiveScrollBlendedPassVars_t info;
  383. SetupVarsEmissiveScrollBlendedPass( info );
  384. InitParamsEmissiveScrollBlendedPass( this, params, pMaterialName, info );
  385. }
  386. // Flesh Interior Pass
  387. if ( !params[FLESHINTERIORENABLED]->IsDefined() )
  388. {
  389. params[FLESHINTERIORENABLED]->SetIntValue( 0 );
  390. }
  391. else if ( params[FLESHINTERIORENABLED]->GetIntValue() )
  392. {
  393. FleshInteriorBlendedPassVars_t info;
  394. SetupVarsFleshInteriorBlendedPass( info );
  395. InitParamsFleshInteriorBlendedPass( this, params, pMaterialName, info );
  396. }
  397. if ( !params[PHONGBOOST]->IsDefined() )
  398. {
  399. params[PHONGBOOST]->SetFloatValue( 1.0f );
  400. }
  401. if ( !params[PHONGFRESNELRANGES]->IsDefined() )
  402. {
  403. params[PHONGFRESNELRANGES]->SetVecValue( 1.0f, 1.0f, 1.0f );
  404. }
  405. if ( !params[PHONGALBEDOBOOST]->IsDefined() )
  406. {
  407. if ( params[PHONGBOOST]->IsDefined() )
  408. {
  409. params[PHONGALBEDOBOOST]->SetFloatValue( params[PHONGBOOST]->GetFloatValue() );
  410. }
  411. else
  412. {
  413. params[PHONGALBEDOBOOST]->SetFloatValue( 1.0f );
  414. }
  415. }
  416. }
  417. SHADER_FALLBACK
  418. {
  419. return 0;
  420. }
  421. SHADER_INIT
  422. {
  423. VertexLitGeneric_DX9_Vars_t vars;
  424. SetupVars( vars );
  425. InitVertexLitGeneric_DX9( this, params, true, vars );
  426. // Cloak Pass
  427. if ( params[CLOAKPASSENABLED]->GetIntValue() )
  428. {
  429. CloakBlendedPassVars_t info;
  430. SetupVarsCloakBlendedPass( info );
  431. InitCloakBlendedPass( this, params, info );
  432. }
  433. // Emissive Scroll Pass
  434. if ( params[EMISSIVEBLENDENABLED]->GetIntValue() )
  435. {
  436. EmissiveScrollBlendedPassVars_t info;
  437. SetupVarsEmissiveScrollBlendedPass( info );
  438. InitEmissiveScrollBlendedPass( this, params, info );
  439. }
  440. // Flesh Interior Pass
  441. if ( params[FLESHINTERIORENABLED]->GetIntValue() )
  442. {
  443. FleshInteriorBlendedPassVars_t info;
  444. SetupVarsFleshInteriorBlendedPass( info );
  445. InitFleshInteriorBlendedPass( this, params, info );
  446. }
  447. }
  448. SHADER_DRAW
  449. {
  450. // Skip the standard rendering if cloak pass is fully opaque
  451. bool bDrawStandardPass = true;
  452. if ( params[CLOAKPASSENABLED]->GetIntValue() && ( pShaderShadow == NULL ) ) // && not snapshotting
  453. {
  454. CloakBlendedPassVars_t info;
  455. SetupVarsCloakBlendedPass( info );
  456. if ( CloakBlendedPassIsFullyOpaque( params, info ) )
  457. {
  458. bDrawStandardPass = false;
  459. }
  460. }
  461. // Standard rendering pass
  462. if ( bDrawStandardPass )
  463. {
  464. VertexLitGeneric_DX9_Vars_t vars;
  465. SetupVars( vars );
  466. DrawVertexLitGeneric_DX9( this, params, pShaderAPI, pShaderShadow, true, vars, vertexCompression, pContextDataPtr );
  467. }
  468. else
  469. {
  470. // Skip this pass!
  471. Draw( false );
  472. }
  473. // Cloak Pass
  474. if ( params[CLOAKPASSENABLED]->GetIntValue() )
  475. {
  476. // If ( snapshotting ) or ( we need to draw this frame )
  477. if ( ( pShaderShadow != NULL ) || ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) )
  478. {
  479. CloakBlendedPassVars_t info;
  480. SetupVarsCloakBlendedPass( info );
  481. DrawCloakBlendedPass( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
  482. }
  483. else // We're not snapshotting and we don't need to draw this frame
  484. {
  485. // Skip this pass!
  486. Draw( false );
  487. }
  488. }
  489. // Emissive Scroll Pass
  490. if ( params[EMISSIVEBLENDENABLED]->GetIntValue() )
  491. {
  492. // If ( snapshotting ) or ( we need to draw this frame )
  493. if ( ( pShaderShadow != NULL ) || ( params[EMISSIVEBLENDSTRENGTH]->GetFloatValue() > 0.0f ) )
  494. {
  495. EmissiveScrollBlendedPassVars_t info;
  496. SetupVarsEmissiveScrollBlendedPass( info );
  497. DrawEmissiveScrollBlendedPass( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
  498. }
  499. else // We're not snapshotting and we don't need to draw this frame
  500. {
  501. // Skip this pass!
  502. Draw( false );
  503. }
  504. }
  505. // Flesh Interior Pass
  506. if ( params[FLESHINTERIORENABLED]->GetIntValue() )
  507. {
  508. // If ( snapshotting ) or ( we need to draw this frame )
  509. if ( ( pShaderShadow != NULL ) || ( true ) )
  510. {
  511. FleshInteriorBlendedPassVars_t info;
  512. SetupVarsFleshInteriorBlendedPass( info );
  513. DrawFleshInteriorBlendedPass( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
  514. }
  515. else // We're not snapshotting and we don't need to draw this frame
  516. {
  517. // Skip this pass!
  518. Draw( false );
  519. }
  520. }
  521. }
  522. void ExecuteFastPath( int *dynVSIdx, int *dynPSIdx, IMaterialVar** params, IShaderDynamicAPI * pShaderAPI,
  523. VertexCompressionType_t vertexCompression, CBasePerMaterialContextData **pContextDataPtr, BOOL bCSMEnabled )
  524. {
  525. *dynVSIdx = -1;
  526. *dynPSIdx = -1;
  527. VertexLitGeneric_DX9_Vars_t vars;
  528. SetupVars( vars );
  529. if ( params[CLOAKPASSENABLED]->GetIntValue() || params[EMISSIVEBLENDENABLED]->GetIntValue() ||
  530. params[FLESHINTERIORENABLED]->GetIntValue() )
  531. {
  532. return;
  533. }
  534. // Only draw standard pass for now
  535. // GS_TODO: Other passes
  536. DrawVertexLitGeneric_DX9_ExecuteFastPath( dynVSIdx, dynPSIdx, this, params, pShaderAPI, vars, vertexCompression,
  537. pContextDataPtr, bCSMEnabled );
  538. }
  539. END_SHADER