This repository has been archived on 2024-06-19. You can view files and clone it, but cannot push or open issues or pull requests.
evermillion/Assets/Forst/CTI Runtime Components/CTI Runtime Components BIRP/Scripts/CTI_Utils.cs
2024-06-05 11:10:54 +08:00

29 lines
1.1 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace CTI {
public static class CTI_Utils {
// Function to adjust the translucent lighting fade according to the given shadow distance  or any othe distance that is passed in
// @params:
// (float) TranslucentLightingRange : Range in which translucent lighting will be applied most likely the shadow distance as set in Quality Settings
// (float) FadeLengthFactor : Lenth relative to TranslucentLightingRange over which the fade will take place (0.0 - 1.0 range)
public static void SetTranslucentLightingFade(float TranslucentLightingRange, float FadeLengthFactor) {
TranslucentLightingRange *= 0.9f; // Add some padding as real time shadows fade out as well
var FadeLength = TranslucentLightingRange * FadeLengthFactor;
// Pleae note: We use sqr distances here!
Shader.SetGlobalVector ("_CTI_TransFade",
new Vector2(
TranslucentLightingRange * TranslucentLightingRange,
FadeLength * FadeLength * ( (TranslucentLightingRange / FadeLength) * 2.0f )
)
);
}
}
}