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.

136 lines
6.3 KiB

  1. //========= Copyright � Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Shader for decals on weapon models
  4. //
  5. //==========================================================================//
  6. #include "BaseVSShader.h"
  7. #include "weapondecal_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( WeaponDecal, WeaponDecal_dx9 )
  12. BEGIN_VS_SHADER( WeaponDecal_dx9, "WeaponDecal" )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( THIRDPERSON, SHADER_PARAM_TYPE_BOOL, "0", "Third-person mode" )
  15. SHADER_PARAM( AOTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/AOTexture", "R: cavity, G: AO, B: mig shading" )
  16. SHADER_PARAM( EXPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/ExpTexture", "RGB: Exponent texture" )
  17. SHADER_PARAM( NORMALMAP, SHADER_PARAM_TYPE_TEXTURE, "dev/flatnormal", "Normal Map" )
  18. SHADER_PARAM( HOLOSPECTRUM, SHADER_PARAM_TYPE_TEXTURE, "", "RGB: Hologram spectrum texture" )
  19. SHADER_PARAM( HOLOMASK, SHADER_PARAM_TYPE_TEXTURE, "", "RGB: Hologram mask texture: R " )
  20. SHADER_PARAM( GRUNGETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/PosTexture", "RGB: Tiling grunge A: spec, black dulls the paint finish" )
  21. SHADER_PARAM( WEARTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/PosTexture", "RGB: Greyscale wear speed factor, white wears soonest" )
  22. SHADER_PARAM( ANISODIRTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "black", "RG give direction vector, A masks specularity" )
  23. SHADER_PARAM( MIRRORHORIZONTAL, SHADER_PARAM_TYPE_BOOL, "0", "Flip decal horizontally" )
  24. SHADER_PARAM( WEARREMAPMIN, SHADER_PARAM_TYPE_FLOAT, "0.0", "" )
  25. SHADER_PARAM( WEARREMAPMID, SHADER_PARAM_TYPE_FLOAT, "0.5", "" )
  26. SHADER_PARAM( WEARREMAPMAX, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
  27. SHADER_PARAM( WEARWIDTHMIN, SHADER_PARAM_TYPE_FLOAT, "0.3", "" )
  28. SHADER_PARAM( WEARWIDTHMAX, SHADER_PARAM_TYPE_FLOAT, "0.06", "" )
  29. SHADER_PARAM( ALPHAMASK, SHADER_PARAM_TYPE_INTEGER, "0", "" )
  30. //SHADER_PARAM( FASTWEARTHRESHOLD, SHADER_PARAM_TYPE_FLOAT, "0.0", "" )
  31. SHADER_PARAM( HIGHLIGHT, SHADER_PARAM_TYPE_FLOAT, "0.0", "Highlight the edges of the sticker")
  32. SHADER_PARAM( HIGHLIGHTCYCLE, SHADER_PARAM_TYPE_FLOAT, "0.0", "Scroll the highlight effect")
  33. SHADER_PARAM( PEEL, SHADER_PARAM_TYPE_FLOAT, "0.0", "An effect that 'peels' the sticker in local uv space")
  34. SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "env_cubemap", "Environment cubemap" )
  35. SHADER_PARAM( ENVMAPTINT, SHADER_PARAM_TYPE_VEC3, "[ 1 1 1 ]", "Envmap tint" )
  36. SHADER_PARAM( ALPHA, SHADER_PARAM_TYPE_INTEGER, "1", "Alpha" )
  37. SHADER_PARAM( PHONG, SHADER_PARAM_TYPE_INTEGER, "0", "Enable phong shading" )
  38. SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_INTEGER, "4", "Phong exponent value" )
  39. SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[ 1 1 1 ]", "Phong fresnel ranges" )
  40. SHADER_PARAM( PHONGALBEDOTINT, SHADER_PARAM_TYPE_BOOL, "0", "Phong albedo tint" )
  41. SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1", "Phong boost" )
  42. SHADER_PARAM( PHONGALBEDOBOOST, SHADER_PARAM_TYPE_FLOAT, "1", "Phong albedo boost" )
  43. SHADER_PARAM( DECALSTYLE, SHADER_PARAM_TYPE_INTEGER, "0", "Decal style: 0 = Plastic/PVC sticker" )
  44. //SHADER_PARAM( PATTERNTEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "logo texcoord transform" )
  45. SHADER_PARAM( PATTERNROTATION, SHADER_PARAM_TYPE_FLOAT, "0.0", "Pattern rotation" )
  46. SHADER_PARAM( PATTERNSCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "Pattern scale" )
  47. SHADER_PARAM( COLORTINT4, SHADER_PARAM_TYPE_VEC3, "[ 1 1 1 ]", "Diffuse tint" )
  48. SHADER_PARAM( COLORTINT3, SHADER_PARAM_TYPE_VEC3, "[ 1 1 1 ]", "Diffuse tint" )
  49. SHADER_PARAM( COLORTINT2, SHADER_PARAM_TYPE_VEC3, "[ 1 1 1 ]", "Diffuse tint" )
  50. SHADER_PARAM( COLORTINT, SHADER_PARAM_TYPE_VEC3, "[ 1 1 1 ]", "Diffuse tint" )
  51. SHADER_PARAM( WEARBIAS, SHADER_PARAM_TYPE_FLOAT, "0.5", "" )
  52. SHADER_PARAM( UNWEARSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
  53. SHADER_PARAM( WEARPROGRESS, SHADER_PARAM_TYPE_FLOAT, "0.5", "Wear/worn progress amount" )
  54. SHADER_PARAM( GRUNGESCALE, SHADER_PARAM_TYPE_FLOAT, "2", "" )
  55. SHADER_PARAM( DESATBASETINT, SHADER_PARAM_TYPE_FLOAT, "0", "Desaturate basemap and affect tint" )
  56. END_SHADER_PARAMS
  57. void SetupVarsWeaponDecal( WeaponDecalVars_t &info )
  58. {
  59. info.m_nBaseTexture = BASETEXTURE;
  60. info.m_nBaseTextureTransform = BASETEXTURETRANSFORM;
  61. info.m_nAOTexture = AOTEXTURE;
  62. info.m_nNormalMap = NORMALMAP;
  63. info.m_nWearRemapMin = WEARREMAPMIN;
  64. info.m_nWearRemapMid = WEARREMAPMID;
  65. info.m_nWearRemapMax = WEARREMAPMAX;
  66. info.m_nWearProgress = WEARPROGRESS;
  67. info.m_nWearWidthMin = WEARWIDTHMIN;
  68. info.m_nWearWidthMax = WEARWIDTHMAX;
  69. info.m_nUnWearStrength = UNWEARSTRENGTH;
  70. info.m_nExpTexture = EXPTEXTURE;
  71. info.m_nHologramSpectrum = HOLOSPECTRUM;
  72. info.m_nHologramMask = HOLOMASK;
  73. info.m_nGrungeTexture = GRUNGETEXTURE;
  74. info.m_nWearTexture = WEARTEXTURE;
  75. info.m_nAnisoDirTexture = ANISODIRTEXTURE;
  76. info.m_nEnvmapTexture = ENVMAP;
  77. info.m_nEnvmapTint = ENVMAPTINT;
  78. info.m_nColorTint = COLORTINT;
  79. info.m_nColorTint2 = COLORTINT2;
  80. info.m_nColorTint3 = COLORTINT3;
  81. info.m_nColorTint4 = COLORTINT4;
  82. info.m_nPhong = PHONG;
  83. info.m_nPhongExponent = PHONGEXPONENT;
  84. info.m_nPhongFresnelRanges = PHONGFRESNELRANGES;
  85. info.m_nPhongAlbedoTint = PHONGALBEDOTINT;
  86. info.m_nPhongBoost = PHONGBOOST;
  87. info.m_nPhongAlbedoBoost = PHONGALBEDOBOOST;
  88. info.m_nDecalStyle = DECALSTYLE;
  89. info.m_nAlpha = ALPHA;
  90. //info.m_nPatternTextureTransform = PATTERNTEXTURETRANSFORM;
  91. info.m_nPatternRotation = PATTERNROTATION;
  92. info.m_nPatternScale = PATTERNSCALE;
  93. info.m_nMirrorHorizontal = MIRRORHORIZONTAL;
  94. info.m_nThirdPerson = THIRDPERSON;
  95. info.m_nHighlight = HIGHLIGHT;
  96. info.m_nHighlightCycle = HIGHLIGHTCYCLE;
  97. info.m_nPeel = PEEL;
  98. info.m_nWearBias = WEARBIAS;
  99. info.m_nAlphaMask = ALPHAMASK;
  100. //info.m_nFastWearThreshold = FASTWEARTHRESHOLD;
  101. info.m_nGrungeScale = GRUNGESCALE;
  102. info.m_nDesatBaseTint = DESATBASETINT;
  103. }
  104. SHADER_INIT_PARAMS()
  105. {
  106. WeaponDecalVars_t info;
  107. SetupVarsWeaponDecal( info );
  108. InitParamsWeaponDecal( this, params, pMaterialName, info );
  109. }
  110. SHADER_FALLBACK
  111. {
  112. return 0;
  113. }
  114. SHADER_INIT
  115. {
  116. WeaponDecalVars_t info;
  117. SetupVarsWeaponDecal( info );
  118. InitWeaponDecal( this, params, info );
  119. }
  120. SHADER_DRAW
  121. {
  122. WeaponDecalVars_t info;
  123. SetupVarsWeaponDecal( info );
  124. DrawWeaponDecal( this, params, pShaderAPI, pShaderShadow, info, vertexCompression, pContextDataPtr );
  125. }
  126. END_SHADER