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.

102 lines
3.9 KiB

  1. //========= Copyright � 1996-2008, Valve Corporation, All rights reserved. ============//
  2. #include "BaseVSShader.h"
  3. #include "lightshafts_helper.h"
  4. // memdbgon must be the last include file in a .cpp file!!!
  5. #include "tier0/memdbgon.h"
  6. DEFINE_FALLBACK_SHADER( LightShafts, LightShafts_dx9 )
  7. BEGIN_VS_SHADER( LightShafts_dx9, "LightShafts" )
  8. BEGIN_SHADER_PARAMS
  9. SHADER_PARAM( SHADOWDEPTHTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Shadow Depth Texture" )
  10. SHADER_PARAM( NOISETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Noise texture for non-uniform density" )
  11. SHADER_PARAM( COOKIETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Cookie Texture" )
  12. SHADER_PARAM( COOKIEFRAMENUM, SHADER_PARAM_TYPE_INTEGER, "", "Cookie Frame number for animated cookies" )
  13. SHADER_PARAM( WORLDTOTEXTURE, SHADER_PARAM_TYPE_MATRIX, "1", "World to Texture Matrix" )
  14. SHADER_PARAM( FLASHLIGHTCOLOR, SHADER_PARAM_TYPE_VEC4, "1", "Flashlight color" )
  15. SHADER_PARAM( ATTENFACTORS, SHADER_PARAM_TYPE_VEC4, "1", "Packed attenuation factors" )
  16. SHADER_PARAM( ORIGINFARZ, SHADER_PARAM_TYPE_VEC4, "1", "Light origin packed with farz" )
  17. SHADER_PARAM( QUATORIENTATION, SHADER_PARAM_TYPE_VEC4, "1", "Light orientation (quaternion)" )
  18. SHADER_PARAM( SHADOWFILTERSIZE, SHADER_PARAM_TYPE_FLOAT, "3", "Shadow filter size" )
  19. SHADER_PARAM( SHADOWATTEN, SHADER_PARAM_TYPE_FLOAT, "1", "Shadow Attenuation" )
  20. SHADER_PARAM( SHADOWJITTERSEED, SHADER_PARAM_TYPE_FLOAT, "1", "Shadow jitter seed" )
  21. SHADER_PARAM( UBERLIGHT, SHADER_PARAM_TYPE_INTEGER, "1", "Is this an uberlight?" )
  22. SHADER_PARAM( ENABLESHADOWS, SHADER_PARAM_TYPE_INTEGER, "1", "Are shadows enabled?" )
  23. SHADER_PARAM( NOISESTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1", "Strength of noise in volumetrics" )
  24. // Uberlight parameters
  25. SHADER_PARAM( UBERNEARFAR, SHADER_PARAM_TYPE_VEC4, "1", "Packed uberlight near and far parameters" )
  26. SHADER_PARAM( UBERHEIGHTWIDTH, SHADER_PARAM_TYPE_VEC4, "1", "Packed uberlight height and width parameters" )
  27. SHADER_PARAM( UBERROUNDNESS, SHADER_PARAM_TYPE_FLOAT, "1", "Uberlight roundness" )
  28. SHADER_PARAM( FLASHLIGHTTIME, SHADER_PARAM_TYPE_FLOAT, "0", "Typically driven by SFM, similar to jitter seed" )
  29. SHADER_PARAM( NUMPLANES, SHADER_PARAM_TYPE_FLOAT, "0", "Need to know this to normalize intensity" )
  30. SHADER_PARAM( VOLUMETRICINTENSITY, SHADER_PARAM_TYPE_FLOAT, "1", "Intensity of volumetrics" )
  31. END_SHADER_PARAMS
  32. void SetupVarsLightShafts( LightShaftsVars_t &info )
  33. {
  34. info.m_nCookieTexture = COOKIETEXTURE;
  35. info.m_nCookieFrameNum = COOKIEFRAMENUM;
  36. info.m_nShadowDepthTexture = SHADOWDEPTHTEXTURE;
  37. info.m_nNoiseTexture = NOISETEXTURE;
  38. info.m_nNoiseStrength = NOISESTRENGTH;
  39. info.m_nWorldToTexture = WORLDTOTEXTURE;
  40. info.m_nFlashlightColor = FLASHLIGHTCOLOR;
  41. info.m_nAttenFactors = ATTENFACTORS;
  42. info.m_nOriginFarZ = ORIGINFARZ;
  43. info.m_nQuatOrientation = QUATORIENTATION;
  44. info.m_nShadowFilterSize = SHADOWFILTERSIZE;
  45. info.m_nShadowAtten = SHADOWATTEN;
  46. info.m_nShadowJitterSeed = SHADOWJITTERSEED;
  47. info.m_nUberlight = UBERLIGHT;
  48. info.m_nEnableShadows = ENABLESHADOWS;
  49. info.m_nFlashlightTime = FLASHLIGHTTIME;
  50. info.m_nNumPlanes = NUMPLANES;
  51. // Uberlight parameters
  52. info.m_nUberNearFar = UBERNEARFAR;
  53. info.m_nUberHeightWidth = UBERHEIGHTWIDTH;
  54. info.m_nUberRoundness = UBERROUNDNESS;
  55. info.m_nVolumetricIntensity = VOLUMETRICINTENSITY;
  56. }
  57. SHADER_INIT_PARAMS()
  58. {
  59. LightShaftsVars_t info;
  60. SetupVarsLightShafts( info );
  61. InitParamsLightShafts( this, params, pMaterialName, info );
  62. }
  63. SHADER_FALLBACK
  64. {
  65. if ( !g_pHardwareConfig->HasFastVertexTextures() )
  66. {
  67. // Fallback to unlit generic
  68. return "Wireframe";
  69. }
  70. return 0;
  71. }
  72. SHADER_INIT
  73. {
  74. LightShaftsVars_t info;
  75. SetupVarsLightShafts( info );
  76. InitLightShafts( this, params, info );
  77. }
  78. SHADER_DRAW
  79. {
  80. LightShaftsVars_t info;
  81. SetupVarsLightShafts( info );
  82. DrawLightShafts( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
  83. }
  84. END_SHADER