CTI_Utils.cs 1.1 KB

12345678910111213141516171819202122232425262728
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace CTI {
  5. public static class CTI_Utils {
  6. // Function to adjust the translucent lighting fade according to the given shadow distance – or any othe distance that is passed in
  7. // @params:
  8. // (float) TranslucentLightingRange : Range in which translucent lighting will be applied – most likely the shadow distance as set in Quality Settings
  9. // (float) FadeLengthFactor : Lenth relative to TranslucentLightingRange over which the fade will take place (0.0 - 1.0 range)
  10. public static void SetTranslucentLightingFade(float TranslucentLightingRange, float FadeLengthFactor) {
  11. TranslucentLightingRange *= 0.9f; // Add some padding as real time shadows fade out as well
  12. var FadeLength = TranslucentLightingRange * FadeLengthFactor;
  13. // Pleae note: We use sqr distances here!
  14. Shader.SetGlobalVector ("_CTI_TransFade",
  15. new Vector2(
  16. TranslucentLightingRange * TranslucentLightingRange,
  17. FadeLength * FadeLength * ( (TranslucentLightingRange / FadeLength) * 2.0f )
  18. )
  19. );
  20. }
  21. }
  22. }