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.

72 lines
2.4 KiB

  1. #include "common_fog_vs_fxc.h"
  2. // STATIC: "ENVMAP_MASK" "0..1"
  3. #include "common_vs_fxc.h"
  4. static const int g_FogType = DOWATERFOG;
  5. static const bool g_UseSeparateEnvmapMask = ENVMAP_MASK;
  6. const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
  7. const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_2 );
  8. struct VS_INPUT
  9. {
  10. float3 vPos : POSITION;
  11. float4 vNormal : NORMAL;
  12. float2 vBaseTexCoord : TEXCOORD0;
  13. float2 vLightmapTexCoord : TEXCOORD1;
  14. float2 vDetailTexCoord : TEXCOORD2;
  15. };
  16. struct VS_OUTPUT
  17. {
  18. float4 projPos : POSITION;
  19. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  20. float fog : FOG;
  21. #endif
  22. float2 baseTexCoord : TEXCOORD0;
  23. float2 detailTexCoord : TEXCOORD1;
  24. float2 lightmapTexCoord : TEXCOORD2;
  25. float2 envmapMaskTexCoord : TEXCOORD3;
  26. float4 worldPos_projPosZ : TEXCOORD4;
  27. float3 worldNormal : TEXCOORD5;
  28. float4 vertexColor : COLOR;
  29. };
  30. VS_OUTPUT main( const VS_INPUT v )
  31. {
  32. VS_OUTPUT o = ( VS_OUTPUT )0;
  33. float3 vObjNormal;
  34. DecompressVertex_Normal( v.vNormal, vObjNormal );
  35. float4 projPos;
  36. projPos = mul( float4( v.vPos, 1 ), cModelViewProj );
  37. o.projPos = projPos;
  38. #ifdef _PS3
  39. // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
  40. o.projPos.y = -o.projPos.y;
  41. o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
  42. #endif // _PS3
  43. o.worldPos_projPosZ.w = projPos.z;
  44. o.worldPos_projPosZ.xyz = mul4x3( float4( v.vPos, 1 ), cModel[0] );
  45. o.worldNormal = mul3x3( vObjNormal, ( float3x3 )cModel[0] );
  46. o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0].xy ) + cBaseTexCoordTransform[0].w;
  47. o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1].xy ) + cBaseTexCoordTransform[1].w;
  48. o.detailTexCoord.x = dot( v.vDetailTexCoord, cDetailTexCoordTransform[0].xy ) + cDetailTexCoordTransform[0].w;
  49. o.detailTexCoord.y = dot( v.vDetailTexCoord, cDetailTexCoordTransform[1].xy ) + cDetailTexCoordTransform[1].w;
  50. o.envmapMaskTexCoord.x = dot( v.vDetailTexCoord, cDetailTexCoordTransform[0].xy ) + cDetailTexCoordTransform[0].w;
  51. o.envmapMaskTexCoord.y = dot( v.vDetailTexCoord, cDetailTexCoordTransform[1].xy ) + cDetailTexCoordTransform[1].w;
  52. o.lightmapTexCoord = v.vLightmapTexCoord;
  53. #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
  54. o.fog = CalcFixedFunctionFog( o.worldPos_projPosZ.xyz, g_FogType );
  55. #endif
  56. o.vertexColor = cModulationColor;
  57. return o;
  58. }