Skip to content
Snippets Groups Projects
Commit 60efd25d authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Add Readme

parent f24d3015
No related branches found
No related tags found
No related merge requests found
......@@ -12,10 +12,10 @@ public class LightFlicker : MonoBehaviour
[Tooltip("Intensity of the periodic brightness fluctuations")]
[Range(0.0f, 10.0f)]
public float oscillationIntensity = 2.0f;
public float fluctuationIntensity = 2.0f;
[Tooltip("Frequency of the periodic brightness fluctuations")]
[Range(0.0f, 100.0f)]
public float oscillationSpeed = 44.0f;
public float fluctuationSpeed = 44.0f;
[Tooltip("Intensity of the random brightness flicker")]
[Range(0.0f, 10.0f)]
......@@ -27,19 +27,19 @@ public class LightFlicker : MonoBehaviour
[Range(0.0f, 1.0f)]
public float flickerOffVsOn = 0.5f;
[Tooltip("Frequency of the normality effect (where flicker and oscillations are switched off)")]
[Tooltip("Frequency of the normality effect (where flicker and fluctuations are switched off)")]
[Range(0.0f, 1.0f)]
public float normalitySpeed = 0.1f;
[Tooltip("Likelyhood of the normality effect to happen (where flicker and oscillations are switched off)")]
[Tooltip("Likelihood of the normality effect to happen (where flicker and fluctuations are switched off)")]
[Range(0.0f, 1.0f)]
public float normalityLikelyhood = 0.5f;
public float normalityLikelihood = 0.5f;
float randomWalk = 0.0f;
float flickerBrightness = 0.0f;
float upperBound = 1.0f;
float lowerBound = -1.0f;
float oscillationBrightness = 0.0f;
float fluctuationBrightness = 0.0f;
float randomWalk2 = 0.0f;
float upperBound2 = 1.0f;
......@@ -61,19 +61,19 @@ public class LightFlicker : MonoBehaviour
if (randomWalk <= lowerBound) { randomWalk = lowerBound; }
flickerBrightness = (randomWalk * flickerIntensity) + (-8.0f + flickerOffVsOn * 16.0f) * flickerIntensity;
// Oscillation
oscillationBrightness = ((Mathf.PingPong(Time.time*oscillationSpeed, 8.0f) * Mathf.PingPong(Time.time*oscillationSpeed*1.131517f,4.0f)) - 4.0f) * oscillationIntensity*0.1f;
// fluctuation
fluctuationBrightness = ((Mathf.PingPong(Time.time*fluctuationSpeed, 8.0f) * Mathf.PingPong(Time.time*fluctuationSpeed*1.131517f,4.0f)) - 4.0f) * fluctuationIntensity*0.1f;
// Normality
randomWalk2 += Random.Range(-normalitySpeed * 0.2f, normalitySpeed * 0.2f);
if (randomWalk2 >= upperBound2) { randomWalk2 = upperBound2; }
if (randomWalk2 <= lowerBound2) { randomWalk2 = lowerBound2; }
if (randomWalk2 <= normalityLikelyhood)
if (randomWalk2 <= normalityLikelihood)
{
thisLight.intensity = baseBrightness;
} else {
thisLight.intensity = baseBrightness + flickerBrightness + oscillationBrightness;
thisLight.intensity = baseBrightness + flickerBrightness + fluctuationBrightness;
}
}
}
\ No newline at end of file
# LightFlicker
This is a script for the creation of post-apocalyptic light-flickering. Just put it on a light source and tune the settings.
## Settings
The light flicker effect has 4 different main components:
1. The **base brightness** (how bright the light is as a base value)
2. periodic **fluctuations** of the brightness
3. aperiodic **flicker** of the brightness
4. occasional periods of **normality** where the light works as intended
## Settings-Table
| Setting | Explaination |
| --------------------- | ------------------------------------------------------------ |
| Base Brightness | The basic brightness of the light, with `0.0` meaning no light and `8.0` meaning maximum intensity light. This is used as a baseline for the effects and used when the normality-effect is active. |
| Fluctuation Intensity | The intensity of the bipolar fluctuations, with `0.0` meaning the fluctuation effect is switched off and `10.0` meaning the oscillations between very bright and off are at their most extreme. |
| Fluctuation Speed | |
| Flicker Intensity | The intensity of the aperiodic flicker, with `0.0` meaning the flicker effect is switched off and `10.0` meaning the flickering between very bright and off are at their most extreme. |
| Flicker Speed | The speed of the flicker effect. Small values are slow, big values fast. |
| Flicker Off Vs On | The likelihood of the flicker effect to lean to the dark or the bright side. The default value of `0.5` means there are 50% dark and 50% bright flickers over time, a value approaching `0.0` would mean the light would be mostly off, while a value of `1.0` would mean the light is mostly on |
| Normality Speed | The speed of the normality effect. Affect how long the effect stays on or off when activated. Small values are slow, big values fast. |
| Normality Likelihood | The likelihood with which "normal" periods occur, where the light is not affected by flicker and fluctuation. The default value of `0.5` means over time normal and "anormal" periods will be have a 50/50 chance of happening, a value approaching `0.0` would mean there is never any normality, while a value of `1.0` would mean the light is only normal. |
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment