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.

162 lines
7.5 KiB

  1. //========= Copyright � 1996-2007, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Blob shader
  4. //
  5. //=============================================================================//
  6. #include "BaseVSShader.h"
  7. #include "Blob_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( Blob, Blob_dx9 )
  12. BEGIN_VS_SHADER( Blob_dx9, "Blob" )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( BACKSURFACE, SHADER_PARAM_TYPE_BOOL, "0.0", "specify that this is the back surface of the blob" )
  15. SHADER_PARAM( NORMALMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "normal map" )
  16. SHADER_PARAM( SPECMASKTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "specular reflection mask" )
  17. SHADER_PARAM( LIGHTWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for tinting scalar diffuse term" )
  18. SHADER_PARAM( FRESNELWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for controlling fresnel falloff" )
  19. SHADER_PARAM( OPACITYTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for controlling fresnel falloff" )
  20. SHADER_PARAM( UVSCALE, SHADER_PARAM_TYPE_FLOAT, "0.02", "uv projection scale" )
  21. SHADER_PARAM( BUMPSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "bump map strength" )
  22. SHADER_PARAM( FRESNELBUMPSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "bump map strength for fresnel" )
  23. SHADER_PARAM( TRANSLUCENTFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.8 1.0 1.0]", "fresnel params" )
  24. SHADER_PARAM( INTERIOR, SHADER_PARAM_TYPE_BOOL, "1", "Enable interior layer" )
  25. SHADER_PARAM( INTERIORFOGSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.06", "fog strength (scales with thickness of the interior volume)" )
  26. SHADER_PARAM( INTERIORFOGLIMIT, SHADER_PARAM_TYPE_FLOAT, "0.8", "fog opacity beyond the range of destination alpha depth (in low-precision depth mode)" )
  27. SHADER_PARAM( INTERIORFOGNORMALBOOST, SHADER_PARAM_TYPE_FLOAT, "0.0", "degree to boost interior thickness/fog by 'side-on'ness of vertex normals to the camera" )
  28. SHADER_PARAM( INTERIORBACKGROUNDBOOST, SHADER_PARAM_TYPE_FLOAT, "7", "boosts the brightness of bright background pixels" )
  29. SHADER_PARAM( INTERIORAMBIENTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales ambient light in the interior volume" );
  30. SHADER_PARAM( INTERIORBACKLIGHTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales backlighting in the interior volume" );
  31. SHADER_PARAM( INTERIORCOLOR, SHADER_PARAM_TYPE_VEC3, "[0.7 0.5 0.45]", "tints light in the interior volume" )
  32. SHADER_PARAM( INTERIORREFRACTSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.015", "strength of bumped refract of the background seen through the interior" )
  33. SHADER_PARAM( INTERIORREFRACTBLUR, SHADER_PARAM_TYPE_FLOAT, "0.2", "strength of blur applied to the background seen through the interior" )
  34. SHADER_PARAM( DIFFUSEBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
  35. SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
  36. SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
  37. SHADER_PARAM( PHONGEXPONENT2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
  38. SHADER_PARAM( PHONGBOOST2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
  39. SHADER_PARAM( RIMLIGHTEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light exponent" )
  40. SHADER_PARAM( RIMLIGHTBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light boost" )
  41. SHADER_PARAM( BASECOLORTINT, SHADER_PARAM_TYPE_VEC3, "[1.0 1.0 1.0]", "base texture tint" )
  42. SHADER_PARAM( SELFILLUMFRESNEL, SHADER_PARAM_TYPE_BOOL, "0", "enable self illum fresnel term" )
  43. SHADER_PARAM( SELFILLUMFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.7 0.5 0.45]", "min max exponent" )
  44. SHADER_PARAM( SELFILLUMTINT, SHADER_PARAM_TYPE_VEC3, "[0.7 0.5 0.45]", "selfillum color tint" )
  45. SHADER_PARAM( UVPROJOFFSET, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "Center for UV projection" )
  46. SHADER_PARAM( BBMIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
  47. SHADER_PARAM( BBMAX, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
  48. SHADER_PARAM( ARMATURE, SHADER_PARAM_TYPE_BOOL, "0", "armature" )
  49. SHADER_PARAM( ARMCOLOR, SHADER_PARAM_TYPE_VEC3, "[1 1 1]", "arm color" )
  50. SHADER_PARAM( ARMWIDEN, SHADER_PARAM_TYPE_BOOL, "0", "widen arms at end instead of taper" )
  51. SHADER_PARAM( ARMWIDTHEXP, SHADER_PARAM_TYPE_FLOAT, "1", "" )
  52. SHADER_PARAM( ARMWIDTHSCALE, SHADER_PARAM_TYPE_FLOAT, "1", "" )
  53. SHADER_PARAM( ARMWIDTHBIAS, SHADER_PARAM_TYPE_FLOAT, "0", "" )
  54. SHADER_PARAM( ANIMATEARMPULSES, SHADER_PARAM_TYPE_BOOL, "1", "" )
  55. SHADER_PARAM( GLOWSCALE, SHADER_PARAM_TYPE_FLOAT, "4", "Scale value applied to self-illum vertex colours" )
  56. SHADER_PARAM( PULSE, SHADER_PARAM_TYPE_BOOL, "1", "" )
  57. SHADER_PARAM( CONTACTSHADOWS, SHADER_PARAM_TYPE_BOOL, "1", "" )
  58. SHADER_PARAM( VOLUMETEXTURETEST, SHADER_PARAM_TYPE_BOOL, "0", "" )
  59. SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
  60. END_SHADER_PARAMS
  61. void SetupVarsBlob( BlobVars_t &info )
  62. {
  63. info.m_nBackSurface = BACKSURFACE;
  64. info.m_nBaseTexture = BASETEXTURE;
  65. info.m_nNormalMap = NORMALMAP;
  66. info.m_nSpecMap = SPECMASKTEXTURE;
  67. info.m_nLightWarpTexture = LIGHTWARPTEXTURE;
  68. info.m_nFresnelWarpTexture = FRESNELWARPTEXTURE;
  69. info.m_nOpacityTexture = OPACITYTEXTURE;
  70. info.m_nBumpStrength = BUMPSTRENGTH;
  71. info.m_nFresnelBumpStrength = FRESNELBUMPSTRENGTH;
  72. info.m_nUVScale = UVSCALE;
  73. info.m_nInteriorEnable = INTERIOR;
  74. info.m_nInteriorFogStrength = INTERIORFOGSTRENGTH;
  75. info.m_nInteriorFogLimit = INTERIORFOGLIMIT;
  76. info.m_nInteriorFogNormalBoost = INTERIORFOGNORMALBOOST;
  77. info.m_nInteriorBackgroundBoost = INTERIORBACKGROUNDBOOST;
  78. info.m_nInteriorAmbientScale = INTERIORAMBIENTSCALE;
  79. info.m_nInteriorBackLightScale = INTERIORBACKLIGHTSCALE;
  80. info.m_nInteriorColor = INTERIORCOLOR;
  81. info.m_nInteriorRefractStrength = INTERIORREFRACTSTRENGTH;
  82. info.m_nInteriorRefractBlur = INTERIORREFRACTBLUR;
  83. info.m_nFresnelParams = TRANSLUCENTFRESNELMINMAXEXP;
  84. info.m_nDiffuseScale = DIFFUSEBOOST;
  85. info.m_nSpecExp = PHONGEXPONENT;
  86. info.m_nSpecScale = PHONGBOOST;
  87. info.m_nSpecExp2 = PHONGEXPONENT2;
  88. info.m_nSpecScale2 = PHONGBOOST2;
  89. info.m_nRimLightExp = RIMLIGHTEXPONENT;
  90. info.m_nRimLightScale = RIMLIGHTBOOST;
  91. info.m_nBaseColorTint = BASECOLORTINT;
  92. info.m_nSelfIllumFresnelEnable = SELFILLUMFRESNEL;
  93. info.m_nSelfIllumFresnelParams = SELFILLUMFRESNELMINMAXEXP;
  94. info.m_nSelfIllumTint = SELFILLUMTINT;
  95. info.m_nUVProjOffset = UVPROJOFFSET;
  96. info.m_nBBMin = BBMIN;
  97. info.m_nBBMax = BBMAX;
  98. info.m_nArmature = ARMATURE;
  99. info.m_nFlashlightTexture = FLASHLIGHTTEXTURE;
  100. info.m_nFlashlightTextureFrame = FLASHLIGHTTEXTUREFRAME;
  101. info.m_nArmColorTint = ARMCOLOR;
  102. info.m_nArmWiden = ARMWIDEN;
  103. info.m_nArmWidthExp = ARMWIDTHEXP;
  104. info.m_nArmWidthScale = ARMWIDTHSCALE;
  105. info.m_nArmWidthBias = ARMWIDTHBIAS;
  106. info.m_nAnimateArmPulses = ANIMATEARMPULSES;
  107. info.m_nVolumeTex = VOLUMETEXTURETEST;
  108. info.m_nBumpFrame = BUMPFRAME;
  109. info.m_nGlowScale = GLOWSCALE;
  110. info.m_nPulse = PULSE;
  111. info.m_nContactShadows = CONTACTSHADOWS;
  112. }
  113. SHADER_INIT_PARAMS()
  114. {
  115. BlobVars_t info;
  116. SetupVarsBlob( info );
  117. InitParamsBlob( this, params, pMaterialName, info );
  118. }
  119. SHADER_FALLBACK
  120. {
  121. // TODO: Reasonable fallback
  122. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  123. {
  124. return "Wireframe";
  125. }
  126. return 0;
  127. }
  128. SHADER_INIT
  129. {
  130. BlobVars_t info;
  131. SetupVarsBlob( info );
  132. InitBlob( this, params, info );
  133. }
  134. SHADER_DRAW
  135. {
  136. BlobVars_t info;
  137. SetupVarsBlob( info );
  138. DrawBlob( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
  139. }
  140. END_SHADER