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.

40 lines
1.1 KiB

  1. const float3 g_OverbrightFactor : register( c0 );
  2. const float3 g_SelfIllumTint : register( c1 );
  3. const float3 g_EnvmapTint : register( c2 );
  4. sampler BumpmapSampler : register( s0 );
  5. struct PS_INPUT
  6. {
  7. float2 vBumpTexCoord : TEXCOORD0;
  8. float3 vTangentSpaceLightDir : TEXCOORD1;
  9. float3 vAmbientColor : TEXCOORD2;
  10. float4 vDirLightScale : COLOR0;
  11. };
  12. float4 main( PS_INPUT i ) : COLOR
  13. {
  14. float4 baseColor = tex2D( BumpmapSampler, i.vBumpTexCoord );
  15. // Dot the bump normal and the light vector.
  16. float4 vBumpMapNormal = (baseColor - 0.5); // The format of the sphere map is 0 to 1,
  17. // so this is now -0.5 to 0.5.
  18. float3 vTangentSpaceLightDir = (i.vTangentSpaceLightDir - 0.5) * 2; // This is -1 to 1
  19. float4 vOutput = dot( vBumpMapNormal, vTangentSpaceLightDir ) + 0.5;
  20. // Scale by the light color outputted by the vertex shader (ie: based on distance).
  21. vOutput *= i.vDirLightScale;
  22. // Add ambient.
  23. vOutput += float4( i.vAmbientColor.x, i.vAmbientColor.y, i.vAmbientColor.z, 0 );
  24. // Alpha = normal map alpha * vertex alpha
  25. vOutput.a = baseColor.a * i.vDirLightScale.a;
  26. return vOutput;
  27. }