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.

77 lines
1.9 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. // STATIC: "MODEL" "0..1"
  7. #include "common_fog_vs_fxc.h"
  8. #include "common_vs_fxc.h"
  9. //const float4 cBaseTexCoordTransform[ 2 ] : register( SHADER_SPECIFIC_CONST_6 );
  10. const float4 g_flProjectedSizeRotation : register( c49 );
  11. const float4 g_vProjectionOrigin : register( c48 );
  12. struct VS_INPUT
  13. {
  14. float3 vPos : POSITION;
  15. float4 vNormal : NORMAL;
  16. };
  17. struct VS_OUTPUT
  18. {
  19. float4 vProjPos : POSITION;
  20. float2 vBaseTexCoord : TEXCOORD0;
  21. };
  22. static const float3 Normal = float3( 0, 0, -1.0 );
  23. float3 ClosestPointOnPlane( float3 TestPoint )
  24. {
  25. float distance = dot( Normal, TestPoint - g_vProjectionOrigin );
  26. return TestPoint - distance*Normal;
  27. }
  28. float2 ComputeTexCoord( const float3 vWorldPos, const float flRotation, const float flScale )
  29. {
  30. float3 vTest = ClosestPointOnPlane( vWorldPos );
  31. float2 vBaseCoord = ( ( vTest - g_vProjectionOrigin ) / g_flProjectedSizeRotation.x ) + 0.5f;
  32. float2 vAdjust = vBaseCoord - float2( 0.5, 0.5 );
  33. float2 vResult;
  34. float c = cos( flRotation );
  35. float s = sin( flRotation );
  36. vResult.x = ( vAdjust.x * c ) + ( vAdjust.y * -s );
  37. vResult.y = ( vAdjust.x * s ) + ( vAdjust.y * c );
  38. return ( vResult / flScale ) + float2( 0.5, 0.5 );
  39. }
  40. VS_OUTPUT main( const VS_INPUT v )
  41. {
  42. VS_OUTPUT o;
  43. float3 vNewPos = v.vPos;
  44. // vNewPos.z += 128.0;
  45. float3 vObjNormal;
  46. DecompressVertex_Normal( v.vNormal, vObjNormal );
  47. float4 vProjPos;
  48. float3 vWorldPos;
  49. vWorldPos = mul( float4( vNewPos, 1 ), cModel[0] );
  50. vProjPos = mul( float4( vWorldPos, 1 ), cViewProj );
  51. o.vProjPos = vProjPos;
  52. // float3 worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] );
  53. o.vBaseTexCoord = ComputeTexCoord( vWorldPos, g_flProjectedSizeRotation.y, 1.0 );
  54. return o;
  55. }