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.

131 lines
6.6 KiB

  1. //========= Copyright � Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Shader for compositing weapon textures
  4. //
  5. //==========================================================================//
  6. #include "BaseVSShader.h"
  7. #include "customweapon_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( CustomWeapon, CustomWeapon_dx9 )
  12. BEGIN_VS_SHADER( CustomWeapon_dx9, "CustomWeapon" )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( SURFACETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/SurfaceTexture", "RGB: Object-space normal, A: Cavity" )
  15. SHADER_PARAM( AOTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/AOTexture", "RGB: Ambient Occlusion" )
  16. SHADER_PARAM( MASKSTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/MasksTexture", "R: Anodized, G: Camo2, B: Camo3, A: Black is paintable, White reveals original basetexture" )
  17. SHADER_PARAM( POSTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/PosTexture", "RGB: High-precision object-space position" )
  18. SHADER_PARAM( GRUNGETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/PosTexture", "RGB: Tiling grunge A: spec, black dulls the paint finish" )
  19. SHADER_PARAM( WEARTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/PosTexture", "RGB: Greyscale wear speed factor, white wears soonest" )
  20. SHADER_PARAM( PAINTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/PosTexture", "RGB: High-precision object-space position" )
  21. SHADER_PARAM( EXPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shader/PosTexture", "RGB: Exponent texture" )
  22. SHADER_PARAM( CAMOCOLOR0, SHADER_PARAM_TYPE_VEC3, "[ 0 0 0 ]", "Customization color 0" )
  23. SHADER_PARAM( CAMOCOLOR1, SHADER_PARAM_TYPE_VEC3, "[ 0 0 0 ]", "Customization color 1" )
  24. SHADER_PARAM( CAMOCOLOR2, SHADER_PARAM_TYPE_VEC3, "[ 0 0 0 ]", "Customization color 2" )
  25. SHADER_PARAM( CAMOCOLOR3, SHADER_PARAM_TYPE_VEC3, "[ 0 0 0 ]", "Customization color 3" )
  26. SHADER_PARAM( BASEDIFFUSEOVERRIDE, SHADER_PARAM_TYPE_INTEGER, "0", "Set if this customization style needs a different (non-default) underlying diffuse map for this weapon" )
  27. SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_INTEGER, "4", "Phong exponent value" )
  28. SHADER_PARAM( WEARPROGRESS, SHADER_PARAM_TYPE_FLOAT, "0.45", "Wear/worn progress amount" )
  29. SHADER_PARAM( PHONGALBEDOBOOST, SHADER_PARAM_TYPE_FLOAT, "1", "Phong albedo boost value for anodized metallic effect" )
  30. SHADER_PARAM( PHONGINTENSITY, SHADER_PARAM_TYPE_INTEGER, "10", "Phong intensity value" )
  31. SHADER_PARAM( PAINTSTYLE, SHADER_PARAM_TYPE_INTEGER, "0", "Indicates a specific customization style: 0 = none, 1 = solid, 2 = hydrographic, 3 = spray, 4 = anodized, 5 = anodized multicolored, 6 = anodized airbrushed, 7 = custom texture, 8 = patina/antiqued" )
  32. SHADER_PARAM( EXPONENTMODE, SHADER_PARAM_TYPE_INTEGER, "0", "Set to 1 to an exponent texture for the given style rather than a base diffuse" )
  33. SHADER_PARAM( PATTERNTEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$PAINTTEXTURE texcoord transform" )
  34. SHADER_PARAM( WEARTEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$WEARTEXTURE texcoord transform" )
  35. SHADER_PARAM( GRUNGETEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$GRUNGETEXTURE texcoord transform" )
  36. SHADER_PARAM( CHEAPMODE, SHADER_PARAM_TYPE_BOOL, "", "Cheap mode for low-spec hardware. Disables certain nice-but-not-fundamentally-vital features such as super-sampling the HDR precision" )
  37. SHADER_PARAM( PHONGALBEDOFACTOR, SHADER_PARAM_TYPE_FLOAT, "1.0", "When using the anodizing mode, some specular values already affected by phongalbedo in the source need to be reduced to compensate for increase in phongalbedoboost")
  38. SHADER_PARAM( PREVIEW, SHADER_PARAM_TYPE_BOOL, "0", "Enable to preview the shader, realtime, on a model" )
  39. SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[ .25 .5 1 ]", "Phong fresnel ranges for preview render" )
  40. SHADER_PARAM( PHONGALBEDOTINT, SHADER_PARAM_TYPE_BOOL, "0", "Enable phong albedo tint for preview render" )
  41. SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong boost for preview render" )
  42. SHADER_PARAM( PAINTPHONGALBEDOBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong albedo boost for preview render" )
  43. SHADER_PARAM( PREVIEWWEAPONOBJSCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "Weapon-specific scale factor for patterns applied via object space projections" )
  44. SHADER_PARAM( PREVIEWWEAPONUVSCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "Weapon-specific scale factor for patterns applied via UVs" )
  45. SHADER_PARAM( PREVIEWIGNOREWEAPONSCALE, SHADER_PARAM_TYPE_BOOL, "0", "Paint-specific toggle for ignoring weapon-specific scales" )
  46. END_SHADER_PARAMS
  47. void SetupVarsCustomWeapon( CustomWeaponVars_t &info )
  48. {
  49. info.m_nBaseTexture = BASETEXTURE;
  50. info.m_nBaseTextureTransform = BASETEXTURETRANSFORM;
  51. info.m_nSurfaceTexture = SURFACETEXTURE;
  52. info.m_nAOTexture = AOTEXTURE;
  53. info.m_nMasksTexture = MASKSTEXTURE;
  54. info.m_nPosTexture = POSTEXTURE;
  55. info.m_nGrungeTexture = GRUNGETEXTURE;
  56. info.m_nWearTexture = WEARTEXTURE;
  57. info.m_nPaintTexture = PAINTTEXTURE;
  58. info.m_nExpTexture = EXPTEXTURE;
  59. info.m_nCamoColor0 = CAMOCOLOR0;
  60. info.m_nCamoColor1 = CAMOCOLOR1;
  61. info.m_nCamoColor2 = CAMOCOLOR2;
  62. info.m_nCamoColor3 = CAMOCOLOR3;
  63. info.m_nBaseDiffuseOverride = BASEDIFFUSEOVERRIDE;
  64. info.m_nPhongExponent = PHONGEXPONENT;
  65. info.m_nPhongIntensity = PHONGINTENSITY;
  66. info.m_nWearProgress = WEARPROGRESS;
  67. info.m_nPaintStyle = PAINTSTYLE;
  68. info.m_nExponentMode = EXPONENTMODE;
  69. info.m_nPatternTextureTransform = PATTERNTEXTURETRANSFORM;
  70. info.m_nWearTextureTransform = WEARTEXTURETRANSFORM;
  71. info.m_nGrungeTextureTransform = GRUNGETEXTURETRANSFORM;
  72. info.m_nCheap = CHEAPMODE;
  73. info.m_nPhongAlbedoFactor = PHONGALBEDOFACTOR;
  74. info.m_nPreview = PREVIEW;
  75. info.m_nPreviewPhongFresnelRanges = PHONGFRESNELRANGES;
  76. info.m_nPreviewPhongAlbedoTint = PHONGALBEDOTINT;
  77. info.m_nPreviewPhongBoost = PHONGBOOST;
  78. info.m_nPhongAlbedoBoost = PHONGALBEDOBOOST;
  79. info.m_nPreviewPaintPhongAlbedoBoost = PAINTPHONGALBEDOBOOST;
  80. info.m_nPreviewWeaponObjScale = PREVIEWWEAPONOBJSCALE;
  81. info.m_nPreviewWeaponUVScale = PREVIEWWEAPONUVSCALE;
  82. info.m_nPreviewIgnoreWeaponScale = PREVIEWIGNOREWEAPONSCALE;
  83. }
  84. SHADER_INIT_PARAMS()
  85. {
  86. CustomWeaponVars_t info;
  87. SetupVarsCustomWeapon( info );
  88. InitParamsCustomWeapon( this, params, pMaterialName, info );
  89. }
  90. SHADER_FALLBACK
  91. {
  92. return 0;
  93. }
  94. SHADER_INIT
  95. {
  96. CustomWeaponVars_t info;
  97. SetupVarsCustomWeapon( info );
  98. InitCustomWeapon( this, params, info );
  99. }
  100. SHADER_DRAW
  101. {
  102. CustomWeaponVars_t info;
  103. SetupVarsCustomWeapon( info );
  104. DrawCustomWeapon( this, params, pShaderAPI, pShaderShadow, info, vertexCompression, pContextDataPtr );
  105. }
  106. END_SHADER