Hallucination system setup & implementation with the infinite staircase + Fake volumetric lights test
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MonoLimboStudio
|
||||
{
|
||||
public class LightFlicker : MonoBehaviour
|
||||
{
|
||||
[Header("Light Settings")]
|
||||
public Light targetLight;
|
||||
public float minIntensity = 0.5f;
|
||||
public float maxIntensity = 1.5f;
|
||||
public float flickerSpeed = 5f;
|
||||
|
||||
[Header("Material Settings")]
|
||||
public Renderer targetRenderer;
|
||||
public string opacityProperty = "_Opacity"; // Must be a float property in your shader
|
||||
[Range(0f, 1f)] public float minOpacity = 0.2f;
|
||||
[Range(0f, 1f)] public float maxOpacity = 1.0f;
|
||||
|
||||
private Material materialInstance;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (targetRenderer != null)
|
||||
{
|
||||
materialInstance = targetRenderer.material;
|
||||
|
||||
// Validate that the property exists
|
||||
if (!materialInstance.HasProperty(opacityProperty))
|
||||
{
|
||||
Debug.LogWarning($"Material does not have a float property named '{opacityProperty}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float flickerValue = Mathf.PerlinNoise(Time.time * flickerSpeed, 0.0f);
|
||||
|
||||
// Flicker the light
|
||||
if (targetLight != null)
|
||||
{
|
||||
float intensity = Mathf.Lerp(minIntensity, maxIntensity, flickerValue);
|
||||
targetLight.intensity = intensity;
|
||||
}
|
||||
|
||||
// Adjust material opacity float
|
||||
if (materialInstance != null && materialInstance.HasProperty(opacityProperty))
|
||||
{
|
||||
float opacity = Mathf.Lerp(minOpacity, maxOpacity, flickerValue);
|
||||
materialInstance.SetFloat(opacityProperty, opacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4144428452c31843a84d459266f8212
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 299560
|
||||
packageName: Simple Fake Volume Fog
|
||||
packageVersion: 1.5
|
||||
assetPath: Assets/Mono Limbo/Simple Fake Volume/Bonus/Scripts/LightFlicker.cs
|
||||
uploadId: 823828
|
||||
Reference in New Issue
Block a user