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.

87 lines
2.2 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // DYNAMIC: "DZONE" "0..1"
  3. #include "common_fog_vs_fxc.h"
  4. #include "common_vs_fxc.h"
  5. const float4 vConst0 : register(SHADER_SPECIFIC_CONST_0);
  6. #define g_time vConst0.x
  7. #define g_scale vConst0.y
  8. const float4 vConst3 : register(SHADER_SPECIFIC_CONST_3);
  9. #define g_dzCenter vConst3.xyz
  10. #define g_dzRadius vConst3.w
  11. static const int g_FogType = DOWATERFOG;
  12. struct VS_INPUT
  13. {
  14. float4 vPos : POSITION;
  15. float4 vColor : COLOR0;
  16. float4 vTexCoord0 : TEXCOORD0;
  17. //float4 vTexCoord1 : TEXCOORD1;
  18. };
  19. struct VS_OUTPUT
  20. {
  21. float4 projPos : POSITION; // Projection-space position
  22. float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
  23. float4 color : TEXCOORD2; // Vertex color (from lighting or unlit)
  24. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  25. float fog : FOG;
  26. #endif
  27. float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
  28. };
  29. VS_OUTPUT main( const VS_INPUT v )
  30. {
  31. VS_OUTPUT o = ( VS_OUTPUT )0;
  32. float3 worldPos;
  33. worldPos = mul( v.vPos, cModel[0] );
  34. float3 v2p = worldPos - cEyePos;
  35. float l = length(v2p);
  36. float3 up = float3(0,0,1);
  37. float3 right = normalize(cross(up, normalize(v2p)));
  38. float flScale = smoothstep( 2500, 2200, l ) * g_scale;
  39. float flCrush = smoothstep( 20, 60, l );
  40. #if ( DZONE == 1 )
  41. flScale *= smoothstep( g_dzRadius, g_dzRadius - 200, length( worldPos - g_dzCenter ) );
  42. #endif
  43. worldPos.z -= v.vTexCoord0.w * flScale * flCrush;
  44. worldPos.xy -= right.xy * v.vTexCoord0.z * flScale;
  45. float flRipple = 4 * sin( g_time + worldPos.x ) + sin( 2 * g_time + worldPos.y );
  46. float flZscale = (v.vTexCoord0.w * -0.01f);
  47. worldPos.xy -= right.xy * flRipple * flZscale;
  48. // Transform into projection space
  49. o.projPos = mul( float4( worldPos, 1 ), cViewProj );
  50. o.worldPos_projPosZ = float4( worldPos.xyz, o.projPos.z );
  51. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  52. o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
  53. #endif
  54. o.color.rgba = v.vColor.rgba;
  55. // darken bottom of grass - TODO: make material params
  56. o.color.rgb *= saturate( pow( flZscale, 0.01 ) + 0.5 );
  57. // Base texture coordinates
  58. o.baseTexCoord.xy = v.vTexCoord0.xy;
  59. return o;
  60. }