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.

28 lines
776 B

  1. //
  2. // Custom Fresnel with low, mid and high parameters defining a piecewise continuous function
  3. // with traditional fresnel (0 to 1 range) as input. The 0 to 0.5 range blends between
  4. // low and mid while the 0.5 to 1 range blends between mid and high
  5. //
  6. // |
  7. // | . M . . . H
  8. // | .
  9. // L
  10. // |
  11. // +----------------
  12. // 0 1
  13. //
  14. float FresnelHack( const float3 vNormal, const float3 vEyeDir, float3 vRanges, float fSpecMask )
  15. {
  16. float result, f = Fresnel( vNormal, vEyeDir ); // Traditional Fresnel
  17. if ( f > 0.5f )
  18. {
  19. result = lerp( vRanges.y, vRanges.z, (2*f)-1 ); // Blend between mid and high values
  20. }
  21. else
  22. {
  23. result = lerp( fSpecMask * vRanges.x, vRanges.y, 2*f ); // Blend between low and mid values
  24. }
  25. return result;
  26. }