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.

128 lines
5.4 KiB

  1. //========= Copyright � 1996-2007, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Ice surface shader (for the ice gun)
  4. //
  5. //=============================================================================//
  6. #include "BaseVSShader.h"
  7. #include "paintblob_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( paintblob, paintblob_dx9 )
  12. BEGIN_VS_SHADER( paintblob_dx9, "paintblob" )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( BACKSURFACE, SHADER_PARAM_TYPE_BOOL, "0.0", "specify that this is the back surface of the ice" )
  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( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "", "environment map" )
  21. SHADER_PARAM( UVSCALE, SHADER_PARAM_TYPE_FLOAT, "0.02", "uv projection scale" )
  22. SHADER_PARAM( BUMPSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "bump map strength" )
  23. SHADER_PARAM( FRESNELBUMPSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "bump map strength for fresnel" )
  24. SHADER_PARAM( TRANSLUCENTFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.8 1.0 1.0]", "fresnel params" )
  25. SHADER_PARAM( INTERIOR, SHADER_PARAM_TYPE_BOOL, "1", "Enable interior layer" )
  26. SHADER_PARAM( INTERIORFOGSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.06", "fog strength (scales with thickness of the interior volume)" )
  27. SHADER_PARAM( INTERIORBACKGROUNDBOOST, SHADER_PARAM_TYPE_FLOAT, "7", "boosts the brightness of bright background pixels" )
  28. SHADER_PARAM( INTERIORAMBIENTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales ambient light in the interior volume" );
  29. SHADER_PARAM( INTERIORBACKLIGHTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales backlighting in the interior volume" );
  30. SHADER_PARAM( INTERIORREFRACTSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.015", "strength of bumped refract of the background seen through the interior" )
  31. SHADER_PARAM( DIFFUSESCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
  32. SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
  33. SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
  34. SHADER_PARAM( PHONGEXPONENT2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
  35. SHADER_PARAM( PHONGBOOST2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
  36. SHADER_PARAM( RIMLIGHTEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light exponent" )
  37. SHADER_PARAM( RIMLIGHTBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light boost" )
  38. SHADER_PARAM( BASECOLORTINT, SHADER_PARAM_TYPE_VEC3, "[1.0 1.0 1.0]", "base texture tint" )
  39. SHADER_PARAM( UVPROJOFFSET, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "Center for UV projection" )
  40. SHADER_PARAM( BBMIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
  41. SHADER_PARAM( BBMAX, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
  42. SHADER_PARAM( CONTACTSHADOWS, SHADER_PARAM_TYPE_BOOL, "1", "" )
  43. SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
  44. END_SHADER_PARAMS
  45. void SetupVarsIceSurface( PaintBlobVars_t &info )
  46. {
  47. info.m_nBackSurface = BACKSURFACE;
  48. info.m_nBaseTexture = BASETEXTURE;
  49. info.m_nNormalMap = NORMALMAP;
  50. info.m_nSpecMap = SPECMASKTEXTURE;
  51. info.m_nLightWarpTexture = LIGHTWARPTEXTURE;
  52. info.m_nFresnelWarpTexture = FRESNELWARPTEXTURE;
  53. info.m_nOpacityTexture = OPACITYTEXTURE;
  54. info.m_nEnvMap = ENVMAP;
  55. info.m_nBumpStrength = BUMPSTRENGTH;
  56. info.m_nFresnelBumpStrength = FRESNELBUMPSTRENGTH;
  57. info.m_nUVScale = UVSCALE;
  58. info.m_nInteriorEnable = INTERIOR;
  59. info.m_nInteriorFogStrength = INTERIORFOGSTRENGTH;
  60. info.m_nInteriorBackgroundBoost = INTERIORBACKGROUNDBOOST;
  61. info.m_nInteriorAmbientScale = INTERIORAMBIENTSCALE;
  62. info.m_nInteriorBackLightScale = INTERIORBACKLIGHTSCALE;
  63. info.m_nInteriorRefractStrength = INTERIORREFRACTSTRENGTH;
  64. info.m_nFresnelParams = TRANSLUCENTFRESNELMINMAXEXP;
  65. info.m_nDiffuseScale = DIFFUSESCALE;
  66. info.m_nSpecExp = PHONGEXPONENT;
  67. info.m_nSpecScale = PHONGBOOST;
  68. info.m_nSpecExp2 = PHONGEXPONENT2;
  69. info.m_nSpecScale2 = PHONGBOOST2;
  70. info.m_nRimLightExp = RIMLIGHTEXPONENT;
  71. info.m_nRimLightScale = RIMLIGHTBOOST;
  72. info.m_nBaseColorTint = BASECOLORTINT;
  73. info.m_nUVProjOffset = UVPROJOFFSET;
  74. info.m_nBBMin = BBMIN;
  75. info.m_nBBMax = BBMAX;
  76. info.m_nFlashlightTexture = FLASHLIGHTTEXTURE;
  77. info.m_nFlashlightTextureFrame = FLASHLIGHTTEXTUREFRAME;
  78. info.m_nBumpFrame = BUMPFRAME;
  79. info.m_nContactShadows = CONTACTSHADOWS;
  80. }
  81. SHADER_INIT_PARAMS()
  82. {
  83. PaintBlobVars_t info;
  84. SetupVarsIceSurface( info );
  85. InitParamsPaintBlob( this, params, pMaterialName, info );
  86. }
  87. SHADER_FALLBACK
  88. {
  89. // TODO: Reasonable fallback
  90. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  91. {
  92. return "Wireframe";
  93. }
  94. return 0;
  95. }
  96. SHADER_INIT
  97. {
  98. PaintBlobVars_t info;
  99. SetupVarsIceSurface( info );
  100. InitPaintBlob( this, params, info );
  101. }
  102. SHADER_DRAW
  103. {
  104. PaintBlobVars_t info;
  105. SetupVarsIceSurface( info );
  106. DrawPaintBlob( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
  107. }
  108. END_SHADER