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.

31 lines
1.1 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. //
  3. // Run procedural glint generation inner loop in pixel shader (ps_2_0)
  4. //
  5. // ==========================================================================//
  6. struct PS_INPUT
  7. {
  8. float2 tc : TEXCOORD0; // Interpolated coordinate of current texel
  9. float2 glintCenter : TEXCOORD1; // Uniform value containing center of glint
  10. float3 glintColor : TEXCOORD2; // Uniform value of color of glint
  11. };
  12. float GlintGaussSpotCoefficient( float2 d )
  13. {
  14. return saturate( exp( -25.0f * dot(d, d) ) );
  15. }
  16. float4 main( PS_INPUT i ) : COLOR
  17. {
  18. float2 uv = i.tc - i.glintCenter; // This texel relative to glint center
  19. float intensity = GlintGaussSpotCoefficient( uv + float2(-0.25f, -0.25f) ) +
  20. GlintGaussSpotCoefficient( uv + float2( 0.25f, -0.25f) ) +
  21. 5 * GlintGaussSpotCoefficient( uv ) +
  22. GlintGaussSpotCoefficient( uv + float2(-0.25f, 0.25f) ) +
  23. GlintGaussSpotCoefficient( uv + float2( 0.25f, 0.25f) );
  24. intensity *= 4.0f/9.0f;
  25. return float4( intensity * i.glintColor, 1.0f );
  26. }