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.

138 lines
6.3 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 "IceSurface_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( IceSurface, IceSurface_dx9 )
  12. BEGIN_VS_SHADER( IceSurface_dx9, "IceSurface" )
  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( INTERIORFOGLIMIT, SHADER_PARAM_TYPE_FLOAT, "0.8", "fog opacity beyond the range of destination alpha depth (in low-precision depth mode)" )
  28. 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" )
  29. SHADER_PARAM( INTERIORBACKGROUNDBOOST, SHADER_PARAM_TYPE_FLOAT, "7", "boosts the brightness of bright background pixels" )
  30. SHADER_PARAM( INTERIORAMBIENTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales ambient light in the interior volume" );
  31. SHADER_PARAM( INTERIORBACKLIGHTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales backlighting in the interior volume" );
  32. SHADER_PARAM( INTERIORCOLOR, SHADER_PARAM_TYPE_VEC3, "[0.7 0.5 0.45]", "tints light in the interior volume" )
  33. SHADER_PARAM( INTERIORREFRACTSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.015", "strength of bumped refract of the background seen through the interior" )
  34. SHADER_PARAM( INTERIORREFRACTBLUR, SHADER_PARAM_TYPE_FLOAT, "0.2", "strength of blur applied to the background seen through the interior" )
  35. SHADER_PARAM( DIFFUSESCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
  36. SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
  37. SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
  38. SHADER_PARAM( PHONGEXPONENT2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
  39. SHADER_PARAM( PHONGBOOST2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
  40. SHADER_PARAM( RIMLIGHTEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light exponent" )
  41. SHADER_PARAM( RIMLIGHTBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light boost" )
  42. SHADER_PARAM( BASECOLORTINT, SHADER_PARAM_TYPE_VEC3, "[1.0 1.0 1.0]", "base texture tint" )
  43. SHADER_PARAM( ENVMAPTINT, SHADER_PARAM_TYPE_VEC3, "[1.0 1.0 1.0]", "tints the environment reflection" )
  44. SHADER_PARAM( UVPROJOFFSET, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "Center for UV projection" )
  45. SHADER_PARAM( BBMIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
  46. SHADER_PARAM( BBMAX, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
  47. SHADER_PARAM( CONTACTSHADOWS, SHADER_PARAM_TYPE_BOOL, "1", "" )
  48. SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
  49. END_SHADER_PARAMS
  50. void SetupVarsIceSurface( IceSurfaceVars_t &info )
  51. {
  52. info.m_nBackSurface = BACKSURFACE;
  53. info.m_nBaseTexture = BASETEXTURE;
  54. info.m_nNormalMap = NORMALMAP;
  55. info.m_nSpecMap = SPECMASKTEXTURE;
  56. info.m_nLightWarpTexture = LIGHTWARPTEXTURE;
  57. info.m_nFresnelWarpTexture = FRESNELWARPTEXTURE;
  58. info.m_nOpacityTexture = OPACITYTEXTURE;
  59. info.m_nEnvMap = ENVMAP;
  60. info.m_nBumpStrength = BUMPSTRENGTH;
  61. info.m_nFresnelBumpStrength = FRESNELBUMPSTRENGTH;
  62. info.m_nUVScale = UVSCALE;
  63. info.m_nInteriorEnable = INTERIOR;
  64. info.m_nInteriorFogStrength = INTERIORFOGSTRENGTH;
  65. info.m_nInteriorFogLimit = INTERIORFOGLIMIT;
  66. info.m_nInteriorFogNormalBoost = INTERIORFOGNORMALBOOST;
  67. info.m_nInteriorBackgroundBoost = INTERIORBACKGROUNDBOOST;
  68. info.m_nInteriorAmbientScale = INTERIORAMBIENTSCALE;
  69. info.m_nInteriorBackLightScale = INTERIORBACKLIGHTSCALE;
  70. info.m_nInteriorColor = INTERIORCOLOR;
  71. info.m_nInteriorRefractStrength = INTERIORREFRACTSTRENGTH;
  72. info.m_nInteriorRefractBlur = INTERIORREFRACTBLUR;
  73. info.m_nFresnelParams = TRANSLUCENTFRESNELMINMAXEXP;
  74. info.m_nDiffuseScale = DIFFUSESCALE;
  75. info.m_nSpecExp = PHONGEXPONENT;
  76. info.m_nSpecScale = PHONGBOOST;
  77. info.m_nSpecExp2 = PHONGEXPONENT2;
  78. info.m_nSpecScale2 = PHONGBOOST2;
  79. info.m_nRimLightExp = RIMLIGHTEXPONENT;
  80. info.m_nRimLightScale = RIMLIGHTBOOST;
  81. info.m_nBaseColorTint = BASECOLORTINT;
  82. info.m_nEnvMapTint = ENVMAPTINT;
  83. info.m_nUVProjOffset = UVPROJOFFSET;
  84. info.m_nBBMin = BBMIN;
  85. info.m_nBBMax = BBMAX;
  86. info.m_nFlashlightTexture = FLASHLIGHTTEXTURE;
  87. info.m_nFlashlightTextureFrame = FLASHLIGHTTEXTUREFRAME;
  88. info.m_nBumpFrame = BUMPFRAME;
  89. info.m_nContactShadows = CONTACTSHADOWS;
  90. }
  91. SHADER_INIT_PARAMS()
  92. {
  93. IceSurfaceVars_t info;
  94. SetupVarsIceSurface( info );
  95. InitParamsIceSurface( this, params, pMaterialName, info );
  96. }
  97. SHADER_FALLBACK
  98. {
  99. // TODO: Reasonable fallback
  100. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  101. {
  102. return "Wireframe";
  103. }
  104. return 0;
  105. }
  106. SHADER_INIT
  107. {
  108. IceSurfaceVars_t info;
  109. SetupVarsIceSurface( info );
  110. InitIceSurface( this, params, info );
  111. }
  112. SHADER_DRAW
  113. {
  114. IceSurfaceVars_t info;
  115. SetupVarsIceSurface( info );
  116. DrawIceSurface( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
  117. }
  118. END_SHADER