Team Fortress 2 Source Code as on 22/4/2020
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.

83 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "BaseVSShader.h"
  3. #include "portal_refract_dx8_helper.h"
  4. // memdbgon must be the last include file in a .cpp file!!!
  5. #include "tier0/memdbgon.h"
  6. DEFINE_FALLBACK_SHADER( PortalRefract, PortalRefract_dx8 )
  7. BEGIN_VS_SHADER( PortalRefract_dx8, "PortalRefract_dx8" )
  8. BEGIN_SHADER_PARAMS
  9. SHADER_PARAM( STAGE, SHADER_PARAM_TYPE_INTEGER, "0", "Stage of portal rendering (0, 1, 2)" )
  10. SHADER_PARAM( PORTALOPENAMOUNT, SHADER_PARAM_TYPE_FLOAT, "0.0", "Portal open amount 0.0-1.0" )
  11. SHADER_PARAM( PORTALSTATIC, SHADER_PARAM_TYPE_FLOAT, "0.0", "Portal static amount 0.0-1.0" )
  12. SHADER_PARAM( PORTALMASKTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Mask texture" )
  13. SHADER_PARAM( TEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "Texcoord transform" )
  14. SHADER_PARAM( PORTALCOLORTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Color texture" )
  15. SHADER_PARAM( PORTALCOLORSCALE, SHADER_PARAM_TYPE_FLOAT, "0.0", "Portal color scale" )
  16. END_SHADER_PARAMS
  17. void SetupVarsPortalRefract_DX8( PortalRefractVarsDX8_t &info )
  18. {
  19. info.m_nStage = STAGE;
  20. info.m_nPortalOpenAmount = PORTALOPENAMOUNT;
  21. info.m_nPortalStatic = PORTALSTATIC;
  22. info.m_nPortalMaskTexture = PORTALMASKTEXTURE;
  23. info.m_nTextureTransform = TEXTURETRANSFORM;
  24. info.m_nPortalColorTexture = PORTALCOLORTEXTURE;
  25. info.m_nPortalColorScale = PORTALCOLORSCALE;
  26. }
  27. bool NeedsPowerOfTwoFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame ) const
  28. {
  29. return false;
  30. }
  31. SHADER_INIT_PARAMS()
  32. {
  33. PortalRefractVarsDX8_t info;
  34. SetupVarsPortalRefract_DX8( info );
  35. InitParamsPortalRefract_DX8( this, params, pMaterialName, info );
  36. }
  37. SHADER_FALLBACK
  38. {
  39. if ( g_pHardwareConfig->GetDXSupportLevel() < 80 )
  40. {
  41. return "Wireframe";
  42. }
  43. return 0;
  44. }
  45. SHADER_INIT
  46. {
  47. PortalRefractVarsDX8_t info;
  48. SetupVarsPortalRefract_DX8( info );
  49. InitPortalRefract_DX8( this, params, info );
  50. }
  51. SHADER_DRAW
  52. {
  53. // Skip drawing stage 0 in DX8
  54. bool bDraw = true;
  55. if ( params[STAGE]->GetIntValue() == 0 )
  56. {
  57. bDraw = false;
  58. }
  59. // If ( snapshotting ) or ( we need to draw this frame )
  60. if ( ( pShaderShadow != NULL ) || ( bDraw == true ) )
  61. {
  62. PortalRefractVarsDX8_t info;
  63. SetupVarsPortalRefract_DX8( info );
  64. DrawPortalRefract_DX8( this, params, pShaderAPI, pShaderShadow, info );
  65. }
  66. else // We're not snapshotting and we don't need to draw this frame
  67. {
  68. // Skip this pass!
  69. Draw( false );
  70. }
  71. }
  72. END_SHADER