add weather and time
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8e4f90f9f6fddf4c9dd3295d72da4ff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,275 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroAudio
|
||||
{
|
||||
public List<EnviroAudioClip> ambientClips = new List<EnviroAudioClip>();
|
||||
public List<EnviroAudioClip> weatherClips = new List<EnviroAudioClip>();
|
||||
public List<EnviroAudioClip> thunderClips = new List<EnviroAudioClip>();
|
||||
public float ambientMasterVolume = 1f;
|
||||
public float weatherMasterVolume = 1f;
|
||||
public float thunderMasterVolume = 1f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroAudioClip
|
||||
{
|
||||
public enum PlayBackType
|
||||
{
|
||||
Always,
|
||||
BasedOnSun,
|
||||
BasedOnMoon
|
||||
}
|
||||
|
||||
public bool showEditor;
|
||||
public string name;
|
||||
public AudioClip audioClip;
|
||||
public UnityEngine.Audio.AudioMixerGroup audioMixerGroup;
|
||||
public PlayBackType playBackType;
|
||||
public AudioSource myAudioSource;
|
||||
public bool loop = false;
|
||||
public float volume = 0f;
|
||||
public AnimationCurve volumeCurve = new AnimationCurve();
|
||||
public float maxVolume = 1f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[ExecuteInEditMode]
|
||||
public class EnviroAudioModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroAudio Settings;
|
||||
public EnviroAudioModule preset;
|
||||
|
||||
public float ambientVolumeModifier, weatherVolumeModifier, thunderVolumeModifier = 0f;
|
||||
|
||||
//Inspector
|
||||
public bool showAmbientSetupControls,showWeatherSetupControls,showThunderSetupControls, showAudioControls;
|
||||
|
||||
public override void Enable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
CreateAudio();
|
||||
}
|
||||
|
||||
public override void Disable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
private void Setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Cleanup()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance.Objects.audio != null)
|
||||
EnviroHelper.DestroyExtended(EnviroManager.instance.Objects.audio);
|
||||
}
|
||||
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
UpdateAudio();
|
||||
}
|
||||
|
||||
public void CreateAudio()
|
||||
{
|
||||
|
||||
if(EnviroManager.instance.Objects.audio != null)
|
||||
{
|
||||
EnviroHelper.DestroyExtended(EnviroManager.instance.Objects.audio);
|
||||
EnviroManager.instance.Objects.audio = null;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Objects.audio == null)
|
||||
{
|
||||
EnviroManager.instance.Objects.audio = new GameObject();
|
||||
EnviroManager.instance.Objects.audio.hideFlags = HideFlags.DontSave;
|
||||
EnviroManager.instance.Objects.audio.name = "Audio";
|
||||
EnviroManager.instance.Objects.audio.transform.SetParent(EnviroManager.instance.transform);
|
||||
EnviroManager.instance.Objects.audio.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
//Ambient
|
||||
for(int i = 0; i < Settings.ambientClips.Count; i++)
|
||||
{
|
||||
if(Settings.ambientClips[i].myAudioSource != null)
|
||||
EnviroHelper.DestroyExtended(Settings.ambientClips[i].myAudioSource.gameObject);
|
||||
|
||||
GameObject sys;
|
||||
|
||||
if(Settings.ambientClips[i].audioClip != null)
|
||||
{
|
||||
sys = new GameObject();
|
||||
sys.name = "Ambient - " +Settings.ambientClips[i].name;
|
||||
sys.transform.SetParent(EnviroManager.instance.Objects.audio.transform);
|
||||
Settings.ambientClips[i].myAudioSource = sys.AddComponent<AudioSource>();
|
||||
Settings.ambientClips[i].myAudioSource.clip = Settings.ambientClips[i].audioClip;
|
||||
Settings.ambientClips[i].myAudioSource.loop = Settings.ambientClips[i].loop;
|
||||
Settings.ambientClips[i].myAudioSource.volume = Settings.ambientClips[i].volume;
|
||||
Settings.ambientClips[i].myAudioSource.outputAudioMixerGroup = Settings.ambientClips[i].audioMixerGroup;
|
||||
}
|
||||
}
|
||||
|
||||
//Weather
|
||||
for(int i = 0; i < Settings.weatherClips.Count; i++)
|
||||
{
|
||||
if(Settings.weatherClips[i].myAudioSource != null)
|
||||
EnviroHelper.DestroyExtended(Settings.weatherClips[i].myAudioSource.gameObject);
|
||||
|
||||
GameObject sys;
|
||||
|
||||
if(Settings.weatherClips[i].audioClip != null)
|
||||
{
|
||||
sys = new GameObject();
|
||||
sys.name = "Weather - " + Settings.weatherClips[i].name;
|
||||
sys.transform.SetParent(EnviroManager.instance.Objects.audio.transform);
|
||||
Settings.weatherClips[i].myAudioSource = sys.AddComponent<AudioSource>();
|
||||
Settings.weatherClips[i].myAudioSource.clip = Settings.weatherClips[i].audioClip;
|
||||
Settings.weatherClips[i].myAudioSource.loop = Settings.weatherClips[i].loop;
|
||||
Settings.weatherClips[i].myAudioSource.volume = Settings.weatherClips[i].volume;
|
||||
Settings.weatherClips[i].myAudioSource.outputAudioMixerGroup = Settings.weatherClips[i].audioMixerGroup;
|
||||
}
|
||||
}
|
||||
|
||||
//Tunder
|
||||
for(int i = 0; i < Settings.thunderClips.Count; i++)
|
||||
{
|
||||
if(Settings.thunderClips[i].myAudioSource != null)
|
||||
EnviroHelper.DestroyExtended(Settings.thunderClips[i].myAudioSource.gameObject);
|
||||
|
||||
GameObject sys;
|
||||
|
||||
if(Settings.thunderClips[i].audioClip != null)
|
||||
{
|
||||
sys = new GameObject();
|
||||
sys.name = "Thunder - " + Settings.thunderClips[i].name;
|
||||
sys.transform.SetParent(EnviroManager.instance.Objects.audio.transform);
|
||||
Settings.thunderClips[i].myAudioSource = sys.AddComponent<AudioSource>();
|
||||
Settings.thunderClips[i].myAudioSource.clip = Settings.thunderClips[i].audioClip;
|
||||
Settings.thunderClips[i].myAudioSource.loop = false;
|
||||
Settings.thunderClips[i].myAudioSource.playOnAwake = false;
|
||||
Settings.thunderClips[i].myAudioSource.volume = Settings.thunderClips[i].volume;
|
||||
Settings.thunderClips[i].myAudioSource.outputAudioMixerGroup = Settings.thunderClips[i].audioMixerGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Plays random thunder SFX audio.
|
||||
public void PlayRandomThunderSFX()
|
||||
{
|
||||
int thunderSFX = UnityEngine.Random.Range(0,Settings.thunderClips.Count);
|
||||
|
||||
if(Settings.thunderClips.Count > 0 && Settings.thunderClips[thunderSFX] != null)
|
||||
{
|
||||
Settings.thunderClips[thunderSFX].myAudioSource.volume = Settings.thunderClips[thunderSFX].volume * Settings.thunderMasterVolume + thunderVolumeModifier;
|
||||
Settings.thunderClips[thunderSFX].myAudioSource.PlayOneShot(Settings.thunderClips[thunderSFX].myAudioSource.clip);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAudio()
|
||||
{
|
||||
for(int i = 0; i < Settings.ambientClips.Count; i++)
|
||||
{
|
||||
UpdateEnviroAudioClip(Settings.ambientClips[i],Settings.ambientMasterVolume + ambientVolumeModifier);
|
||||
}
|
||||
|
||||
for(int i = 0; i < Settings.weatherClips.Count; i++)
|
||||
{
|
||||
UpdateEnviroAudioClip(Settings.weatherClips[i],Settings.weatherMasterVolume + weatherVolumeModifier);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateEnviroAudioClip(EnviroAudioClip clip, float masterVolume)
|
||||
{
|
||||
if(clip.audioClip != null && clip.myAudioSource != null)
|
||||
{
|
||||
if(!Application.isPlaying)
|
||||
{
|
||||
clip.myAudioSource.Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
clip.myAudioSource.loop = clip.loop;
|
||||
|
||||
switch (clip.playBackType)
|
||||
{
|
||||
case EnviroAudioClip.PlayBackType.Always:
|
||||
clip.myAudioSource.volume = clip.volume * masterVolume;
|
||||
break;
|
||||
|
||||
case EnviroAudioClip.PlayBackType.BasedOnSun:
|
||||
clip.myAudioSource.volume = clip.volumeCurve.Evaluate(EnviroManager.instance.solarTime);
|
||||
clip.myAudioSource.volume *= clip.volume * masterVolume;
|
||||
break;
|
||||
|
||||
case EnviroAudioClip.PlayBackType.BasedOnMoon:
|
||||
clip.myAudioSource.volume = clip.volumeCurve.Evaluate(EnviroManager.instance.lunarTime);
|
||||
clip.myAudioSource.volume *= clip.volume * masterVolume;
|
||||
break;
|
||||
}
|
||||
|
||||
//Enable or disable playback based on volume
|
||||
if(clip.myAudioSource.volume < 0.001f && clip.myAudioSource.isPlaying)
|
||||
clip.myAudioSource.Stop();
|
||||
|
||||
if(clip.myAudioSource.volume > 0f && !clip.myAudioSource.isPlaying)
|
||||
clip.myAudioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroAudio>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroAudioModule t = ScriptableObject.CreateInstance<EnviroAudioModule>();
|
||||
t.name = "Audio Module";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroAudio>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SaveModuleValues (EnviroAudioModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroAudio>(JsonUtility.ToJson(Settings));
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3e0fff1aca044c40b9f5dc9d0bfaaa3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Audio/EnviroAudioModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8584d198954851d47a42ddc29a12e3ee
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,263 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a3e0fff1aca044c40b9f5dc9d0bfaaa3, type: 3}
|
||||
m_Name: Default Audio Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 1
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
ambientClips:
|
||||
- showEditor: 1
|
||||
name: Day
|
||||
audioClip: {fileID: 8300000, guid: 3e0b793299afd7c4086f6dfcd604aaba, type: 3}
|
||||
audioMixerGroup: {fileID: -7356562420348432203, guid: c5196b1e1a81a964ab0079efa98e857b, type: 2}
|
||||
playBackType: 1
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 1
|
||||
volume: 1
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: -0.000000659857
|
||||
outSlope: -0.000000659857
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.496813
|
||||
value: -0.00000032782555
|
||||
inSlope: 0.026825864
|
||||
outSlope: 0.026825864
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.12836285
|
||||
- serializedVersion: 3
|
||||
time: 0.5332272
|
||||
value: 0.69103265
|
||||
inSlope: 2.2555194
|
||||
outSlope: 2.2555194
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.0717938
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0.050087996
|
||||
outSlope: 0.050087996
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.15470096
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
- showEditor: 1
|
||||
name: Night
|
||||
audioClip: {fileID: 8300000, guid: eef01bfe93973f4419f0b3dd1b7a6a06, type: 3}
|
||||
audioMixerGroup: {fileID: -7356562420348432203, guid: c5196b1e1a81a964ab0079efa98e857b, type: 2}
|
||||
playBackType: 1
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 1
|
||||
volume: 1
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0.0058403015
|
||||
value: 0.003780365
|
||||
inSlope: 0.40376505
|
||||
outSlope: 0.40376505
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.30587992
|
||||
value: 0.12492588
|
||||
inSlope: 0.9373293
|
||||
outSlope: 0.9373293
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.45850945
|
||||
value: 0.39840025
|
||||
inSlope: -0.15356094
|
||||
outSlope: -0.15356094
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.3681847
|
||||
outWeight: 0.09808861
|
||||
- serializedVersion: 3
|
||||
time: 0.51107603
|
||||
value: 0.00567906
|
||||
inSlope: -0.03341259
|
||||
outSlope: -0.03341259
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.11550105
|
||||
- serializedVersion: 3
|
||||
time: 1.0029275
|
||||
value: 0.0013360546
|
||||
inSlope: -0.07205321
|
||||
outSlope: -0.07205321
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.15684973
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
weatherClips:
|
||||
- showEditor: 1
|
||||
name: Light Rain
|
||||
audioClip: {fileID: 8300000, guid: 84e5ea3df3fc44749b4bf8e1fe360d49, type: 3}
|
||||
audioMixerGroup: {fileID: 0}
|
||||
playBackType: 0
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 1
|
||||
volume: 0
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve: []
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
- showEditor: 1
|
||||
name: Medium Rain
|
||||
audioClip: {fileID: 8300000, guid: c2b83583de6cc7c4ca613942c6fe8a76, type: 3}
|
||||
audioMixerGroup: {fileID: 0}
|
||||
playBackType: 0
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 1
|
||||
volume: 0
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve: []
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
- showEditor: 1
|
||||
name: Heavy Rain
|
||||
audioClip: {fileID: 8300000, guid: 6ff8b8db3a3fd6e4cbfa0995856ebaca, type: 3}
|
||||
audioMixerGroup: {fileID: 0}
|
||||
playBackType: 0
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 1
|
||||
volume: 0
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve: []
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
thunderClips:
|
||||
- showEditor: 1
|
||||
name: Thunder 1
|
||||
audioClip: {fileID: 8300000, guid: 6ca3bddd35a48a745b4dcecc9f65a83f, type: 3}
|
||||
audioMixerGroup: {fileID: 0}
|
||||
playBackType: 0
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 0
|
||||
volume: 1
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve: []
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
- showEditor: 1
|
||||
name: Thunder 2
|
||||
audioClip: {fileID: 8300000, guid: dd76e0dd59e215946a75c7338c043951, type: 3}
|
||||
audioMixerGroup: {fileID: 0}
|
||||
playBackType: 0
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 0
|
||||
volume: 1
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve: []
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
- showEditor: 1
|
||||
name: Thunder 3
|
||||
audioClip: {fileID: 8300000, guid: ee17606ad258a3543a73a326bf5bc5da, type: 3}
|
||||
audioMixerGroup: {fileID: 0}
|
||||
playBackType: 0
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 0
|
||||
volume: 1
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve: []
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
- showEditor: 1
|
||||
name: Thunder 4
|
||||
audioClip: {fileID: 8300000, guid: eb8c1b0f82ffe784da2459bc295b4854, type: 3}
|
||||
audioMixerGroup: {fileID: 0}
|
||||
playBackType: 0
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 0
|
||||
volume: 1
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve: []
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
- showEditor: 1
|
||||
name: Thunder 5
|
||||
audioClip: {fileID: 8300000, guid: e410de94ef87c1b4998b2d4731a717bc, type: 3}
|
||||
audioMixerGroup: {fileID: 0}
|
||||
playBackType: 0
|
||||
myAudioSource: {fileID: 0}
|
||||
loop: 0
|
||||
volume: 1
|
||||
volumeCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve: []
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
maxVolume: 1
|
||||
ambientMasterVolume: 1
|
||||
weatherMasterVolume: 1
|
||||
thunderMasterVolume: 1
|
||||
preset: {fileID: 0}
|
||||
ambientVolumeModifier: 0
|
||||
weatherVolumeModifier: 0
|
||||
thunderVolumeModifier: 0
|
||||
showAmbientSetupControls: 0
|
||||
showWeatherSetupControls: 0
|
||||
showThunderSetupControls: 0
|
||||
showAudioControls: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fac88c4f2c49e2d429d7269d163c9947
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Audio/Preset/Default
|
||||
Audio Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3267a7fcfd1151b4a8b65af01324115d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,137 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroAurora
|
||||
{
|
||||
public bool useAurora = true;
|
||||
[Header("Aurora Intensity")]
|
||||
[Range(0f,1f)]
|
||||
public float auroraIntensityModifier = 1f;
|
||||
public AnimationCurve auroraIntensity = new AnimationCurve(new Keyframe(0f, 1f), new Keyframe(0.5f, 0.1f), new Keyframe(1f, 0f));
|
||||
|
||||
//
|
||||
[Header("Aurora Color and Brightness")]
|
||||
public Color auroraColor = new Color(0.1f, 0.5f, 0.7f);
|
||||
public float auroraBrightness = 75f;
|
||||
public float auroraContrast = 10f;
|
||||
//
|
||||
[Header("Aurora Height and Scale")]
|
||||
public float auroraHeight = 20000f;
|
||||
[Range(0f, 0.025f)]
|
||||
public float auroraScale = 0.01f;
|
||||
//
|
||||
[Header("Aurora Performance")]
|
||||
[Range(8, 32)]
|
||||
public int auroraSteps = 20;
|
||||
//
|
||||
[Header("Aurora Modelling and Animation")]
|
||||
public Vector4 auroraLayer1Settings = new Vector4(0.1f, 0.1f, 0f, 0.5f);
|
||||
public Vector4 auroraLayer2Settings = new Vector4(5f, 5f, 0f, 0.5f);
|
||||
public Vector4 auroraColorshiftSettings = new Vector4(0.05f, 0.05f, 0f, 5f);
|
||||
[Range(0f, 0.1f)]
|
||||
public float auroraSpeed = 0.005f;
|
||||
[Header("Aurora Textures")]
|
||||
public Texture2D aurora_layer_1;
|
||||
public Texture2D aurora_layer_2;
|
||||
public Texture2D aurora_colorshift;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroAuroraModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroAurora Settings;
|
||||
public EnviroAuroraModule preset;
|
||||
public bool showAuroraControls;
|
||||
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance.Sky != null)
|
||||
{
|
||||
UpdateAuroraShader();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAuroraShader ()
|
||||
{
|
||||
if(!Settings.useAurora)
|
||||
{
|
||||
Shader.SetGlobalFloat("_Aurora", 0f);
|
||||
return;
|
||||
}
|
||||
else
|
||||
Shader.SetGlobalFloat("_Aurora", 1f);
|
||||
|
||||
if (Settings.aurora_layer_1 != null)
|
||||
Shader.SetGlobalTexture("_Aurora_Layer_1", Settings.aurora_layer_1);
|
||||
|
||||
if (Settings.aurora_layer_2 != null)
|
||||
Shader.SetGlobalTexture("_Aurora_Layer_2", Settings.aurora_layer_2);
|
||||
|
||||
if (Settings.aurora_colorshift != null)
|
||||
Shader.SetGlobalTexture("_Aurora_Colorshift", Settings.aurora_colorshift);
|
||||
|
||||
Shader.SetGlobalFloat("_AuroraIntensity", Mathf.Clamp01(Settings.auroraIntensityModifier * Settings.auroraIntensity.Evaluate(EnviroManager.instance.solarTime)));
|
||||
Shader.SetGlobalFloat("_AuroraBrightness", Settings.auroraBrightness);
|
||||
Shader.SetGlobalFloat("_AuroraContrast", Settings.auroraContrast);
|
||||
Shader.SetGlobalColor("_AuroraColor", Settings.auroraColor);
|
||||
Shader.SetGlobalFloat("_AuroraHeight", Settings.auroraHeight);
|
||||
Shader.SetGlobalFloat("_AuroraScale", Settings.auroraScale);
|
||||
Shader.SetGlobalFloat("_AuroraSpeed", Settings.auroraSpeed);
|
||||
Shader.SetGlobalFloat("_AuroraSteps", Settings.auroraSteps);
|
||||
Shader.SetGlobalFloat("_AuroraSteps", Settings.auroraSteps);
|
||||
Shader.SetGlobalVector("_Aurora_Tiling_Layer1", Settings.auroraLayer1Settings);
|
||||
Shader.SetGlobalVector("_Aurora_Tiling_Layer2", Settings.auroraLayer2Settings);
|
||||
Shader.SetGlobalVector("_Aurora_Tiling_ColorShift", Settings.auroraColorshiftSettings);
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroAurora>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroAuroraModule t = ScriptableObject.CreateInstance<EnviroAuroraModule>();
|
||||
t.name = "Aurora Preset";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroAurora>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
public void SaveModuleValues (EnviroAuroraModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroAurora>(JsonUtility.ToJson(Settings));
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6910768c241d1924f921a3f44198cfe1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Aurora/EnviroAuroraModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a1cba72929520b4887fd961043e8fe7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6910768c241d1924f921a3f44198cfe1, type: 3}
|
||||
m_Name: Default Aurora Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 0
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
useAurora: 1
|
||||
auroraIntensityModifier: 1
|
||||
auroraIntensity:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 0.5
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
auroraColor: {r: 0.1, g: 0.5, b: 0.7, a: 1}
|
||||
auroraBrightness: 75
|
||||
auroraContrast: 10
|
||||
auroraHeight: 20000
|
||||
auroraScale: 0.01
|
||||
auroraSteps: 24
|
||||
auroraLayer1Settings: {x: 0.1, y: 0.1, z: 0, w: 0.5}
|
||||
auroraLayer2Settings: {x: 5, y: 5, z: 0, w: 0.5}
|
||||
auroraColorshiftSettings: {x: 0.05, y: 0.05, z: 0, w: 5}
|
||||
auroraSpeed: 0.005
|
||||
aurora_layer_1: {fileID: 2800000, guid: 3316634c3fa8231429eb988934de236c, type: 3}
|
||||
aurora_layer_2: {fileID: 2800000, guid: 25bf6a8e18b4471499e961d75d1777c2, type: 3}
|
||||
aurora_colorshift: {fileID: 2800000, guid: f99b7b1866c1ab3489d848a4ef3dd81b, type: 3}
|
||||
preset: {fileID: 0}
|
||||
showAuroraControls: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 278933d28004c6b40ace276968b45b9e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Aurora/Preset/Default
|
||||
Aurora Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a66e1fc504e6aff45ba345c76949ab44
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroDefault
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroDefaultModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroDefault settings;
|
||||
public EnviroDefaultModule preset;
|
||||
public bool showDefaultControls;
|
||||
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
settings = JsonUtility.FromJson<Enviro.EnviroDefault>(JsonUtility.ToJson(preset.settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroDefaultModule t = ScriptableObject.CreateInstance<EnviroDefaultModule>();
|
||||
t.name = "Default Preset";
|
||||
t.settings = JsonUtility.FromJson<Enviro.EnviroDefault>(JsonUtility.ToJson(settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
public void SaveModuleValues (EnviroDefaultModule module)
|
||||
{
|
||||
module.settings = JsonUtility.FromJson<Enviro.EnviroDefault>(JsonUtility.ToJson(settings));
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f09341d4288862d4c869629f4b229df9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Default/EnviroDefaultModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b8b3ff041c621c488b1ef5eba3b1b8f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,311 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroEffectTypes
|
||||
{
|
||||
#if ENVIRO_VFXGRAPH
|
||||
public UnityEngine.VFX.VisualEffect myVFXGraph;
|
||||
#endif
|
||||
public GameObject prefabVFXGraph;
|
||||
public Vector3 localPositionOffsetVFXGraph;
|
||||
public Vector3 localRotationOffsetVFXGraph;
|
||||
public float maxEmissionVFXGraph;
|
||||
|
||||
public ParticleSystem mySystem;
|
||||
public string name;
|
||||
public GameObject prefab;
|
||||
public Vector3 localPositionOffset;
|
||||
public Vector3 localRotationOffset;
|
||||
public float emissionRate = 0f;
|
||||
public float maxEmission;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroEffects
|
||||
{
|
||||
public enum EnviroEffectSystemType
|
||||
{
|
||||
ParticleSystem,
|
||||
VFXGraph,
|
||||
Both
|
||||
}
|
||||
|
||||
public EnviroEffectSystemType enviroEffectSystemType = EnviroEffectSystemType.VFXGraph;
|
||||
public List<EnviroEffectTypes> effectTypes = new List<EnviroEffectTypes>();
|
||||
[Range(0f,2f)]
|
||||
public float particeEmissionRateModifier = 1f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[ExecuteInEditMode]
|
||||
public class EnviroEffectsModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroEffects Settings;
|
||||
public EnviroEffectsModule preset;
|
||||
|
||||
//Inspector
|
||||
public bool showSetupControls;
|
||||
public bool showEmissionControls;
|
||||
public override void Enable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
public override void Disable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
private void Setup()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
CreateEffects();
|
||||
}
|
||||
|
||||
private void Cleanup()
|
||||
{
|
||||
if(EnviroManager.instance.Objects.effects != null)
|
||||
DestroyImmediate(EnviroManager.instance.Objects.effects);
|
||||
}
|
||||
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
UpdateEffects();
|
||||
}
|
||||
|
||||
public void CreateEffects()
|
||||
{
|
||||
if(EnviroManager.instance.Objects.effects != null)
|
||||
{
|
||||
EnviroHelper.DestroyExtended(EnviroManager.instance.Objects.effects);
|
||||
EnviroManager.instance.Objects.effects = null;
|
||||
}
|
||||
|
||||
|
||||
if(EnviroManager.instance.Objects.effects == null)
|
||||
{
|
||||
EnviroManager.instance.Objects.effects = new GameObject();
|
||||
EnviroManager.instance.Objects.effects.hideFlags = HideFlags.DontSave;
|
||||
EnviroManager.instance.Objects.effects.name = "Effects";
|
||||
EnviroManager.instance.Objects.effects.transform.SetParent(EnviroManager.instance.transform);
|
||||
EnviroManager.instance.Objects.effects.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
for(int i = 0; i < Settings.effectTypes.Count; i++)
|
||||
{
|
||||
if(Settings.effectTypes[i].mySystem != null)
|
||||
{
|
||||
EnviroHelper.DestroyExtended(Settings.effectTypes[i].mySystem.gameObject);
|
||||
Settings.effectTypes[i].mySystem = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
GameObject sys;
|
||||
|
||||
if(Settings.effectTypes[i].prefab != null)
|
||||
{
|
||||
sys = Instantiate(Settings.effectTypes[i].prefab,Settings.effectTypes[i].localPositionOffset,Quaternion.identity);
|
||||
sys.transform.SetParent(EnviroManager.instance.Objects.effects.transform);
|
||||
sys.name = Settings.effectTypes[i].name + " Particle System";
|
||||
sys.transform.localPosition = Settings.effectTypes[i].localPositionOffset;
|
||||
sys.transform.localEulerAngles = Settings.effectTypes[i].localRotationOffset;
|
||||
Settings.effectTypes[i].mySystem = sys.GetComponent<ParticleSystem>();
|
||||
|
||||
if(Settings.effectTypes[i].emissionRate <= 0f)
|
||||
{
|
||||
Settings.effectTypes[i].mySystem.Clear();
|
||||
Settings.effectTypes[i].mySystem.Stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if ENVIRO_VFXGRAPH
|
||||
if(Settings.effectTypes[i].prefabVFXGraph != null)
|
||||
{
|
||||
sys = Instantiate(Settings.effectTypes[i].prefabVFXGraph,Settings.effectTypes[i].localPositionOffsetVFXGraph,Quaternion.identity);
|
||||
sys.transform.SetParent(EnviroManager.instance.Objects.effects.transform);
|
||||
sys.name = Settings.effectTypes[i].name + " VFX Graph";
|
||||
sys.transform.localPosition = Settings.effectTypes[i].localPositionOffsetVFXGraph;
|
||||
sys.transform.localEulerAngles = Settings.effectTypes[i].localRotationOffsetVFXGraph;
|
||||
Settings.effectTypes[i].myVFXGraph = sys.GetComponent<UnityEngine.VFX.VisualEffect>();
|
||||
|
||||
if(Settings.effectTypes[i].emissionRate <= 0f)
|
||||
Settings.effectTypes[i].myVFXGraph.Stop();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public float GetEmissionRate(ParticleSystem system)
|
||||
{
|
||||
return system.emission.rateOverTime.constantMax;
|
||||
}
|
||||
|
||||
public void SetEmissionRate(ParticleSystem sys, float emissionRate)
|
||||
{
|
||||
var emission = sys.emission;
|
||||
var rate = emission.rateOverTime;
|
||||
rate.constantMax = emissionRate;
|
||||
emission.rateOverTime = rate;
|
||||
}
|
||||
|
||||
#if ENVIRO_VFXGRAPH
|
||||
public float GetEmissionRate(UnityEngine.VFX.VisualEffect system)
|
||||
{
|
||||
return system.GetFloat("Emission Rate");
|
||||
}
|
||||
|
||||
|
||||
public void SetEmissionRate(UnityEngine.VFX.VisualEffect system, float emissionRate)
|
||||
{
|
||||
system.SetFloat("Emission Rate", emissionRate);
|
||||
|
||||
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
{
|
||||
system.SetVector3("Wind",new UnityEngine.Vector3 (EnviroManager.instance.Environment.Settings.windDirectionX,0f,EnviroManager.instance.Environment.Settings.windDirectionY));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
private void UpdateEffects()
|
||||
{
|
||||
Shader.SetGlobalFloat("_EnviroLightIntensity", EnviroManager.instance.solarTime);
|
||||
|
||||
|
||||
for(int i = 0; i < Settings.effectTypes.Count; i++)
|
||||
{
|
||||
#if ENVIRO_VFXGRAPH
|
||||
if(Settings.enviroEffectSystemType == EnviroEffects.EnviroEffectSystemType.VFXGraph)
|
||||
{
|
||||
if(Settings.effectTypes[i].myVFXGraph != null)
|
||||
{
|
||||
float currentEmission = Settings.effectTypes[i].maxEmissionVFXGraph * Settings.effectTypes[i].emissionRate * Settings.particeEmissionRateModifier;
|
||||
|
||||
SetEmissionRate(Settings.effectTypes[i].myVFXGraph,currentEmission);
|
||||
|
||||
if(currentEmission > 0f && Settings.effectTypes[i].myVFXGraph.aliveParticleCount < 1)
|
||||
Settings.effectTypes[i].myVFXGraph.Play();
|
||||
}
|
||||
|
||||
if(Settings.effectTypes[i].mySystem != null)
|
||||
{
|
||||
SetEmissionRate(Settings.effectTypes[i].mySystem,0f);
|
||||
|
||||
if(Settings.effectTypes[i].mySystem.isPlaying)
|
||||
Settings.effectTypes[i].mySystem.Stop();
|
||||
}
|
||||
|
||||
}
|
||||
else if(Settings.enviroEffectSystemType == EnviroEffects.EnviroEffectSystemType.ParticleSystem)
|
||||
{
|
||||
|
||||
if(Settings.effectTypes[i].mySystem != null)
|
||||
{
|
||||
float currentEmission = Settings.effectTypes[i].maxEmission * Settings.effectTypes[i].emissionRate * Settings.particeEmissionRateModifier;
|
||||
|
||||
SetEmissionRate(Settings.effectTypes[i].mySystem,currentEmission);
|
||||
|
||||
if(currentEmission > 0f && !Settings.effectTypes[i].mySystem.isPlaying)
|
||||
Settings.effectTypes[i].mySystem.Play();
|
||||
}
|
||||
|
||||
if(Settings.effectTypes[i].myVFXGraph != null)
|
||||
{
|
||||
SetEmissionRate(Settings.effectTypes[i].myVFXGraph,0f);
|
||||
|
||||
if (Settings.effectTypes[i].myVFXGraph.aliveParticleCount > 0)
|
||||
Settings.effectTypes[i].myVFXGraph.Stop();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Settings.effectTypes[i].myVFXGraph != null)
|
||||
{
|
||||
float currentEmission = Settings.effectTypes[i].maxEmissionVFXGraph * Settings.effectTypes[i].emissionRate * Settings.particeEmissionRateModifier;
|
||||
|
||||
SetEmissionRate(Settings.effectTypes[i].myVFXGraph,currentEmission);
|
||||
|
||||
if(currentEmission > 0f && Settings.effectTypes[i].myVFXGraph.aliveParticleCount < 1)
|
||||
Settings.effectTypes[i].myVFXGraph.Play();
|
||||
}
|
||||
|
||||
if(Settings.effectTypes[i].mySystem != null)
|
||||
{
|
||||
float currentEmission = Settings.effectTypes[i].maxEmission * Settings.effectTypes[i].emissionRate * Settings.particeEmissionRateModifier;
|
||||
|
||||
SetEmissionRate(Settings.effectTypes[i].mySystem,currentEmission);
|
||||
|
||||
if(currentEmission > 0f && !Settings.effectTypes[i].mySystem.isPlaying)
|
||||
Settings.effectTypes[i].mySystem.Play();
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
if(Settings.effectTypes[i].mySystem != null)
|
||||
{
|
||||
float currentEmission = Settings.effectTypes[i].maxEmission * Settings.effectTypes[i].emissionRate * Settings.particeEmissionRateModifier;
|
||||
|
||||
SetEmissionRate(Settings.effectTypes[i].mySystem,currentEmission);
|
||||
|
||||
if(currentEmission > 0f && !Settings.effectTypes[i].mySystem.isPlaying)
|
||||
Settings.effectTypes[i].mySystem.Play();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroEffects>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroEffectsModule t = ScriptableObject.CreateInstance<EnviroEffectsModule>();
|
||||
t.name = "Effects Module";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroEffects>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SaveModuleValues (EnviroEffectsModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroEffects>(JsonUtility.ToJson(Settings));
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7aa6806f1fff5b489f26777d053c723
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Effects/EnviroEffectsModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8efd41a7193b0dd49be02a75377fc379
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e7aa6806f1fff5b489f26777d053c723, type: 3}
|
||||
m_Name: Default Effects Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 1
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
enviroEffectSystemType: 1
|
||||
effectTypes:
|
||||
- prefabVFXGraph: {fileID: 217644638508447475, guid: c4dc37a82cd6e96449263392be3a47b5, type: 3}
|
||||
localPositionOffsetVFXGraph: {x: 0, y: 25, z: 0}
|
||||
localRotationOffsetVFXGraph: {x: 0, y: 0, z: 0}
|
||||
maxEmissionVFXGraph: 75000
|
||||
mySystem: {fileID: 0}
|
||||
name: Rain
|
||||
prefab: {fileID: 6936246916098640434, guid: bf3881f9fe64de14597de578d2acee5d, type: 3}
|
||||
localPositionOffset: {x: 0, y: 25, z: 0}
|
||||
localRotationOffset: {x: -90, y: 0, z: 0}
|
||||
emissionRate: 0
|
||||
maxEmission: 2000
|
||||
- prefabVFXGraph: {fileID: 217644638508447475, guid: 208b9da0ef19ebe4c8589225a19a508f, type: 3}
|
||||
localPositionOffsetVFXGraph: {x: 0, y: 25, z: 0}
|
||||
localRotationOffsetVFXGraph: {x: 0, y: 0, z: 0}
|
||||
maxEmissionVFXGraph: 75000
|
||||
mySystem: {fileID: 0}
|
||||
name: Snow
|
||||
prefab: {fileID: 1000011163096958, guid: 6ec12b7d8fc5e704fbbbe1641e4a6c56, type: 3}
|
||||
localPositionOffset: {x: 0, y: 25, z: 0}
|
||||
localRotationOffset: {x: -90, y: 0, z: 0}
|
||||
emissionRate: 0
|
||||
maxEmission: 2500
|
||||
particeEmissionRateModifier: 1
|
||||
preset: {fileID: 0}
|
||||
showSetupControls: 0
|
||||
showEmissionControls: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59a8076f06e540343b875f850ac3b6a4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.2.0
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Effects/Preset/Default
|
||||
Effects Preset.asset
|
||||
uploadId: 721859
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class EnviroModule : ScriptableObject
|
||||
{
|
||||
public bool showModuleInspector = false;
|
||||
public bool showSaveLoad = false;
|
||||
public bool active = true;
|
||||
|
||||
public virtual void Enable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Disable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void UpdateModule ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f18644bfe4a6622429e017df5dcda800
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/EnviroModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7856f0e01443004a979dc5383e6042b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,328 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
public class EnviroEnvironment
|
||||
{
|
||||
//Seasons
|
||||
public enum Seasons
|
||||
{
|
||||
Spring,
|
||||
Summer,
|
||||
Autumn,
|
||||
Winter
|
||||
}
|
||||
public Seasons season;
|
||||
public bool changeSeason = true;
|
||||
|
||||
[Tooltip("Start Day of Year for Spring")]
|
||||
[Range(0, 366)]
|
||||
public int springStart = 60;
|
||||
[Tooltip("End Day of Year for Spring")]
|
||||
[Range(0, 366)]
|
||||
public int springEnd = 92;
|
||||
[Tooltip("Start Day of Year for Summer")]
|
||||
[Range(0, 366)]
|
||||
public int summerStart = 93;
|
||||
[Tooltip("End Day of Year for Summer")]
|
||||
[Range(0, 366)]
|
||||
public int summerEnd = 185;
|
||||
[Tooltip("Start Day of Year for Autumn")]
|
||||
[Range(0, 366)]
|
||||
public int autumnStart = 186;
|
||||
[Tooltip("End Day of Year for Autumn")]
|
||||
[Range(0, 366)]
|
||||
public int autumnEnd = 276;
|
||||
[Tooltip("Start Day of Year for Winter")]
|
||||
[Range(0, 366)]
|
||||
public int winterStart = 277;
|
||||
[Tooltip("End Day of Year for Winter")]
|
||||
[Range(0, 366)]
|
||||
public int winterEnd = 59;
|
||||
|
||||
//Temperature
|
||||
[Tooltip("Base Temperature in Spring")]
|
||||
public AnimationCurve springBaseTemperature = new AnimationCurve();
|
||||
[Tooltip("Base Temperature in Summer")]
|
||||
public AnimationCurve summerBaseTemperature = new AnimationCurve();
|
||||
[Tooltip("Base Temperature in Autumn")]
|
||||
public AnimationCurve autumnBaseTemperature = new AnimationCurve();
|
||||
[Tooltip("Base Temperature in Winter")]
|
||||
public AnimationCurve winterBaseTemperature = new AnimationCurve();
|
||||
[Tooltip("Current temperature.")]
|
||||
[Range(-50f, 50f)]
|
||||
public float temperature = 0f;
|
||||
[Tooltip("Temperature mod used for different weather types.")]
|
||||
[Range(-50f, 50f)]
|
||||
public float temperatureWeatherMod = 0f;
|
||||
[Tooltip("Custom temperature mod for gameplay use.")]
|
||||
[Range(-50f, 50f)]
|
||||
public float temperatureCustomMod = 0f;
|
||||
|
||||
[Tooltip("Temperature changing speed.")]
|
||||
public float temperatureChangingSpeed = 1f;
|
||||
|
||||
//Weather State
|
||||
[Tooltip("Current wetness for third party shader or gameplay.")]
|
||||
[Range(0f, 1f)]
|
||||
public float wetness = 0f;
|
||||
[Tooltip("Target wetness for third party shader or gameplay.")]
|
||||
[Range(0f, 1f)]
|
||||
public float wetnessTarget = 0f;
|
||||
[Tooltip("Current snow for third party shader or gameplay.")]
|
||||
[Range(0f, 1f)]
|
||||
public float snow = 0f;
|
||||
[Tooltip("Target snow for third party shader or gameplay.")]
|
||||
[Range(0f, 1f)]
|
||||
public float snowTarget = 0f;
|
||||
|
||||
[Tooltip("Speed of wetness accumulation.")]
|
||||
public float wetnessAccumulationSpeed = 1f;
|
||||
[Tooltip("Speed of wetness dries.")]
|
||||
public float wetnessDrySpeed = 1f;
|
||||
|
||||
[Tooltip("Speed of snow buildup.")]
|
||||
public float snowAccumulationSpeed = 1f;
|
||||
[Tooltip("Speed of how fast snow melts.")]
|
||||
public float snowMeltSpeed = 1f;
|
||||
|
||||
[Tooltip("Temperature when snow starts to melt.")]
|
||||
[Range(-20f, 20f)]
|
||||
public float snowMeltingTresholdTemperature = 1f;
|
||||
|
||||
//Wind
|
||||
[Range(-1f,1f)]
|
||||
public float windDirectionX, windDirectionY;
|
||||
[Range(0f,1f)]
|
||||
public float windSpeed = 0.1f;
|
||||
[Range(0f,1f)]
|
||||
public float windTurbulence = 0.1f;
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroEnvironmentModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroEnvironment Settings;
|
||||
public EnviroEnvironmentModule preset;
|
||||
public bool showSeasonControls,showTemperatureControls,showWeatherStateControls,showWindControls;
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
CreateWindZone ();
|
||||
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance.Objects.windZone != null)
|
||||
DestroyImmediate(EnviroManager.instance.Objects.windZone.gameObject);
|
||||
|
||||
}
|
||||
|
||||
private void CreateWindZone ()
|
||||
{
|
||||
if(EnviroManager.instance.Objects.windZone == null)
|
||||
{
|
||||
GameObject wZ = new GameObject();
|
||||
wZ.name = "Wind Zone";
|
||||
wZ.transform.SetParent(EnviroManager.instance.transform);
|
||||
wZ.transform.localPosition = Vector3.zero;
|
||||
EnviroManager.instance.Objects.windZone = wZ.AddComponent<WindZone>();
|
||||
}
|
||||
}
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance.Time != null)
|
||||
{
|
||||
UpdateTemperature(EnviroManager.instance.Time.GetUniversalTimeOfDay() / 24f);
|
||||
UpdateSeason();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateTemperature(1f);
|
||||
}
|
||||
|
||||
UpdateWindZone();
|
||||
UpdateWeatherState();
|
||||
}
|
||||
|
||||
//Changes season based on day settings.
|
||||
public void UpdateSeason()
|
||||
{
|
||||
if(Settings.changeSeason)
|
||||
{
|
||||
|
||||
int currentDay = EnviroManager.instance.Time.Settings.date.DayOfYear;
|
||||
|
||||
if(EnviroManager.instance.Time.Settings.calenderType == EnviroTime.CalenderType.Custom)
|
||||
{
|
||||
currentDay = EnviroManager.instance.Time.days + (EnviroManager.instance.Time.months - 1) * EnviroManager.instance.Time.Settings.daysInMonth;
|
||||
}
|
||||
|
||||
|
||||
if (currentDay >= Settings.springStart && currentDay <= Settings.springEnd)
|
||||
{
|
||||
ChangeSeason(EnviroEnvironment.Seasons.Spring);
|
||||
}
|
||||
else if (currentDay >= Settings.summerStart && currentDay <= Settings.summerEnd)
|
||||
{
|
||||
ChangeSeason(EnviroEnvironment.Seasons.Summer);
|
||||
}
|
||||
else if (currentDay >= Settings.autumnStart && currentDay <= Settings.autumnEnd)
|
||||
{
|
||||
ChangeSeason(EnviroEnvironment.Seasons.Autumn);
|
||||
}
|
||||
else if (currentDay >= Settings.winterStart || currentDay <= Settings.winterEnd)
|
||||
{
|
||||
ChangeSeason(EnviroEnvironment.Seasons.Winter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Changes Season
|
||||
public void ChangeSeason(EnviroEnvironment.Seasons season)
|
||||
{
|
||||
if(Settings.season != season)
|
||||
{
|
||||
EnviroManager.instance.NotifySeasonChanged(season);
|
||||
Settings.season = season;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Sets temperature based on time of day.
|
||||
public void UpdateTemperature (float timeOfDay)
|
||||
{
|
||||
float temperature = 0f;
|
||||
|
||||
switch (Settings.season)
|
||||
{
|
||||
case EnviroEnvironment.Seasons.Spring:
|
||||
temperature = Settings.springBaseTemperature.Evaluate(timeOfDay);
|
||||
break;
|
||||
case EnviroEnvironment.Seasons.Summer:
|
||||
temperature = Settings.summerBaseTemperature.Evaluate(timeOfDay);
|
||||
break;
|
||||
case EnviroEnvironment.Seasons.Autumn:
|
||||
temperature = Settings.autumnBaseTemperature.Evaluate(timeOfDay);
|
||||
break;
|
||||
case EnviroEnvironment.Seasons.Winter:
|
||||
temperature = Settings.winterBaseTemperature.Evaluate(timeOfDay);
|
||||
break;
|
||||
}
|
||||
|
||||
//Apply temperature mods
|
||||
temperature += Settings.temperatureWeatherMod;
|
||||
temperature += Settings.temperatureCustomMod;
|
||||
|
||||
//Set temperature
|
||||
Settings.temperature = Mathf.Lerp(Settings.temperature, temperature, Time.deltaTime * Settings.temperatureChangingSpeed);
|
||||
}
|
||||
|
||||
public void UpdateWeatherState()
|
||||
{
|
||||
// Wetness
|
||||
if (Settings.wetness < Settings.wetnessTarget)
|
||||
{
|
||||
// Raining
|
||||
Settings.wetness = Mathf.Lerp(Settings.wetness, Settings.wetnessTarget, Settings.wetnessAccumulationSpeed * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{ // Drying
|
||||
Settings.wetness = Mathf.Lerp(Settings.wetness, Settings.wetnessTarget, Settings.wetnessDrySpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
if(Settings.wetness < 0.0001f)
|
||||
Settings.wetness = 0f;
|
||||
|
||||
Settings.wetness = Mathf.Clamp(Settings.wetness, 0f, 1f);
|
||||
|
||||
//Snow
|
||||
if (Settings.snow < Settings.snowTarget)
|
||||
{
|
||||
//Snowing
|
||||
Settings.snow = Mathf.Lerp(Settings.snow, Settings.snowTarget, Settings.snowAccumulationSpeed * Time.deltaTime);
|
||||
}
|
||||
else if (Settings.temperature > Settings.snowMeltingTresholdTemperature)
|
||||
{
|
||||
//Melting
|
||||
Settings.snow = Mathf.Lerp(Settings.snow, Settings.snowTarget, Settings.snowMeltSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
if(Settings.snow < 0.0001f)
|
||||
Settings.snow = 0f;
|
||||
|
||||
Settings.snow = Mathf.Clamp(Settings.snow, 0f, 1f);
|
||||
}
|
||||
|
||||
private void UpdateWindZone()
|
||||
{
|
||||
if(EnviroManager.instance.Objects.windZone != null)
|
||||
{
|
||||
EnviroManager.instance.Objects.windZone.windMain = Settings.windSpeed;
|
||||
EnviroManager.instance.Objects.windZone.windTurbulence = Settings.windTurbulence;
|
||||
|
||||
Vector3 windDirection = new Vector3(-Settings.windDirectionX,0f,-Settings.windDirectionY);
|
||||
EnviroManager.instance.Objects.windZone.transform.forward = windDirection;
|
||||
// EnviroManager.instance.Objects.windZone.transform.Rotate(new Vector3(Settings.windDirectionX,0f,Settings.windDirectionY),Space.World);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroEnvironment>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroEnvironmentModule t = ScriptableObject.CreateInstance<EnviroEnvironmentModule>();
|
||||
t.name = "Environment Preset";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroEnvironment>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
public void SaveModuleValues (EnviroEnvironmentModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroEnvironment>(JsonUtility.ToJson(Settings));
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0586c1500fad0074693dd4176a399883
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Environment/EnviroEnvironmentModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03ce2aa1f1b60694cb8a09c64db825f0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,182 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0586c1500fad0074693dd4176a399883, type: 3}
|
||||
m_Name: Default Environment Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 1
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
season: 1
|
||||
changeSeason: 1
|
||||
springStart: 60
|
||||
springEnd: 92
|
||||
summerStart: 93
|
||||
summerEnd: 185
|
||||
autumnStart: 186
|
||||
autumnEnd: 276
|
||||
winterStart: 277
|
||||
winterEnd: 59
|
||||
springBaseTemperature:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.49166667
|
||||
value: 10
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
summerBaseTemperature:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 15
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.49166667
|
||||
value: 25
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 15
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
autumnBaseTemperature:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.49166667
|
||||
value: 10
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
winterBaseTemperature:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.49166667
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
temperature: 22.565174
|
||||
temperatureWeatherMod: 0
|
||||
temperatureCustomMod: 0
|
||||
temperatureChangingSpeed: 0.1
|
||||
wetness: 0
|
||||
wetnessTarget: 0
|
||||
snow: 0
|
||||
snowTarget: 0
|
||||
wetnessAccumulationSpeed: 1
|
||||
wetnessDrySpeed: 1
|
||||
snowAccumulationSpeed: 1
|
||||
snowMeltSpeed: 1
|
||||
snowMeltingTresholdTemperature: 1
|
||||
windDirectionX: 0.009
|
||||
windDirectionY: 0.157
|
||||
windSpeed: 0.25
|
||||
windTurbulence: 0.25
|
||||
preset: {fileID: 0}
|
||||
showSeasonControls: 0
|
||||
showTemperatureControls: 0
|
||||
showWeatherStateControls: 0
|
||||
showWindControls: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2a8d80258fd83a409a05aa912abca80
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Environment/Preset/Default
|
||||
Environment Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 115d2b99df2d51e4387aca37d5606718
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class EnviroEvents
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroActionEvent : UnityEngine.Events.UnityEvent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EnviroActionEvent onHourPassedActions = new EnviroActionEvent();
|
||||
public EnviroActionEvent onDayPassedActions = new EnviroActionEvent();
|
||||
public EnviroActionEvent onYearPassedActions = new EnviroActionEvent();
|
||||
public EnviroActionEvent onWeatherChangedActions = new EnviroActionEvent();
|
||||
public EnviroActionEvent onSeasonChangedActions = new EnviroActionEvent();
|
||||
public EnviroActionEvent onNightActions = new EnviroActionEvent();
|
||||
public EnviroActionEvent onDayActions = new EnviroActionEvent();
|
||||
public EnviroActionEvent onZoneChangedActions = new EnviroActionEvent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c3520f8107654e4d82b9470b3eb462a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Events/EnviroEventModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82bf5f2331e8b474682b8480280663a7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,193 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroFlatClouds
|
||||
{
|
||||
// Cirrus
|
||||
public bool useCirrusClouds = true;
|
||||
public Texture2D cirrusCloudsTex;
|
||||
[Range(0f,1f)]
|
||||
public float cirrusCloudsAlpha;
|
||||
[Range(0f,2f)]
|
||||
public float cirrusCloudsColorPower;
|
||||
[Range(0f,1f)]
|
||||
public float cirrusCloudsCoverage;
|
||||
[GradientUsage(true)]
|
||||
public Gradient cirrusCloudsColor;
|
||||
[Range(0f,1f)]
|
||||
public float cirrusCloudsWindIntensity = 0.5f;
|
||||
|
||||
// Flat Clouds
|
||||
public bool useFlatClouds = true;
|
||||
public Texture2D flatCloudsBaseTex;
|
||||
public Texture2D flatCloudsDetailTex;
|
||||
|
||||
[GradientUsage(true)]
|
||||
public Gradient flatCloudsLightColor;
|
||||
[GradientUsage(true)]
|
||||
public Gradient flatCloudsAmbientColor;
|
||||
|
||||
[Range(0f,2f)]
|
||||
public float flatCloudsLightIntensity = 1.0f;
|
||||
[Range(0f,2f)]
|
||||
public float flatCloudsAmbientIntensity = 1.0f;
|
||||
[Range(0f,2f)]
|
||||
public float flatCloudsShadowIntensity = 0.6f;
|
||||
[Range(1,12)]
|
||||
public float flatCloudsShadowSteps = 8;
|
||||
[Range(0f,1f)]
|
||||
public float flatCloudsHGPhase = 0.6f;
|
||||
[Range(0f,2f)]
|
||||
public float flatCloudsCoverage = 1f;
|
||||
[Range(0f,2f)]
|
||||
public float flatCloudsDensity = 1f;
|
||||
public float flatCloudsAltitude = 10f;
|
||||
public bool flatCloudsTonemapping;
|
||||
public float flatCloudsBaseTiling = 4f;
|
||||
public float flatCloudsDetailTiling = 10f;
|
||||
[Range(0f,1f)]
|
||||
public float flatCloudsWindIntensity = 0.2f;
|
||||
[Range(0f,1f)]
|
||||
public float flatCloudsDetailWindIntensity = 0.5f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroFlatCloudsModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroFlatClouds settings;
|
||||
public EnviroFlatCloudsModule preset;
|
||||
[HideInInspector]
|
||||
public bool showCirrusCloudsControls;
|
||||
[HideInInspector]
|
||||
public bool show2DCloudsControls;
|
||||
[HideInInspector]
|
||||
public Vector2 cloudFlatBaseAnim;
|
||||
[HideInInspector]
|
||||
public Vector2 cloudFlatDetailAnim;
|
||||
[HideInInspector]
|
||||
public Vector2 cirrusAnim;
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
UpdateWind ();
|
||||
|
||||
if(settings.useCirrusClouds)
|
||||
{
|
||||
Shader.SetGlobalFloat("_CirrusClouds",1f);
|
||||
|
||||
if(settings.cirrusCloudsTex != null)
|
||||
Shader.SetGlobalTexture("_CirrusCloudMap",settings.cirrusCloudsTex);
|
||||
|
||||
Shader.SetGlobalFloat("_CirrusCloudAlpha",settings.cirrusCloudsAlpha);
|
||||
Shader.SetGlobalFloat("_CirrusCloudCoverage",settings.cirrusCloudsCoverage);
|
||||
Shader.SetGlobalFloat("_CirrusCloudColorPower",settings.cirrusCloudsColorPower);
|
||||
Shader.SetGlobalColor("_CirrusCloudColor",settings.cirrusCloudsColor.Evaluate(EnviroManager.instance.solarTime));
|
||||
Shader.SetGlobalVector("_CirrusCloudAnimation", new Vector4(cirrusAnim.x, cirrusAnim.y, 0f, 0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
Shader.SetGlobalFloat("_CirrusClouds",0f);
|
||||
}
|
||||
|
||||
if(settings.useFlatClouds)
|
||||
{
|
||||
Shader.SetGlobalFloat("_FlatClouds",1f);
|
||||
|
||||
if(settings.flatCloudsBaseTex != null)
|
||||
Shader.SetGlobalTexture("_FlatCloudsBaseTexture",settings.flatCloudsBaseTex);
|
||||
|
||||
if(settings.flatCloudsDetailTex != null)
|
||||
Shader.SetGlobalTexture("_FlatCloudsDetailTexture",settings.flatCloudsDetailTex);
|
||||
|
||||
//_FlatCloudsAnimation;
|
||||
Shader.SetGlobalColor("_FlatCloudsLightColor", settings.flatCloudsLightColor.Evaluate(EnviroManager.instance.solarTime));
|
||||
Shader.SetGlobalColor("_FlatCloudsAmbientColor", settings.flatCloudsAmbientColor.Evaluate(EnviroManager.instance.solarTime));
|
||||
|
||||
Vector3 lightDirection = Vector3.forward;
|
||||
if(EnviroManager.instance.Objects.directionalLight != null)
|
||||
lightDirection = EnviroManager.instance.Objects.directionalLight.transform.forward;
|
||||
|
||||
Shader.SetGlobalVector("_FlatCloudsLightDirection",lightDirection);
|
||||
Shader.SetGlobalVector("_FlatCloudsLightingParams",new Vector4(settings.flatCloudsLightIntensity * 10f, settings.flatCloudsAmbientIntensity, settings.flatCloudsShadowIntensity,settings.flatCloudsHGPhase));
|
||||
Shader.SetGlobalVector("_FlatCloudsParams",new Vector4(settings.flatCloudsCoverage, settings.flatCloudsDensity * 5f, settings.flatCloudsAltitude,settings.flatCloudsShadowSteps));
|
||||
Shader.SetGlobalVector("_FlatCloudsTiling",new Vector4(settings.flatCloudsBaseTiling, settings.flatCloudsDetailTiling, 0f,0f));
|
||||
Shader.SetGlobalVector("_FlatCloudsAnimation", new Vector4(cloudFlatBaseAnim.x, cloudFlatBaseAnim.y, cloudFlatDetailAnim.x, cloudFlatDetailAnim.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
Shader.SetGlobalFloat("_FlatClouds",0f);
|
||||
}
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
settings = JsonUtility.FromJson<Enviro.EnviroFlatClouds>(JsonUtility.ToJson(preset.settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWind ()
|
||||
{
|
||||
|
||||
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
{
|
||||
cloudFlatBaseAnim += new Vector2(((EnviroManager.instance.Environment.Settings.windSpeed * EnviroManager.instance.Environment.Settings.windDirectionX) * settings.flatCloudsWindIntensity) * Time.deltaTime * 0.01f, ((EnviroManager.instance.Environment.Settings.windSpeed * EnviroManager.instance.Environment.Settings.windDirectionY) * settings.flatCloudsWindIntensity) * Time.deltaTime * 0.01f);
|
||||
cloudFlatDetailAnim += new Vector2(((EnviroManager.instance.Environment.Settings.windSpeed * EnviroManager.instance.Environment.Settings.windDirectionX) * settings.flatCloudsDetailWindIntensity) * Time.deltaTime * 0.1f, ((EnviroManager.instance.Environment.Settings.windSpeed * EnviroManager.instance.Environment.Settings.windDirectionY) * settings.flatCloudsDetailWindIntensity) * Time.deltaTime * 0.1f);
|
||||
cirrusAnim += new Vector2(((EnviroManager.instance.Environment.Settings.windSpeed * EnviroManager.instance.Environment.Settings.windDirectionX) * settings.cirrusCloudsWindIntensity) * Time.deltaTime * 0.01f, ((EnviroManager.instance.Environment.Settings.windSpeed * EnviroManager.instance.Environment.Settings.windDirectionY) * settings.cirrusCloudsWindIntensity) * Time.deltaTime * 0.01f);
|
||||
}
|
||||
else
|
||||
{
|
||||
cloudFlatBaseAnim += new Vector2(settings.flatCloudsWindIntensity * Time.deltaTime * 0.01f,settings.flatCloudsWindIntensity * Time.deltaTime * 0.01f);
|
||||
cloudFlatDetailAnim += new Vector2(settings.flatCloudsDetailWindIntensity * Time.deltaTime * 0.1f,settings.flatCloudsDetailWindIntensity * Time.deltaTime * 0.1f);
|
||||
cirrusAnim += new Vector2(settings.cirrusCloudsWindIntensity * Time.deltaTime * 0.01f,settings.cirrusCloudsWindIntensity * Time.deltaTime * 0.01f);
|
||||
}
|
||||
|
||||
cirrusAnim = EnviroHelper.PingPong(cirrusAnim);
|
||||
cloudFlatBaseAnim = EnviroHelper.PingPong(cloudFlatBaseAnim);
|
||||
cloudFlatDetailAnim = EnviroHelper.PingPong(cloudFlatDetailAnim);
|
||||
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroFlatCloudsModule t = ScriptableObject.CreateInstance<EnviroFlatCloudsModule>();
|
||||
t.name = "Flat Clouds Preset";
|
||||
t.settings = JsonUtility.FromJson<Enviro.EnviroFlatClouds>(JsonUtility.ToJson(settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
public void SaveModuleValues (EnviroFlatCloudsModule module)
|
||||
{
|
||||
module.settings = JsonUtility.FromJson<Enviro.EnviroFlatClouds>(JsonUtility.ToJson(settings));
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b982c9fba9faf3a43bf4a9e7ced867d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/FlatClouds/EnviroFlatCloudsModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a6a4b2e84e90ba4fb3010a5c31d5a9f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,133 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b982c9fba9faf3a43bf4a9e7ced867d7, type: 3}
|
||||
m_Name: Default Flat Clouds Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 0
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
settings:
|
||||
useCirrusClouds: 1
|
||||
cirrusCloudsTex: {fileID: 2800000, guid: 75c66597a85001644b2de40147b8d196, type: 3}
|
||||
cirrusCloudsAlpha: 0.5
|
||||
cirrusCloudsColorPower: 1
|
||||
cirrusCloudsCoverage: 0.5
|
||||
cirrusCloudsColor:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0, g: 0, b: 0, a: 1}
|
||||
key2: {r: 1, g: 0.18127085, b: 0, a: 0.9843137}
|
||||
key3: {r: 0.91764706, g: 0.78431374, b: 0.6431373, a: 0.9843137}
|
||||
key4: {r: 0.91764706, g: 0.8627451, b: 0.80784315, a: 0.9843137}
|
||||
key5: {r: 0.4627451, g: 0.9843137, b: 0.83137256, a: 0.9843137}
|
||||
key6: {r: 0.4627451, g: 0.9843137, b: 0.83137256, a: 0.9843137}
|
||||
key7: {r: 0.4627451, g: 0.9843137, b: 0.83137256, a: 0.9843137}
|
||||
ctime0: 0
|
||||
ctime1: 29696
|
||||
ctime2: 31641
|
||||
ctime3: 36700
|
||||
ctime4: 65535
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
cirrusCloudsWindIntensity: 0.5
|
||||
useFlatClouds: 0
|
||||
flatCloudsBaseTex: {fileID: 2800000, guid: d178a8cc601a00f48914c0bfd42c77d5, type: 3}
|
||||
flatCloudsDetailTex: {fileID: 2800000, guid: 2e0e351a1a0d49545a3dd0264e7ac2d9, type: 3}
|
||||
flatCloudsLightColor:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.12615699, g: 0.13726778, b: 0.1981132, a: 1}
|
||||
key2: {r: 1, g: 0.18127085, b: 0, a: 0}
|
||||
key3: {r: 0.91764706, g: 0.78431374, b: 0.6431373, a: 0}
|
||||
key4: {r: 0.91764706, g: 0.8627451, b: 0.80784315, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29696
|
||||
ctime2: 31641
|
||||
ctime3: 36700
|
||||
ctime4: 65535
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
flatCloudsAmbientColor:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.06781771, g: 0.07401677, b: 0.11320752, a: 1}
|
||||
key2: {r: 0.17319329, g: 0.2085657, b: 0.26415092, a: 0}
|
||||
key3: {r: 0.23535956, g: 0.28180525, b: 0.4056604, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29491
|
||||
ctime2: 33539
|
||||
ctime3: 65535
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 4
|
||||
m_NumAlphaKeys: 2
|
||||
flatCloudsLightIntensity: 0.478
|
||||
flatCloudsAmbientIntensity: 0.969
|
||||
flatCloudsShadowIntensity: 0.6
|
||||
flatCloudsShadowSteps: 8
|
||||
flatCloudsHGPhase: 0.8
|
||||
flatCloudsCoverage: 1.189
|
||||
flatCloudsDensity: 1
|
||||
flatCloudsAltitude: 1
|
||||
flatCloudsTonemapping: 0
|
||||
flatCloudsBaseTiling: 1
|
||||
flatCloudsDetailTiling: 10
|
||||
flatCloudsWindIntensity: 1
|
||||
flatCloudsDetailWindIntensity: 0.5
|
||||
preset: {fileID: 0}
|
||||
showCirrusCloudsControls: 0
|
||||
show2DCloudsControls: 0
|
||||
cloudFlatBaseAnim: {x: 0, y: 0}
|
||||
cloudFlatDetailAnim: {x: 0, y: 0}
|
||||
cirrusAnim: {x: 0, y: 0}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fcdd472bd6a8ec429fc1e9bc978c4fa
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/FlatClouds/Preset/Default
|
||||
Flat Clouds Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d15c93c666974ac4b83898ac5746c0d5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4eacb969ef7bfec4ba69d66b0a873f2f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Fog/EnviroFogModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,116 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
namespace Enviro
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("Enviro 3/Volumetric Light")]
|
||||
public class EnviroVolumetricFogLight : MonoBehaviour
|
||||
{
|
||||
[Range(0f,2f)]
|
||||
public float intensity = 1.0f;
|
||||
[Range(0f,2f)]
|
||||
public float range = 1.0f;
|
||||
|
||||
private Light myLight;
|
||||
|
||||
private bool initialized = false;
|
||||
private CommandBuffer cascadeShadowCB;
|
||||
//private CommandBuffer shadowMatrixBuffer;
|
||||
|
||||
|
||||
|
||||
public bool isOn
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isActiveAndEnabled)
|
||||
return false;
|
||||
|
||||
Init();
|
||||
|
||||
return myLight.enabled;
|
||||
}
|
||||
|
||||
private set{}
|
||||
}
|
||||
|
||||
new public Light light {get{Init(); return myLight;} private set{}}
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
Init();
|
||||
if(EnviroManager.instance != null && EnviroManager.instance.Fog != null)
|
||||
AddToLightManager();
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
#if !ENVIRO_URP && !ENVIRO_HDRP
|
||||
if(cascadeShadowCB != null && myLight != null && myLight.type == LightType.Directional)
|
||||
myLight.RemoveCommandBuffer(LightEvent.AfterShadowMap, cascadeShadowCB);
|
||||
#endif
|
||||
// if(shadowMatrixBuffer != null && myLight != null && myLight.type == LightType.Directional)
|
||||
// myLight.RemoveCommandBuffer(LightEvent.BeforeScreenspaceMask, shadowMatrixBuffer);
|
||||
|
||||
if(EnviroManager.instance != null && EnviroManager.instance.Fog != null)
|
||||
RemoveFromLightManager();
|
||||
}
|
||||
|
||||
void AddToLightManager()
|
||||
{
|
||||
bool addedToMgr = false;
|
||||
|
||||
for(int i = 0; i < EnviroManager.instance.Fog.fogLights.Count; i++)
|
||||
{
|
||||
if(EnviroManager.instance.Fog.fogLights[i] == this)
|
||||
{
|
||||
addedToMgr = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!addedToMgr)
|
||||
EnviroManager.instance.Fog.AddLight(this);
|
||||
}
|
||||
|
||||
void RemoveFromLightManager()
|
||||
{
|
||||
for(int i = 0; i < EnviroManager.instance.Fog.fogLights.Count; i++)
|
||||
{
|
||||
if(EnviroManager.instance.Fog.fogLights[i] == this)
|
||||
{
|
||||
EnviroManager.instance.Fog.RemoveLight(this);
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
|
||||
myLight = GetComponent<Light>();
|
||||
|
||||
#if !ENVIRO_URP && !ENVIRO_HDRP
|
||||
if(myLight.type == LightType.Directional)
|
||||
{
|
||||
cascadeShadowCB = new CommandBuffer();
|
||||
cascadeShadowCB.name = "Dir Light Command Buffer";
|
||||
cascadeShadowCB.SetGlobalTexture("_CascadeShadowMapTexture", new UnityEngine.Rendering.RenderTargetIdentifier(UnityEngine.Rendering.BuiltinRenderTextureType.CurrentActive));
|
||||
myLight.AddCommandBuffer(LightEvent.AfterShadowMap, cascadeShadowCB);
|
||||
|
||||
//shadowMatrixBuffer = new CommandBuffer();
|
||||
//shadowMatrixBuffer.name = "Extract Shadow Matrix Buffer";
|
||||
//myLight.AddCommandBuffer(LightEvent.BeforeShadowMap, shadowMatrixBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84329a1a5ad77384a9c3bb7ed65d8506
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Fog/EnviroVolumetricFogLight.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61db9d7312f446347a562504188fc2c9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,162 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4eacb969ef7bfec4ba69d66b0a873f2f, type: 3}
|
||||
m_Name: Default Fog Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 1
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
volumetrics: 1
|
||||
steps: 32
|
||||
quality: 1
|
||||
scattering: 0.425
|
||||
scatteringMultiplier:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 8
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 0.29862836
|
||||
value: 7.1266994
|
||||
inSlope: -7.9367094
|
||||
outSlope: -7.9367094
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.1494251
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.41374835
|
||||
value: 1.9498584
|
||||
inSlope: -5.9926996
|
||||
outSlope: -5.9926996
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.515421
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
extinction: 0.029
|
||||
anistropy: 0.5
|
||||
maxRange: 1000
|
||||
maxRangePointSpot: 100
|
||||
noiseIntensity: 0
|
||||
noiseScale: 0
|
||||
windDirection: {x: 3.9, y: 0, z: 0}
|
||||
noise: {fileID: 0}
|
||||
ditheringTex: {fileID: 2800000, guid: 711e788cbc742bb439b3c7cad60651e3, type: 3}
|
||||
fog: 1
|
||||
fogQualityMode: 0
|
||||
floatingPointOriginMod: {x: 0, y: 0, z: 0}
|
||||
globalFogHeight: 0
|
||||
fogDensity: 0.097
|
||||
fogHeightFalloff: 0.0045
|
||||
fogHeight: 0
|
||||
fogDensity2: 0.073
|
||||
fogHeightFalloff2: 0.05
|
||||
fogHeight2: -25
|
||||
fogMaxOpacity: 1
|
||||
startDistance: 0.01
|
||||
fogColorBlend: 0.7
|
||||
fogColorMod: {r: 1, g: 1, b: 1, a: 1}
|
||||
blockScattering: 1
|
||||
ambientColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0.23549305, g: 0.2427107, b: 0.7924528, a: 1}
|
||||
key1: {r: 0.16073336, g: 0.22812635, b: 0.7924528, a: 1}
|
||||
key2: {r: 0.35590956, g: 0.44551674, b: 0.5849056, a: 0}
|
||||
key3: {r: 2.5796902, g: 2.651018, b: 2.8293376, a: 0}
|
||||
key4: {r: 2.5796902, g: 2.651018, b: 2.8293376, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29491
|
||||
ctime2: 33539
|
||||
ctime3: 65535
|
||||
ctime4: 65535
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 4
|
||||
m_NumAlphaKeys: 2
|
||||
unityFog: 0
|
||||
unityFogMode: 2
|
||||
unityFogDensity: 0.05
|
||||
unityFogStartDistance: 0
|
||||
unityFogEndDistance: 1000
|
||||
unityFogColor:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.0146404365, g: 0.019780159, b: 0.066037714, a: 1}
|
||||
key2: {r: 0.12589, g: 0.15198022, b: 0.38679248, a: 0}
|
||||
key3: {r: 0.6415094, g: 0.39747813, b: 0.26326096, a: 0}
|
||||
key4: {r: 0.53266287, g: 0.63567483, b: 0.8490566, a: 0}
|
||||
key5: {r: 0.82702917, g: 0.8807278, b: 0.990566, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 23130
|
||||
ctime3: 32768
|
||||
ctime4: 36430
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
preset: {fileID: 0}
|
||||
showFogControls: 0
|
||||
showVolumetricsControls: 0
|
||||
showUnityFogControls: 0
|
||||
fogLights: []
|
||||
customFogDensityModifer: 1
|
||||
fogMat: {fileID: 0}
|
||||
volumetricsMat: {fileID: 0}
|
||||
blurMat: {fileID: 0}
|
||||
blurMat2: {fileID: 0}
|
||||
volumetricsRenderTexture: {fileID: 0}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6625884995235d049bd7f2f1de182577
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Fog/Preset/Default
|
||||
Fog Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a7145ce8216a5e4d96edca8030aa4c9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,509 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroLighting
|
||||
{
|
||||
// DirectLighting
|
||||
public enum LightingMode
|
||||
{
|
||||
Single,
|
||||
Dual
|
||||
};
|
||||
|
||||
public LightingMode lightingMode;
|
||||
public bool setDirectLighting = true;
|
||||
public int updateIntervallFrames = 2;
|
||||
public AnimationCurve sunIntensityCurve;
|
||||
public AnimationCurve moonIntensityCurve;
|
||||
[GradientUsageAttribute(true)]
|
||||
public Gradient sunColorGradient;
|
||||
[GradientUsageAttribute(true)]
|
||||
public Gradient moonColorGradient;
|
||||
public AnimationCurve sunIntensityCurveHDRP = new AnimationCurve();
|
||||
public AnimationCurve moonIntensityCurveHDRP = new AnimationCurve();
|
||||
public AnimationCurve lightColorTemperatureHDRP = new AnimationCurve();
|
||||
[GradientUsageAttribute(true)]
|
||||
public Gradient ambientColorTintHDRP;
|
||||
public float lightIntensityHDRP = 750f;
|
||||
public bool controlExposure = true;
|
||||
public AnimationCurve sceneExposure = new AnimationCurve();
|
||||
public bool controlIndirectLighting = true;
|
||||
public AnimationCurve diffuseIndirectIntensity = new AnimationCurve();
|
||||
public AnimationCurve reflectionIndirectIntensity = new AnimationCurve();
|
||||
|
||||
[Range(0f,2f)]
|
||||
public float directLightIntensityModifier = 1f;
|
||||
|
||||
//Ambient Lighting
|
||||
public bool setAmbientLighting = true;
|
||||
public UnityEngine.Rendering.AmbientMode ambientMode;
|
||||
[GradientUsage(true)]
|
||||
public Gradient ambientSkyColorGradient;
|
||||
[GradientUsage(true)]
|
||||
public Gradient ambientEquatorColorGradient;
|
||||
[GradientUsage(true)]
|
||||
public Gradient ambientGroundColorGradient;
|
||||
public AnimationCurve ambientIntensityCurve;
|
||||
|
||||
[Range(0f,2f)]
|
||||
public float ambientIntensityModifier = 1f;
|
||||
|
||||
public bool ambientUpdateEveryFrame = false;
|
||||
|
||||
[Range(0f,2f)]
|
||||
public float ambientUpdateIntervall = 0.1f;
|
||||
|
||||
[Range(0f,1f)]
|
||||
public float shadowIntensity = 1f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[ExecuteInEditMode]
|
||||
public class EnviroLightingModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroLighting Settings;
|
||||
public EnviroLightingModule preset;
|
||||
|
||||
private int currentFrame;
|
||||
private float lastAmbientSkyboxUpdate;
|
||||
|
||||
//Inspector
|
||||
public bool showDirectLightingControls;
|
||||
public bool showAmbientLightingControls;
|
||||
public bool showReflectionControls;
|
||||
|
||||
#if ENVIRO_HDRP
|
||||
public UnityEngine.Rendering.HighDefinition.HDAdditionalLightData directionalLightHDRP;
|
||||
public UnityEngine.Rendering.HighDefinition.HDAdditionalLightData additionalLightHDRP;
|
||||
public UnityEngine.Rendering.HighDefinition.Exposure exposureHDRP;
|
||||
public UnityEngine.Rendering.HighDefinition.IndirectLightingController indirectLightingHDRP;
|
||||
#endif
|
||||
|
||||
public override void Enable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
public override void Disable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
//Applies changes when you switch the lighting mode.
|
||||
public void ApplyLightingChanges ()
|
||||
{
|
||||
Cleanup();
|
||||
Setup();
|
||||
}
|
||||
|
||||
private void Setup()
|
||||
{
|
||||
if(EnviroManager.instance.Objects.directionalLight == null)
|
||||
{
|
||||
GameObject newLight = new GameObject();
|
||||
|
||||
if(Settings.lightingMode == EnviroLighting.LightingMode.Single)
|
||||
newLight.name = "Sun and Moon Directional Light";
|
||||
else
|
||||
newLight.name = "Sun Directional Light";
|
||||
|
||||
newLight.transform.SetParent(EnviroManager.instance.transform);
|
||||
newLight.transform.localPosition = Vector3.zero;
|
||||
EnviroManager.instance.Objects.directionalLight = newLight.AddComponent<Light>();
|
||||
EnviroManager.instance.Objects.directionalLight.type = LightType.Directional;
|
||||
EnviroManager.instance.Objects.directionalLight.shadows = LightShadows.Soft;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Objects.additionalDirectionalLight == null && Settings.lightingMode == EnviroLighting.LightingMode.Dual)
|
||||
{
|
||||
GameObject newLight = new GameObject();
|
||||
newLight.name = "Moon Directional Light";
|
||||
newLight.transform.SetParent(EnviroManager.instance.transform);
|
||||
newLight.transform.localPosition = Vector3.zero;
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight = newLight.AddComponent<Light>();
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.type = LightType.Directional;
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.shadows = LightShadows.Soft;
|
||||
}
|
||||
else if (EnviroManager.instance.Objects.additionalDirectionalLight != null && Settings.lightingMode == EnviroLighting.LightingMode.Single)
|
||||
{
|
||||
DestroyImmediate(EnviroManager.instance.Objects.additionalDirectionalLight.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void Cleanup()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance.Objects.directionalLight != null)
|
||||
DestroyImmediate(EnviroManager.instance.Objects.directionalLight.gameObject);
|
||||
|
||||
if(EnviroManager.instance.Objects.additionalDirectionalLight != null)
|
||||
DestroyImmediate(EnviroManager.instance.Objects.additionalDirectionalLight.gameObject);
|
||||
}
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
currentFrame++;
|
||||
|
||||
if(currentFrame >= Settings.updateIntervallFrames)
|
||||
{
|
||||
EnviroManager.instance.updateSkyAndLighting = true;
|
||||
currentFrame = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnviroManager.instance.updateSkyAndLighting = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Update Direct Lighting
|
||||
if(EnviroManager.instance.Objects.directionalLight != null && Settings.setDirectLighting)
|
||||
{
|
||||
#if !ENVIRO_HDRP
|
||||
if(EnviroManager.instance.updateSkyAndLighting)
|
||||
UpdateDirectLighting ();
|
||||
#else
|
||||
if(EnviroManager.instance.updateSkyAndLighting)
|
||||
UpdateDirectLightingHDRP();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Settings.setAmbientLighting)
|
||||
{
|
||||
#if !ENVIRO_HDRP
|
||||
UpdateAmbientLighting (Settings.ambientUpdateEveryFrame);
|
||||
#else
|
||||
if(EnviroManager.instance.updateSkyAndLighting)
|
||||
UpdateAmbientLightingHDRP ();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENVIRO_HDRP
|
||||
if(EnviroManager.instance.updateSkyAndLighting)
|
||||
UpdateExposureHDRP ();
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void UpdateDirectLighting ()
|
||||
{
|
||||
if(Settings.lightingMode == EnviroLighting.LightingMode.Single)
|
||||
{
|
||||
if(!EnviroManager.instance.isNight)
|
||||
{
|
||||
//Set light to sun
|
||||
EnviroManager.instance.Objects.directionalLight.transform.rotation = EnviroManager.instance.Objects.sun.transform.rotation;
|
||||
EnviroManager.instance.Objects.directionalLight.intensity = Settings.sunIntensityCurve.Evaluate(EnviroManager.instance.solarTime) * Settings.directLightIntensityModifier;
|
||||
EnviroManager.instance.Objects.directionalLight.color = Settings.sunColorGradient.Evaluate(EnviroManager.instance.solarTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Set light to moon
|
||||
EnviroManager.instance.Objects.directionalLight.transform.rotation = EnviroManager.instance.Objects.moon.transform.rotation;
|
||||
EnviroManager.instance.Objects.directionalLight.intensity = Settings.moonIntensityCurve.Evaluate(EnviroManager.instance.lunarTime) * Settings.directLightIntensityModifier;
|
||||
EnviroManager.instance.Objects.directionalLight.color = Settings.moonColorGradient.Evaluate(EnviroManager.instance.lunarTime);
|
||||
}
|
||||
|
||||
EnviroManager.instance.Objects.directionalLight.shadowStrength = Settings.shadowIntensity;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Sun
|
||||
EnviroManager.instance.Objects.directionalLight.transform.rotation = EnviroManager.instance.Objects.sun.transform.rotation;
|
||||
EnviroManager.instance.Objects.directionalLight.intensity = Settings.sunIntensityCurve.Evaluate(EnviroManager.instance.solarTime) * Settings.directLightIntensityModifier;
|
||||
EnviroManager.instance.Objects.directionalLight.color = Settings.sunColorGradient.Evaluate(EnviroManager.instance.solarTime);
|
||||
EnviroManager.instance.Objects.directionalLight.shadowStrength = Settings.shadowIntensity;
|
||||
//Moon
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.transform.rotation = EnviroManager.instance.Objects.moon.transform.rotation;
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.intensity = Settings.moonIntensityCurve.Evaluate(EnviroManager.instance.lunarTime) * Settings.directLightIntensityModifier;
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.color = Settings.moonColorGradient.Evaluate(EnviroManager.instance.lunarTime);
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.shadowStrength = Settings.shadowIntensity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if ENVIRO_HDRP
|
||||
public void UpdateDirectLightingHDRP ()
|
||||
{
|
||||
if(directionalLightHDRP == null && EnviroManager.instance.Objects.directionalLight != null)
|
||||
directionalLightHDRP = EnviroManager.instance.Objects.directionalLight.gameObject.GetComponent<UnityEngine.Rendering.HighDefinition.HDAdditionalLightData>();
|
||||
|
||||
if(additionalLightHDRP == null && EnviroManager.instance.Objects.additionalDirectionalLight != null)
|
||||
additionalLightHDRP = EnviroManager.instance.Objects.additionalDirectionalLight.gameObject.GetComponent<UnityEngine.Rendering.HighDefinition.HDAdditionalLightData>();
|
||||
|
||||
if(Settings.lightingMode == EnviroLighting.LightingMode.Single)
|
||||
{
|
||||
if(!EnviroManager.instance.isNight)
|
||||
{
|
||||
//Set light to sun
|
||||
EnviroManager.instance.Objects.directionalLight.transform.rotation = EnviroManager.instance.Objects.sun.transform.rotation;
|
||||
EnviroManager.instance.Objects.directionalLight.color = Settings.sunColorGradient.Evaluate(EnviroManager.instance.solarTime);
|
||||
EnviroManager.instance.Objects.directionalLight.useColorTemperature = true;
|
||||
EnviroManager.instance.Objects.directionalLight.colorTemperature = Settings.lightColorTemperatureHDRP.Evaluate(EnviroManager.instance.solarTime);
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
EnviroManager.instance.Objects.directionalLight.intensity = Settings.sunIntensityCurve.Evaluate(EnviroManager.instance.solarTime) * Settings.lightIntensityHDRP * Settings.directLightIntensityModifier;
|
||||
#else
|
||||
if(directionalLightHDRP != null)
|
||||
directionalLightHDRP.SetIntensity(Settings.sunIntensityCurve.Evaluate(EnviroManager.instance.solarTime) * Settings.lightIntensityHDRP * Settings.directLightIntensityModifier);
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Set light to moon
|
||||
EnviroManager.instance.Objects.directionalLight.transform.rotation = EnviroManager.instance.Objects.moon.transform.rotation;
|
||||
EnviroManager.instance.Objects.directionalLight.color = Settings.moonColorGradient.Evaluate(EnviroManager.instance.lunarTime);
|
||||
EnviroManager.instance.Objects.directionalLight.useColorTemperature = true;
|
||||
EnviroManager.instance.Objects.directionalLight.colorTemperature = Settings.lightColorTemperatureHDRP.Evaluate(EnviroManager.instance.solarTime);
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
EnviroManager.instance.Objects.directionalLight.intensity = Settings.moonIntensityCurve.Evaluate(EnviroManager.instance.lunarTime) * Settings.lightIntensityHDRP* Settings.directLightIntensityModifier;
|
||||
#else
|
||||
if (directionalLightHDRP != null)
|
||||
directionalLightHDRP.SetIntensity(Settings.moonIntensityCurve.Evaluate(EnviroManager.instance.lunarTime) * Settings.lightIntensityHDRP * Settings.directLightIntensityModifier);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(directionalLightHDRP != null)
|
||||
directionalLightHDRP.shadowDimmer = Settings.shadowIntensity;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Sun
|
||||
EnviroManager.instance.Objects.directionalLight.transform.rotation = EnviroManager.instance.Objects.sun.transform.rotation;
|
||||
EnviroManager.instance.Objects.directionalLight.color = Settings.sunColorGradient.Evaluate(EnviroManager.instance.solarTime);
|
||||
EnviroManager.instance.Objects.directionalLight.useColorTemperature = true;
|
||||
EnviroManager.instance.Objects.directionalLight.colorTemperature = Settings.lightColorTemperatureHDRP.Evaluate(EnviroManager.instance.solarTime);
|
||||
|
||||
if(directionalLightHDRP != null)
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
EnviroManager.instance.Objects.directionalLight.intensity = Settings.sunIntensityCurve.Evaluate(EnviroManager.instance.solarTime) * Settings.lightIntensityHDRP* Settings.directLightIntensityModifier;
|
||||
#else
|
||||
directionalLightHDRP.SetIntensity(Settings.sunIntensityCurve.Evaluate(EnviroManager.instance.solarTime) * Settings.lightIntensityHDRP * Settings.directLightIntensityModifier);
|
||||
#endif
|
||||
|
||||
directionalLightHDRP.shadowDimmer = Settings.shadowIntensity;
|
||||
}
|
||||
//Moon
|
||||
if(EnviroManager.instance.Objects.additionalDirectionalLight != null)
|
||||
{
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.transform.rotation = EnviroManager.instance.Objects.moon.transform.rotation;
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.color = Settings.moonColorGradient.Evaluate(EnviroManager.instance.lunarTime);
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.useColorTemperature = true;
|
||||
EnviroManager.instance.Objects.additionalDirectionalLight.colorTemperature = Settings.lightColorTemperatureHDRP.Evaluate(EnviroManager.instance.solarTime);
|
||||
}
|
||||
|
||||
if(additionalLightHDRP != null)
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
EnviroManager.instance.Objects.directionalLight.intensity = Settings.moonIntensityCurve.Evaluate(EnviroManager.instance.lunarTime) * Settings.lightIntensityHDRP * Settings.directLightIntensityModifier;
|
||||
#else
|
||||
additionalLightHDRP.SetIntensity(Settings.moonIntensityCurve.Evaluate(EnviroManager.instance.lunarTime) * Settings.lightIntensityHDRP * Settings.directLightIntensityModifier);
|
||||
#endif
|
||||
|
||||
additionalLightHDRP.shadowDimmer = Settings.shadowIntensity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAmbientLightingHDRP ()
|
||||
{
|
||||
if(EnviroManager.instance.volumeHDRP != null && EnviroManager.instance.volumeProfileHDRP != null)
|
||||
{
|
||||
if(indirectLightingHDRP == null)
|
||||
{
|
||||
UnityEngine.Rendering.HighDefinition.IndirectLightingController TempIndirectLight;
|
||||
|
||||
if (EnviroManager.instance.volumeProfileHDRP.TryGet<UnityEngine.Rendering.HighDefinition.IndirectLightingController>(out TempIndirectLight))
|
||||
{
|
||||
indirectLightingHDRP = TempIndirectLight;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnviroManager.instance.volumeProfileHDRP.Add<UnityEngine.Rendering.HighDefinition.IndirectLightingController>();
|
||||
|
||||
if (EnviroManager.instance.volumeProfileHDRP.TryGet<UnityEngine.Rendering.HighDefinition.IndirectLightingController>(out TempIndirectLight))
|
||||
{
|
||||
indirectLightingHDRP = TempIndirectLight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Settings.controlIndirectLighting)
|
||||
{
|
||||
indirectLightingHDRP.active = true;
|
||||
indirectLightingHDRP.indirectDiffuseLightingMultiplier.overrideState = true;
|
||||
indirectLightingHDRP.indirectDiffuseLightingMultiplier.value = Settings.diffuseIndirectIntensity.Evaluate(EnviroManager.instance.solarTime);
|
||||
indirectLightingHDRP.reflectionLightingMultiplier.overrideState = true;
|
||||
indirectLightingHDRP.reflectionLightingMultiplier.value = Settings.reflectionIndirectIntensity.Evaluate(EnviroManager.instance.solarTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
indirectLightingHDRP.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateExposureHDRP ()
|
||||
{
|
||||
if(EnviroManager.instance.volumeHDRP != null && EnviroManager.instance.volumeProfileHDRP != null)
|
||||
{
|
||||
if(exposureHDRP == null)
|
||||
{
|
||||
UnityEngine.Rendering.HighDefinition.Exposure TempExposure;
|
||||
|
||||
if (EnviroManager.instance.volumeProfileHDRP.TryGet<UnityEngine.Rendering.HighDefinition.Exposure>(out TempExposure))
|
||||
{
|
||||
exposureHDRP = TempExposure;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnviroManager.instance.volumeProfileHDRP.Add<UnityEngine.Rendering.HighDefinition.Exposure>();
|
||||
|
||||
if (EnviroManager.instance.volumeProfileHDRP.TryGet<UnityEngine.Rendering.HighDefinition.Exposure>(out TempExposure))
|
||||
{
|
||||
exposureHDRP = TempExposure;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Settings.controlExposure)
|
||||
{
|
||||
exposureHDRP.active = true;
|
||||
exposureHDRP.mode.overrideState = true;
|
||||
exposureHDRP.mode.value = UnityEngine.Rendering.HighDefinition.ExposureMode.Fixed;
|
||||
exposureHDRP.fixedExposure.overrideState = true;
|
||||
exposureHDRP.fixedExposure.value = Settings.sceneExposure.Evaluate(EnviroManager.instance.solarTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
exposureHDRP.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public void UpdateAmbientLighting (bool forced = false)
|
||||
{
|
||||
RenderSettings.ambientMode = Settings.ambientMode;
|
||||
|
||||
float intensity = Settings.ambientIntensityCurve.Evaluate(EnviroManager.instance.solarTime) * Settings.ambientIntensityModifier;
|
||||
|
||||
RenderSettings.ambientIntensity = intensity;
|
||||
|
||||
if(forced)
|
||||
{
|
||||
UpdateAmbient(Settings.ambientMode,intensity);
|
||||
|
||||
if(EnviroManager.instance.Time != null)
|
||||
{
|
||||
lastAmbientSkyboxUpdate = EnviroManager.instance.Time.Settings.timeOfDay + Settings.ambientUpdateIntervall;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(EnviroManager.instance.Time != null)
|
||||
{
|
||||
if (lastAmbientSkyboxUpdate < EnviroManager.instance.Time.Settings.timeOfDay || lastAmbientSkyboxUpdate > EnviroManager.instance.Time.Settings.timeOfDay + (Settings.ambientUpdateIntervall + 0.01f))
|
||||
{
|
||||
UpdateAmbient(Settings.ambientMode,intensity);
|
||||
lastAmbientSkyboxUpdate = EnviroManager.instance.Time.Settings.timeOfDay + Settings.ambientUpdateIntervall;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lastAmbientSkyboxUpdate < Time.time)
|
||||
{
|
||||
UpdateAmbient(Settings.ambientMode,intensity);
|
||||
lastAmbientSkyboxUpdate = Time.time + (Settings.ambientUpdateIntervall * 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAmbient(UnityEngine.Rendering.AmbientMode ambientMode, float intensity)
|
||||
{
|
||||
switch (ambientMode)
|
||||
{
|
||||
case UnityEngine.Rendering.AmbientMode.Flat:
|
||||
RenderSettings.ambientSkyColor = Settings.ambientSkyColorGradient.Evaluate(EnviroManager.instance.solarTime) * intensity;
|
||||
break;
|
||||
|
||||
case UnityEngine.Rendering.AmbientMode.Trilight:
|
||||
RenderSettings.ambientSkyColor = Settings.ambientSkyColorGradient.Evaluate(EnviroManager.instance.solarTime) * intensity;
|
||||
RenderSettings.ambientEquatorColor = Settings.ambientEquatorColorGradient.Evaluate(EnviroManager.instance.solarTime) * intensity;
|
||||
RenderSettings.ambientGroundColor = Settings.ambientGroundColorGradient.Evaluate(EnviroManager.instance.solarTime) * intensity;
|
||||
break;
|
||||
|
||||
case UnityEngine.Rendering.AmbientMode.Skybox:
|
||||
DynamicGI.UpdateEnvironment();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroLighting>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroLightingModule t = ScriptableObject.CreateInstance<EnviroLightingModule>();
|
||||
t.name = "Lighting Module";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroLighting>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SaveModuleValues (EnviroLightingModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroLighting>(JsonUtility.ToJson(Settings));
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b18a0693e95fd064e9d0a3b96e538236
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Lighting/EnviroLightingModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43d2103184b3c9b4a9f920958db18b55
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,542 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b18a0693e95fd064e9d0a3b96e538236, type: 3}
|
||||
m_Name: Default Lighting Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 1
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
lightingMode: 0
|
||||
setDirectLighting: 1
|
||||
updateIntervallFrames: 1
|
||||
sunIntensityCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.42
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.5817692
|
||||
value: 1.9319578
|
||||
inSlope: 0.20075521
|
||||
outSlope: 0.20075521
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.99427843
|
||||
value: 1.9724423
|
||||
inSlope: 0.138579
|
||||
outSlope: 0.138579
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33801654
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
moonIntensityCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.42
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.61047
|
||||
value: 0.46311775
|
||||
inSlope: 0.20075521
|
||||
outSlope: 0.20075521
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.9869074
|
||||
value: 0.49453083
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
sunColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0.29803923, g: 0.33333334, b: 0.4392157, a: 1}
|
||||
key1: {r: 0.3853806, g: 0.4379325, b: 0.5955882, a: 1}
|
||||
key2: {r: 1, g: 0.51851845, b: 0, a: 0}
|
||||
key3: {r: 0.91764706, g: 0.78431374, b: 0.6431373, a: 0}
|
||||
key4: {r: 0.91764706, g: 0.8627451, b: 0.80784315, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29491
|
||||
ctime2: 33153
|
||||
ctime3: 36700
|
||||
ctime4: 65535
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
moonColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.009433985, g: 0.009433985, b: 0.009433985, a: 1}
|
||||
key2: {r: 0.35844606, g: 0.38487896, b: 0.4245283, a: 0}
|
||||
key3: {r: 0.45990568, g: 0.5011793, b: 0.6132076, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29491
|
||||
ctime2: 33539
|
||||
ctime3: 65535
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 4
|
||||
m_NumAlphaKeys: 2
|
||||
sunIntensityCurveHDRP:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: -0.005858557
|
||||
value: 0
|
||||
inSlope: -69.7483
|
||||
outSlope: -69.7483
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.28545874
|
||||
- serializedVersion: 3
|
||||
time: 0.42
|
||||
value: 0
|
||||
inSlope: -14.224594
|
||||
outSlope: -14.224594
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.16805899
|
||||
outWeight: 0.5635239
|
||||
- serializedVersion: 3
|
||||
time: 0.51438606
|
||||
value: 619.9909
|
||||
inSlope: 14358.117
|
||||
outSlope: 14358.117
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.12846851
|
||||
outWeight: 0.20660013
|
||||
- serializedVersion: 3
|
||||
time: 0.6068845
|
||||
value: 1314.4552
|
||||
inSlope: 1486.1951
|
||||
outSlope: 1486.1951
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.330822
|
||||
outWeight: 0.16775069
|
||||
- serializedVersion: 3
|
||||
time: 1.0073586
|
||||
value: 1497.6918
|
||||
inSlope: -142.08925
|
||||
outSlope: -142.08925
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.18685488
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
moonIntensityCurveHDRP:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.42
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 1
|
||||
- serializedVersion: 3
|
||||
time: 0.5151054
|
||||
value: 29.550873
|
||||
inSlope: 936.90796
|
||||
outSlope: 936.90796
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.42325592
|
||||
outWeight: 0.25243106
|
||||
- serializedVersion: 3
|
||||
time: 0.5727867
|
||||
value: 65.81247
|
||||
inSlope: 153.72064
|
||||
outSlope: 153.72064
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.3182723
|
||||
outWeight: 0.17477258
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 89.63618
|
||||
inSlope: 0.074095555
|
||||
outSlope: 0.074095555
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.14896
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
lightColorTemperatureHDRP:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0.0042874366
|
||||
value: 10002.518
|
||||
inSlope: -65.305664
|
||||
outSlope: -65.305664
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.38720584
|
||||
value: 9894.908
|
||||
inSlope: -855.4398
|
||||
outSlope: -855.4398
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.4745867
|
||||
value: 2850.5876
|
||||
inSlope: 926.3545
|
||||
outSlope: 926.3545
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.6485079
|
||||
value: 4931.462
|
||||
inSlope: 4445.381
|
||||
outSlope: 4445.381
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1.0041809
|
||||
value: 5500
|
||||
inSlope: 93.2233
|
||||
outSlope: 93.2233
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
ambientColorTintHDRP:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0.8867924, g: 0.8867924, b: 0.8867924, a: 1}
|
||||
key1: {r: 0.9056604, g: 0.9013884, b: 0.9013884, a: 1}
|
||||
key2: {r: 2, g: 2, b: 2, a: 0.78431374}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0.78431374}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 65535
|
||||
ctime2: 65535
|
||||
ctime3: 0
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 65535
|
||||
atime3: 65535
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 2
|
||||
m_NumAlphaKeys: 2
|
||||
lightIntensityHDRP: 350
|
||||
controlExposure: 1
|
||||
sceneExposure:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
controlIndirectLighting: 1
|
||||
diffuseIndirectIntensity:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reflectionIndirectIntensity:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
directLightIntensityModifier: 1
|
||||
setAmbientLighting: 1
|
||||
ambientMode: 0
|
||||
ambientSkyColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.010946958, g: 0.015512637, b: 0.05660379, a: 1}
|
||||
key2: {r: 0.17475082, g: 0.18796726, b: 0.31132078, a: 0}
|
||||
key3: {r: 0.33931115, g: 0.43156135, b: 0.5754717, a: 0}
|
||||
key4: {r: 0.5298594, g: 0.60636276, b: 0.764151, a: 0}
|
||||
key5: {r: 0.5298594, g: 0.60636276, b: 0.764151, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 15360
|
||||
ctime2: 29593
|
||||
ctime3: 36556
|
||||
ctime4: 65535
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
ambientEquatorColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.010946958, g: 0.015512637, b: 0.05660379, a: 1}
|
||||
key2: {r: 0.15356888, g: 0.16649368, b: 0.2735849, a: 0}
|
||||
key3: {r: 0.33931115, g: 0.43156135, b: 0.5754717, a: 0}
|
||||
key4: {r: 0.5298594, g: 0.60636276, b: 0.764151, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 15360
|
||||
ctime2: 29593
|
||||
ctime3: 36556
|
||||
ctime4: 65535
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
ambientGroundColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.010946958, g: 0.015512637, b: 0.05660379, a: 1}
|
||||
key2: {r: 0.15356888, g: 0.16649368, b: 0.2735849, a: 0}
|
||||
key3: {r: 0.33931115, g: 0.43156135, b: 0.5754717, a: 0}
|
||||
key4: {r: 0.5298594, g: 0.60636276, b: 0.764151, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 15360
|
||||
ctime2: 29593
|
||||
ctime3: 36556
|
||||
ctime4: 65535
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
ambientIntensityCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: -0.021333456
|
||||
value: 0.8050667
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.97866654
|
||||
value: 0.8050667
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
ambientIntensityModifier: 1
|
||||
ambientUpdateEveryFrame: 0
|
||||
ambientUpdateIntervall: 0.1
|
||||
shadowIntensity: 0.996
|
||||
preset: {fileID: 0}
|
||||
showDirectLightingControls: 0
|
||||
showAmbientLightingControls: 0
|
||||
showReflectionControls: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81d8b109102443243bcb0894975c0718
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Lighting/Preset/Default
|
||||
Lighting Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c3b7ecd7d94a254bb2c730b1f0ab9ca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,184 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for a lightning effect.
|
||||
/// </summary>
|
||||
public interface ILightningEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Casts the bolt.
|
||||
/// </summary>
|
||||
/// <param name="origin">The starting position of the bolt.</param>
|
||||
/// <param name="target">The target position of the bolt.</param>
|
||||
void CastBolt(Vector3 origin, Vector3 target);
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroLightning
|
||||
{
|
||||
public Lightning prefab;
|
||||
public GameObject customLightningEffect;
|
||||
|
||||
public bool lightningStorm = false;
|
||||
[Range(1f,60f)]
|
||||
public float randomLightingDelay = 10.0f;
|
||||
[Range(0f,10000f)]
|
||||
public float randomSpawnRange = 5000.0f;
|
||||
[Range(0f,10000f)]
|
||||
public float randomTargetRange = 5000.0f;
|
||||
|
||||
[Range(0f,10000f)]
|
||||
public float cloudsLightningRadius = 2500.0f;
|
||||
[Range(.1f,5f)]
|
||||
public float cloudsLightningDuration = 1.0f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroLightningModule : EnviroModule
|
||||
{
|
||||
public EnviroLightning Settings;
|
||||
public EnviroLightningModule preset;
|
||||
public bool showLightningControls;
|
||||
private bool spawned = false;
|
||||
|
||||
private float lightningStart = -999f;
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
if(Application.isPlaying && Settings.lightningStorm && Settings.prefab != null)
|
||||
{
|
||||
CastLightningBoltRandom();
|
||||
}
|
||||
}
|
||||
|
||||
public void CastLightningBolt(Vector3 from, Vector3 to)
|
||||
{
|
||||
if(Settings.prefab != null)
|
||||
{
|
||||
GameObject lightningGameObject;
|
||||
if (Settings.customLightningEffect != null)
|
||||
{
|
||||
lightningGameObject = Instantiate(Settings.customLightningEffect, from, Quaternion.identity);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightningGameObject = Instantiate(Settings.prefab, from, Quaternion.identity).gameObject;
|
||||
}
|
||||
|
||||
var lightningEffect = lightningGameObject.GetComponent<ILightningEffect>();
|
||||
lightningEffect.CastBolt(from, to);
|
||||
|
||||
|
||||
//Play Thunder SFX with delay if Audio module is used.
|
||||
if (EnviroManager.instance.Audio != null)
|
||||
{
|
||||
EnviroManager.instance.StartCoroutine(PlayThunderSFX(0.05f));
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.VolumetricClouds != null)
|
||||
{
|
||||
EnviroManager.instance.StartCoroutine(CloudsFlash(0.25f,from));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a lightning prefab in your Enviro Ligthning module!");
|
||||
}
|
||||
}
|
||||
|
||||
public void CastLightningBoltRandom()
|
||||
{
|
||||
if(!spawned)
|
||||
{
|
||||
//Calculate some random spawn and target locations.
|
||||
Vector2 circlSpawn = UnityEngine.Random.insideUnitCircle * Settings.randomSpawnRange;
|
||||
Vector2 circlTarget = UnityEngine.Random.insideUnitCircle * Settings.randomTargetRange;
|
||||
float offset = 0f;
|
||||
|
||||
if(EnviroManager.instance.Objects.worldAnchor != null)
|
||||
offset = EnviroManager.instance.Objects.worldAnchor.transform.position.y;
|
||||
|
||||
float altitude = 2000f;
|
||||
|
||||
if(EnviroManager.instance.VolumetricClouds != null)
|
||||
altitude = Mathf.Max(EnviroManager.instance.VolumetricClouds.settingsVolume.bottomCloudsHeight + 1000f, 1000f);
|
||||
|
||||
Vector3 spawnPosition = new Vector3(circlSpawn.x + EnviroManager.instance.transform.position.x, offset + altitude, circlSpawn.y + EnviroManager.instance.transform.position.z);
|
||||
Vector3 targetPosition = new Vector3(circlTarget.x + spawnPosition.x,offset,circlTarget.y + spawnPosition.z);
|
||||
|
||||
EnviroManager.instance.StartCoroutine(LightningStorm(spawnPosition,targetPosition));
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator LightningStorm(Vector3 spwn, Vector3 targ)
|
||||
{
|
||||
spawned = true;
|
||||
CastLightningBolt(spwn,targ);
|
||||
yield return new WaitForSeconds(UnityEngine.Random.Range(Settings.randomLightingDelay, Settings.randomLightingDelay * 2f));
|
||||
spawned = false;
|
||||
}
|
||||
|
||||
private IEnumerator PlayThunderSFX(float delay)
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
EnviroManager.instance.Audio.PlayRandomThunderSFX();
|
||||
}
|
||||
private IEnumerator CloudsFlash(float delay, Vector3 from)
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
//Clouds
|
||||
lightningStart = Time.time;
|
||||
|
||||
// Pass to shader each frame
|
||||
Shader.SetGlobalVector("_LightningCenter", from);
|
||||
Shader.SetGlobalFloat("_LightningRadius", Settings.cloudsLightningRadius);
|
||||
Shader.SetGlobalFloat("_LightningStart", lightningStart);
|
||||
Shader.SetGlobalFloat("_LightningDuration", Settings.cloudsLightningDuration);
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroLightning>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroLightningModule t = ScriptableObject.CreateInstance<EnviroLightningModule>();
|
||||
t.name = "Lightning Preset";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroLightning>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
public void SaveModuleValues (EnviroLightningModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroLightning>(JsonUtility.ToJson(Settings));
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 258de2724c9dfb643a546d0688715ff1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Lightning/EnviroLightningModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,182 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
|
||||
public class Lightning : MonoBehaviour, ILightningEffect
|
||||
{
|
||||
public void CastBolt(Vector3 origin, Vector3 target)
|
||||
{
|
||||
this.transform.position = origin;
|
||||
this.target = target;
|
||||
this.CastBolt();
|
||||
}
|
||||
|
||||
public float flashIntensity = 50f;
|
||||
public Vector3 target;
|
||||
private LineRenderer lineRend;
|
||||
public Light myLight;
|
||||
public Material planeMat;
|
||||
public int arcs = 20;
|
||||
public float arcLength = 100.0f;
|
||||
public float arcVariation = 1.0f;
|
||||
public float inaccuracy = 0.5f;
|
||||
public int splits = 4;
|
||||
public int maxSplits = 24;
|
||||
private int splitCount = 0;
|
||||
public float splitLength = 100.0f;
|
||||
public float splitVariation = 1.0f;
|
||||
|
||||
public Vector3 toTarget;
|
||||
private bool fadeOut;
|
||||
private float fadeTimer;
|
||||
|
||||
void OnEnable ()
|
||||
{
|
||||
lineRend = gameObject.GetComponent<LineRenderer> ();
|
||||
}
|
||||
|
||||
IEnumerator CreateLightningBolt()
|
||||
{
|
||||
myLight.enabled = false;
|
||||
lineRend.widthMultiplier = 10;
|
||||
planeMat.SetFloat("_Brightness", 1f);
|
||||
|
||||
|
||||
lineRend.SetPosition(0, transform.position);
|
||||
lineRend.positionCount = 2;
|
||||
lineRend.SetPosition(1, transform.position);
|
||||
Vector3 lastPoint = transform.position;
|
||||
float dist = Vector3.Distance(transform.position, target);
|
||||
|
||||
float arcDist = dist / arcs;
|
||||
|
||||
for (int i = 1; i < arcs; i++)
|
||||
{
|
||||
planeMat.SetFloat("_Brightness", Random.Range(0f,2f));
|
||||
lineRend.positionCount = i + 1;
|
||||
Vector3 fwd = target - lastPoint;
|
||||
fwd.Normalize ();
|
||||
Vector3 pos = Randomize (fwd, inaccuracy);
|
||||
pos *= Random.Range (arcLength * arcVariation, arcLength) * (arcDist);
|
||||
pos += lastPoint;
|
||||
lineRend.SetPosition (i, pos);
|
||||
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
for (int s = 0; s <= splits; s++)
|
||||
{
|
||||
if(splitCount < maxSplits)
|
||||
StartCoroutine(CreateSplit(pos, target));
|
||||
}
|
||||
}
|
||||
|
||||
lastPoint = pos;
|
||||
// yield return new WaitForSeconds(Random.Range(0.001f,0.005f));
|
||||
}
|
||||
yield return new WaitForSeconds(Random.Range(0.1f,0.2f));
|
||||
lineRend.SetPosition(arcs-1,target);
|
||||
|
||||
//Animate Light and Main bolt
|
||||
myLight.transform.position = target;
|
||||
|
||||
if(EnviroManager.instance.Camera != null)
|
||||
myLight.transform.LookAt(EnviroManager.instance.Camera.transform.position, Vector3.up);
|
||||
|
||||
lineRend.material.SetFloat("_Brightness", this.flashIntensity);
|
||||
planeMat.SetFloat("_Brightness", 20f);
|
||||
myLight.enabled = true;
|
||||
yield return new WaitForSeconds(Random.Range(0.025f,0.035f));
|
||||
lineRend.material.SetFloat("_Brightness", 1f);
|
||||
planeMat.SetFloat("_Brightness", 1f);
|
||||
myLight.enabled = false;
|
||||
yield return new WaitForSeconds(Random.Range(0.025f,0.035f));
|
||||
lineRend.material.SetFloat("_Brightness", this.flashIntensity);
|
||||
planeMat.SetFloat("_Brightness", 20f);
|
||||
myLight.enabled = true;
|
||||
yield return new WaitForSeconds(Random.Range(0.025f,0.035f));
|
||||
lineRend.material.SetFloat("_Brightness", 1f);
|
||||
planeMat.SetFloat("_Brightness", 1f);
|
||||
myLight.enabled = false;
|
||||
yield return new WaitForSeconds(Random.Range(0.025f,0.035f));
|
||||
lineRend.material.SetFloat("_Brightness", this.flashIntensity);
|
||||
planeMat.SetFloat("_Brightness", 0f);
|
||||
myLight.enabled = true;
|
||||
yield return new WaitForSeconds(Random.Range(0.025f,0.035f));
|
||||
myLight.enabled = false;
|
||||
fadeTimer = 50f;
|
||||
fadeOut = true;
|
||||
}
|
||||
|
||||
IEnumerator CreateSplit(Vector3 pos, Vector3 targetP)
|
||||
{
|
||||
splitCount++;
|
||||
GameObject split = new GameObject();
|
||||
split.transform.SetParent(transform);
|
||||
split.transform.position = pos;
|
||||
LineRenderer splitRenderer = split.AddComponent<LineRenderer>();
|
||||
splitRenderer.material = lineRend.material;
|
||||
splitRenderer.material.SetFloat("_Brightness", flashIntensity * 0.9f);
|
||||
splitRenderer.positionCount = 2;
|
||||
splitRenderer.SetPosition(0, split.transform.position);
|
||||
splitRenderer.SetPosition(1, split.transform.position);
|
||||
|
||||
//Set a random target
|
||||
toTarget = targetP - pos;
|
||||
toTarget = Vector3.Normalize(toTarget);
|
||||
Vector3 posDown = new Vector3(toTarget.x,toTarget.y, toTarget.z * 0.1f);
|
||||
Vector3 targetPos = (Random.insideUnitSphere * 500 + pos + toTarget * 800);
|
||||
|
||||
Vector3 lastPoint = split.transform.position;
|
||||
float dist = Vector3.Distance(split.transform.position, targetPos);
|
||||
|
||||
float arcDist = dist / 32;
|
||||
|
||||
for (int i = 1; i < 16; i++)
|
||||
{
|
||||
splitRenderer.positionCount = i + 1;
|
||||
Vector3 fwd = targetPos - lastPoint;
|
||||
fwd.Normalize ();
|
||||
Vector3 newPos = Randomize (fwd, inaccuracy);
|
||||
|
||||
newPos *= Random.Range (splitLength * splitVariation, splitLength) * (arcDist);
|
||||
newPos += lastPoint;
|
||||
splitRenderer.SetPosition (i, newPos);
|
||||
lastPoint = newPos;
|
||||
yield return new WaitForSeconds(Random.Range(0.004f,0.006f));
|
||||
}
|
||||
splitRenderer.SetPosition(7,targetPos);
|
||||
yield return new WaitForSeconds(Random.Range(0.2f,0.5f));
|
||||
DestroyImmediate(split);
|
||||
}
|
||||
|
||||
public void CastBolt()
|
||||
{
|
||||
lineRend.positionCount = 1;
|
||||
StartCoroutine(CreateLightningBolt());
|
||||
}
|
||||
private Vector3 Randomize (Vector3 newVector, float devation) {
|
||||
newVector += new Vector3(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f)) * devation;
|
||||
newVector.Normalize();
|
||||
return newVector;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(fadeOut == true)
|
||||
{
|
||||
fadeTimer = Mathf.Lerp(fadeTimer,0f,10f * Time.deltaTime);
|
||||
lineRend.material.SetFloat("_Brightness", fadeTimer);
|
||||
|
||||
if(fadeTimer <= 1f)
|
||||
{
|
||||
lineRend.positionCount = 1;
|
||||
fadeOut = false;
|
||||
DestroyImmediate(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07501689299c0de43b5f4c0e6edd5bbd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Lightning/Lightning.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 569473d5f2a90ed4194c55a1ec36cd93
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 258de2724c9dfb643a546d0688715ff1, type: 3}
|
||||
m_Name: Default Lightning Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 0
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
prefab: {fileID: 8233971941884837668, guid: 3686e34c2aa90c44e8eab718f3bf99b6, type: 3}
|
||||
customLightningEffect: {fileID: 0}
|
||||
lightningStorm: 0
|
||||
randomLightingDelay: 1
|
||||
randomSpawnRange: 5000
|
||||
randomTargetRange: 5000
|
||||
cloudsLightningRadius: 2000
|
||||
cloudsLightningDuration: 0.5
|
||||
preset: {fileID: 0}
|
||||
showLightningControls: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9a0f93373ad7014fbe96d77c75cbe4e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Lightning/Preset/Default
|
||||
Lightning Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 991b756a2cc2fbd47b2216455c853139
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,101 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroSkyQualitySettings
|
||||
{
|
||||
public EnviroSky.SkyMode skyMode = EnviroSky.SkyMode.Normal;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroVolumetricCloudsQualitySettings
|
||||
{
|
||||
public bool volumetricClouds = true;
|
||||
public bool lightningSupport = true;
|
||||
public bool variableBottomNoise = false;
|
||||
|
||||
public int downsampling = 4;
|
||||
public int stepsLayer1 = 128;
|
||||
public float blueNoiseIntensity = 1f;
|
||||
public float reprojectionBlendTime = 10f;
|
||||
public float lodDistance = 0.25f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroFlatCloudsQualitySettings
|
||||
{
|
||||
public bool cirrusClouds = true;
|
||||
public bool flatClouds = true;
|
||||
public int flatCloudsShadowSteps = 8;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroAuroraQualitySettings
|
||||
{
|
||||
public bool aurora = true;
|
||||
[Range(6,32)]
|
||||
public int steps = 32;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroEffectsQualitySettings
|
||||
{
|
||||
[Range(0f,2f)]
|
||||
public float particeEmissionRateModifier = 1f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroFogQualitySettings
|
||||
{
|
||||
public bool fog = true;
|
||||
public EnviroFogSettings.FogQualityMode fogQualityMode = EnviroFogSettings.FogQualityMode.Normal;
|
||||
public bool volumetrics = true;
|
||||
public bool unityFog = false;
|
||||
public EnviroFogSettings.Quality quality;
|
||||
[Range(16,96)]
|
||||
public int steps = 32;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroQuality : ScriptableObject
|
||||
{
|
||||
//Inspector
|
||||
public bool showEditor, showSky, showVolumeClouds, showFog, showFlatClouds, showEffects, showAurora;
|
||||
public EnviroSkyQualitySettings skyOverride;
|
||||
public EnviroVolumetricCloudsQualitySettings volumetricCloudsOverride;
|
||||
public EnviroFogQualitySettings fogOverride;
|
||||
public EnviroFlatCloudsQualitySettings flatCloudsOverride;
|
||||
public EnviroAuroraQualitySettings auroraOverride;
|
||||
public EnviroEffectsQualitySettings effectsOverride;
|
||||
}
|
||||
|
||||
|
||||
public class EnviroQualityCreation
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.MenuItem("Assets/Create/Enviro3/Quality")]
|
||||
#endif
|
||||
public static EnviroQuality CreateMyAsset()
|
||||
{
|
||||
EnviroQuality wpreset = ScriptableObject.CreateInstance<EnviroQuality>();
|
||||
#if UNITY_EDITOR
|
||||
// Create and save the new profile with unique name
|
||||
string path = UnityEditor.AssetDatabase.GetAssetPath (UnityEditor.Selection.activeObject);
|
||||
if (path == "")
|
||||
{
|
||||
path = EnviroHelper.assetPath;
|
||||
}
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath (path + "/New " + "Quality" + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset (wpreset, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets ();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
return wpreset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfcd10a1b99270a488a19072f6176530
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Quality/EnviroQuality.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,160 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroQualities
|
||||
{
|
||||
public EnviroQuality defaultQuality;
|
||||
public List<EnviroQuality> Qualities = new List<EnviroQuality>();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnviroQualityModule : EnviroModule
|
||||
{
|
||||
public EnviroQualities Settings = new EnviroQualities();
|
||||
public EnviroQualityModule preset;
|
||||
public bool showQualityControls;
|
||||
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
base.Enable();
|
||||
|
||||
//Make sure that we always have at least one quality profile!
|
||||
if(Settings.defaultQuality == null)
|
||||
{
|
||||
if(Settings.Qualities.Count > 0)
|
||||
{
|
||||
Settings.defaultQuality = Settings.Qualities[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateNewQuality();
|
||||
Settings.defaultQuality = Settings.Qualities[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(Settings.defaultQuality != null)
|
||||
{
|
||||
if(EnviroManager.instance.Sky != null)
|
||||
{
|
||||
EnviroManager.instance.Sky.Settings.skyMode = Settings.defaultQuality.skyOverride.skyMode;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.VolumetricClouds != null)
|
||||
{
|
||||
EnviroManager.instance.VolumetricClouds.settingsQuality.volumetricClouds = Settings.defaultQuality.volumetricCloudsOverride.volumetricClouds;
|
||||
EnviroManager.instance.VolumetricClouds.settingsQuality.lightningSupport = Settings.defaultQuality.volumetricCloudsOverride.lightningSupport;
|
||||
EnviroManager.instance.VolumetricClouds.settingsQuality.variableBottomNoise = Settings.defaultQuality.volumetricCloudsOverride.variableBottomNoise;
|
||||
EnviroManager.instance.VolumetricClouds.settingsQuality.downsampling = Settings.defaultQuality.volumetricCloudsOverride.downsampling;
|
||||
EnviroManager.instance.VolumetricClouds.settingsQuality.stepsLayer1 = Settings.defaultQuality.volumetricCloudsOverride.stepsLayer1;
|
||||
EnviroManager.instance.VolumetricClouds.settingsQuality.blueNoiseIntensity = Settings.defaultQuality.volumetricCloudsOverride.blueNoiseIntensity;
|
||||
EnviroManager.instance.VolumetricClouds.settingsQuality.reprojectionBlendTime = Settings.defaultQuality.volumetricCloudsOverride.reprojectionBlendTime;
|
||||
EnviroManager.instance.VolumetricClouds.settingsQuality.lodDistance = Settings.defaultQuality.volumetricCloudsOverride.lodDistance;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Fog != null)
|
||||
{
|
||||
EnviroManager.instance.Fog.Settings.fog = Settings.defaultQuality.fogOverride.fog;
|
||||
EnviroManager.instance.Fog.Settings.fogQualityMode = Settings.defaultQuality.fogOverride.fogQualityMode;
|
||||
EnviroManager.instance.Fog.Settings.volumetrics = Settings.defaultQuality.fogOverride.volumetrics;
|
||||
EnviroManager.instance.Fog.Settings.unityFog = Settings.defaultQuality.fogOverride.unityFog;
|
||||
EnviroManager.instance.Fog.Settings.quality = Settings.defaultQuality.fogOverride.quality;
|
||||
EnviroManager.instance.Fog.Settings.steps = Settings.defaultQuality.fogOverride.steps;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.FlatClouds != null)
|
||||
{
|
||||
EnviroManager.instance.FlatClouds.settings.useFlatClouds = Settings.defaultQuality.flatCloudsOverride.flatClouds;
|
||||
EnviroManager.instance.FlatClouds.settings.useCirrusClouds = Settings.defaultQuality.flatCloudsOverride.cirrusClouds;
|
||||
EnviroManager.instance.FlatClouds.settings.flatCloudsShadowSteps = Settings.defaultQuality.flatCloudsOverride.flatCloudsShadowSteps;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Aurora != null)
|
||||
{
|
||||
EnviroManager.instance.Aurora.Settings.useAurora = Settings.defaultQuality.auroraOverride.aurora;
|
||||
EnviroManager.instance.Aurora.Settings.auroraSteps = Settings.defaultQuality.auroraOverride.steps;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Effects != null)
|
||||
{
|
||||
EnviroManager.instance.Effects.Settings.particeEmissionRateModifier = Settings.defaultQuality.effectsOverride.particeEmissionRateModifier;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void CleanupQualityList()
|
||||
{
|
||||
for (int i = 0; i < Settings.Qualities.Count; i++)
|
||||
{
|
||||
if(Settings.Qualities[i] == null)
|
||||
Settings.Qualities.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
//Add new or assigned quality
|
||||
public void CreateNewQuality()
|
||||
{
|
||||
EnviroQuality quality = EnviroQualityCreation.CreateMyAsset();
|
||||
Settings.Qualities.Add(quality);
|
||||
}
|
||||
|
||||
/// Removes the quality from the list.
|
||||
public void RemoveQuality(EnviroQuality quality)
|
||||
{
|
||||
Settings.Qualities.Remove(quality);
|
||||
}
|
||||
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroQualities>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroQualityModule t = ScriptableObject.CreateInstance<EnviroQualityModule>();
|
||||
t.name = "Quality Module Preset";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroQualities>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
public void SaveModuleValues (EnviroQualityModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroQualities>(JsonUtility.ToJson(Settings));
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 456bf221b186fde4096dcf2c1841b35a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Quality/EnviroQualityModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0fd49af59609e246bc7e5be19f334f3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 456bf221b186fde4096dcf2c1841b35a, type: 3}
|
||||
m_Name: Default Quality Module Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 0
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
defaultQuality: {fileID: 11400000, guid: 60e887b1524da0a4a8f1318ef102e22a, type: 2}
|
||||
Qualities:
|
||||
- {fileID: 11400000, guid: a002704085c17f1439758fcee25df529, type: 2}
|
||||
- {fileID: 11400000, guid: 2e0aaa075bca92245a9e8300b7eace9c, type: 2}
|
||||
- {fileID: 11400000, guid: 60e887b1524da0a4a8f1318ef102e22a, type: 2}
|
||||
- {fileID: 11400000, guid: e653a1dee3c47bb42a13eba46069720c, type: 2}
|
||||
- {fileID: 11400000, guid: ce2712a713d73094fa9c2775886f182d, type: 2}
|
||||
preset: {fileID: 0}
|
||||
showQualityControls: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87fc95b058753524e807e3f229e77c2f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Quality/Preset/Default
|
||||
Quality Module Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f634272e68ed184c8abe120f7a02bbc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,672 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
#if ENVIRO_HDRP
|
||||
using UnityEngine.Rendering.HighDefinition;
|
||||
#endif
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[AddComponentMenu("Enviro 3/Reflection Probe")]
|
||||
[RequireComponent(typeof(ReflectionProbe)), ExecuteInEditMode]
|
||||
public class EnviroReflectionProbe : MonoBehaviour
|
||||
{
|
||||
#region Public Var
|
||||
#region Standalone Settings
|
||||
public bool standalone = false;
|
||||
public bool updateReflectionOnGameTime = true;
|
||||
public float reflectionsUpdateTreshhold = 0.025f;
|
||||
public bool useTimeSlicing = true;
|
||||
#endregion
|
||||
public Camera renderCam;
|
||||
[HideInInspector]
|
||||
public ReflectionProbe myProbe;
|
||||
public bool customRendering = false;
|
||||
|
||||
#if !ENVIRO_HDRP
|
||||
private EnviroRenderer enviroRenderer;
|
||||
#endif
|
||||
public bool useFog = false;
|
||||
#endregion
|
||||
|
||||
#region Private Var
|
||||
// Privates
|
||||
public Camera bakingCam;
|
||||
public int renderId = -1;
|
||||
private bool currentMode = false;
|
||||
private int currentRes;
|
||||
private RenderTexture cubemap;
|
||||
private RenderTexture finalCubemap;
|
||||
private RenderTexture mirrorTexture;
|
||||
private RenderTexture renderTexture;
|
||||
private GameObject renderCamObj;
|
||||
private Material mirror = null;
|
||||
private Material bakeMat = null;
|
||||
private Material convolutionMat;
|
||||
private Coroutine refreshing;
|
||||
|
||||
private int renderID;
|
||||
|
||||
#if ENVIRO_HDRP
|
||||
public HDProbe hdprobe;
|
||||
#endif
|
||||
private static Quaternion[] orientations = new Quaternion[]
|
||||
{
|
||||
Quaternion.LookRotation(Vector3.right, Vector3.down),
|
||||
Quaternion.LookRotation(Vector3.left, Vector3.down),
|
||||
Quaternion.LookRotation(Vector3.up, Vector3.forward),
|
||||
Quaternion.LookRotation(Vector3.down, Vector3.back),
|
||||
Quaternion.LookRotation(Vector3.forward, Vector3.down),
|
||||
Quaternion.LookRotation(Vector3.back, Vector3.down)
|
||||
};
|
||||
|
||||
private double lastRelfectionUpdate;
|
||||
#endregion
|
||||
////////
|
||||
void OnEnable()
|
||||
{
|
||||
myProbe = GetComponent<ReflectionProbe>();
|
||||
|
||||
#if ENVIRO_HDRP
|
||||
if (EnviroManager.instance != null)
|
||||
{
|
||||
hdprobe = GetComponent<HDProbe>();
|
||||
|
||||
if(!standalone && myProbe != null)
|
||||
myProbe.enabled = true;
|
||||
|
||||
if (customRendering)
|
||||
{
|
||||
if (hdprobe != null)
|
||||
{
|
||||
hdprobe.mode = ProbeSettings.Mode.Custom;
|
||||
CreateCubemap();
|
||||
CreateTexturesAndMaterial();
|
||||
CreateRenderCamera();
|
||||
currentRes = myProbe.resolution;
|
||||
StartCoroutine(RefreshFirstTime());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hdprobe != null)
|
||||
{
|
||||
hdprobe.mode = ProbeSettings.Mode.Realtime;
|
||||
hdprobe.realtimeMode = ProbeSettings.RealtimeMode.OnDemand;
|
||||
hdprobe.RequestRenderNextUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
if (!standalone && myProbe != null)
|
||||
myProbe.enabled = true;
|
||||
|
||||
|
||||
if (customRendering)
|
||||
{
|
||||
myProbe.mode = ReflectionProbeMode.Custom;
|
||||
myProbe.refreshMode = ReflectionProbeRefreshMode.ViaScripting;
|
||||
CreateCubemap();
|
||||
CreateTexturesAndMaterial();
|
||||
CreateRenderCamera();
|
||||
currentRes = myProbe.resolution;
|
||||
StartCoroutine(RefreshFirstTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
myProbe.mode = ReflectionProbeMode.Realtime;
|
||||
myProbe.refreshMode = ReflectionProbeRefreshMode.ViaScripting;
|
||||
//StartCoroutine(RefreshUnity());
|
||||
renderId = myProbe.RenderProbe();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
Cleanup();
|
||||
|
||||
if (!standalone && myProbe != null)
|
||||
myProbe.enabled = false;
|
||||
|
||||
RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Skybox;
|
||||
}
|
||||
private void Cleanup()
|
||||
{
|
||||
if (refreshing != null)
|
||||
StopCoroutine(refreshing);
|
||||
|
||||
if (cubemap != null)
|
||||
{
|
||||
if (renderCam != null)
|
||||
renderCam.targetTexture = null;
|
||||
|
||||
DestroyImmediate(cubemap);
|
||||
}
|
||||
|
||||
if (renderCamObj != null)
|
||||
DestroyImmediate(renderCamObj);
|
||||
|
||||
if (mirrorTexture != null)
|
||||
DestroyImmediate(mirrorTexture);
|
||||
|
||||
if (renderTexture != null)
|
||||
DestroyImmediate(renderTexture);
|
||||
}
|
||||
// Creation
|
||||
private void CreateRenderCamera()
|
||||
{
|
||||
if (renderCamObj == null)
|
||||
{
|
||||
renderCamObj = new GameObject();
|
||||
renderCamObj.name = "Reflection Probe Cam";
|
||||
renderCamObj.hideFlags = HideFlags.HideAndDontSave;
|
||||
renderCam = renderCamObj.AddComponent<Camera>();
|
||||
renderCam.gameObject.SetActive(true);
|
||||
renderCam.cameraType = CameraType.Reflection;
|
||||
renderCam.fieldOfView = 90;
|
||||
renderCam.farClipPlane = myProbe.farClipPlane;
|
||||
renderCam.nearClipPlane = myProbe.nearClipPlane;
|
||||
renderCam.clearFlags = (CameraClearFlags)myProbe.clearFlags;
|
||||
renderCam.backgroundColor = myProbe.backgroundColor;
|
||||
renderCam.allowHDR = myProbe.hdr;
|
||||
renderCam.targetTexture = cubemap;
|
||||
renderCam.enabled = false;
|
||||
|
||||
#if VEGETATION_STUDIO_PRO
|
||||
// VegetationStudioManager.Instance.AddCamera(renderCam);
|
||||
#endif
|
||||
|
||||
#if !ENVIRO_HDRP
|
||||
if (EnviroManager.instance != null)
|
||||
{
|
||||
enviroRenderer = renderCamObj.AddComponent<EnviroRenderer>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
private void UpdateCameraSettings()
|
||||
{
|
||||
if (renderCam != null)
|
||||
{
|
||||
renderCam.cullingMask = myProbe.cullingMask;
|
||||
#if !ENVIRO_HDRP
|
||||
if (EnviroManager.instance != null)
|
||||
{
|
||||
//Update Quality
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
private Camera CreateBakingCamera()
|
||||
{
|
||||
GameObject tempCam = new GameObject();
|
||||
tempCam.name = "Reflection Probe Cam";
|
||||
Camera cam = tempCam.AddComponent<Camera>();
|
||||
cam.enabled = false;
|
||||
cam.gameObject.SetActive(true);
|
||||
cam.cameraType = CameraType.Reflection;
|
||||
cam.fieldOfView = 90;
|
||||
cam.farClipPlane = myProbe.farClipPlane;
|
||||
cam.nearClipPlane = myProbe.nearClipPlane;
|
||||
cam.cullingMask = myProbe.cullingMask;
|
||||
cam.clearFlags = (CameraClearFlags)myProbe.clearFlags;
|
||||
cam.backgroundColor = myProbe.backgroundColor;
|
||||
cam.allowHDR = myProbe.hdr;
|
||||
cam.targetTexture = cubemap;
|
||||
#if !ENVIRO_HDRP
|
||||
if (EnviroManager.instance != null)
|
||||
{
|
||||
enviroRenderer = renderCamObj.AddComponent<EnviroRenderer>();
|
||||
}
|
||||
#endif
|
||||
tempCam.hideFlags = HideFlags.HideAndDontSave;
|
||||
return cam;
|
||||
}
|
||||
private void CreateCubemap()
|
||||
{
|
||||
if (cubemap != null && myProbe.resolution == currentRes)
|
||||
return;
|
||||
|
||||
if (cubemap != null)
|
||||
{
|
||||
cubemap.Release();
|
||||
DestroyImmediate(cubemap);
|
||||
}
|
||||
|
||||
if (finalCubemap != null)
|
||||
{
|
||||
finalCubemap.Release();
|
||||
DestroyImmediate(finalCubemap);
|
||||
}
|
||||
|
||||
|
||||
int resolution = myProbe.resolution;
|
||||
|
||||
currentRes = resolution;
|
||||
RenderTextureFormat format = myProbe.hdr ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32;
|
||||
|
||||
cubemap = new RenderTexture(resolution, resolution, 16, format, RenderTextureReadWrite.Linear);
|
||||
cubemap.dimension = TextureDimension.Cube;
|
||||
cubemap.useMipMap = true;
|
||||
cubemap.autoGenerateMips = false;
|
||||
cubemap.name = "Enviro Reflection Temp Cubemap";
|
||||
cubemap.filterMode = FilterMode.Trilinear;
|
||||
cubemap.Create();
|
||||
|
||||
finalCubemap = new RenderTexture(resolution, resolution, 16, format, RenderTextureReadWrite.Linear);
|
||||
finalCubemap.dimension = TextureDimension.Cube;
|
||||
finalCubemap.useMipMap = true;
|
||||
finalCubemap.autoGenerateMips = false;
|
||||
finalCubemap.name = "Enviro Reflection Final Cubemap";
|
||||
finalCubemap.filterMode = FilterMode.Trilinear;
|
||||
finalCubemap.Create();
|
||||
}
|
||||
//Create the textures
|
||||
private void CreateTexturesAndMaterial()
|
||||
{
|
||||
if (mirror == null)
|
||||
mirror = new Material(Shader.Find("Hidden/Enviro/ReflectionProbe"));
|
||||
|
||||
if (convolutionMat == null)
|
||||
convolutionMat = new Material(Shader.Find("Hidden/EnviroCubemapBlur"));
|
||||
|
||||
int resolution = myProbe.resolution;
|
||||
|
||||
RenderTextureFormat format = myProbe.hdr ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32;
|
||||
|
||||
if (mirrorTexture == null || mirrorTexture.width != resolution || mirrorTexture.height != resolution)
|
||||
{
|
||||
if (mirrorTexture != null)
|
||||
DestroyImmediate(mirrorTexture);
|
||||
|
||||
mirrorTexture = new RenderTexture(resolution, resolution, 16, format, RenderTextureReadWrite.Linear);
|
||||
mirrorTexture.useMipMap = true;
|
||||
mirrorTexture.autoGenerateMips = false;
|
||||
mirrorTexture.name = "Enviro Reflection Mirror Texture";
|
||||
mirrorTexture.Create();
|
||||
}
|
||||
|
||||
if (renderTexture == null || renderTexture.width != resolution || renderTexture.height != resolution)
|
||||
{
|
||||
if (renderTexture != null)
|
||||
DestroyImmediate(renderTexture);
|
||||
|
||||
renderTexture = new RenderTexture(resolution, resolution, 16, format, RenderTextureReadWrite.Linear);
|
||||
renderTexture.useMipMap = true;
|
||||
renderTexture.autoGenerateMips = false;
|
||||
renderTexture.name = "Enviro Reflection Target Texture";
|
||||
renderTexture.Create();
|
||||
}
|
||||
}
|
||||
// Refresh Methods
|
||||
public void RefreshReflection(bool timeSlice = false)
|
||||
{
|
||||
#if ENVIRO_HDRP
|
||||
if (customRendering)
|
||||
{
|
||||
if (refreshing != null)
|
||||
return;
|
||||
|
||||
CreateTexturesAndMaterial();
|
||||
|
||||
if (renderCam == null)
|
||||
CreateRenderCamera();
|
||||
|
||||
UpdateCameraSettings();
|
||||
|
||||
renderCam.transform.position = transform.position;
|
||||
renderCam.targetTexture = renderTexture;
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
if (!timeSlice)
|
||||
refreshing = StartCoroutine(RefreshInstant(renderTexture, mirrorTexture));
|
||||
else
|
||||
refreshing = StartCoroutine(RefreshOvertime(renderTexture, mirrorTexture));
|
||||
}
|
||||
else
|
||||
{
|
||||
refreshing = StartCoroutine(RefreshInstant(renderTexture, mirrorTexture));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(hdprobe != null)
|
||||
hdprobe.RequestRenderNextUpdate();
|
||||
}
|
||||
#else
|
||||
if (customRendering)
|
||||
{
|
||||
if (refreshing != null)
|
||||
return;
|
||||
|
||||
CreateTexturesAndMaterial();
|
||||
|
||||
if (renderCam == null)
|
||||
CreateRenderCamera();
|
||||
|
||||
UpdateCameraSettings();
|
||||
|
||||
renderCam.transform.position = transform.position;
|
||||
renderCam.targetTexture = renderTexture;
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
if (!timeSlice)
|
||||
refreshing = StartCoroutine(RefreshInstant(renderTexture, mirrorTexture));
|
||||
else
|
||||
refreshing = StartCoroutine(RefreshOvertime(renderTexture, mirrorTexture));
|
||||
}
|
||||
else
|
||||
{
|
||||
refreshing = StartCoroutine(RefreshInstant(renderTexture, mirrorTexture));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderId = myProbe.RenderProbe();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
IEnumerator RefreshFirstTime()
|
||||
{
|
||||
yield return null;
|
||||
RefreshReflection(false);
|
||||
RefreshReflection(false);
|
||||
}
|
||||
|
||||
|
||||
public IEnumerator RefreshUnity()
|
||||
{
|
||||
yield return null;
|
||||
renderId = myProbe.RenderProbe();
|
||||
}
|
||||
|
||||
|
||||
public IEnumerator RefreshInstant(RenderTexture renderTex, RenderTexture mirrorTex)
|
||||
{
|
||||
CreateCubemap();
|
||||
|
||||
yield return null;
|
||||
|
||||
for (int face = 0; face < 6; face++)
|
||||
{
|
||||
renderCam.transform.rotation = orientations[face];
|
||||
renderCam.Render();
|
||||
|
||||
if(mirrorTex != null)
|
||||
{
|
||||
Graphics.Blit(renderTex, mirrorTex, mirror);
|
||||
Graphics.CopyTexture(mirrorTex, 0, 0, cubemap, face, 0);
|
||||
}
|
||||
}
|
||||
|
||||
ConvolutionCubemap();
|
||||
#if ENVIRO_HDRP
|
||||
if (hdprobe != null)
|
||||
hdprobe.SetTexture(ProbeSettings.Mode.Custom, finalCubemap);
|
||||
#else
|
||||
myProbe.customBakedTexture = finalCubemap;
|
||||
#endif
|
||||
refreshing = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Reflections with Time Slicing
|
||||
/// </summary>
|
||||
public IEnumerator RefreshOvertime(RenderTexture renderTex, RenderTexture mirrorTex)
|
||||
{
|
||||
CreateCubemap();
|
||||
|
||||
for (int face = 0; face < 6; face++)
|
||||
{
|
||||
yield return null;
|
||||
renderCam.transform.rotation = orientations[face];
|
||||
renderCam.Render();
|
||||
|
||||
if(mirrorTex != null)
|
||||
{
|
||||
Graphics.Blit(renderTex, mirrorTex, mirror);
|
||||
Graphics.CopyTexture(mirrorTex, 0, 0, cubemap, face, 0);
|
||||
}
|
||||
//ClearTextures();
|
||||
}
|
||||
|
||||
ConvolutionCubemap();
|
||||
#if ENVIRO_HDRP
|
||||
if (hdprobe != null)
|
||||
hdprobe.SetTexture(ProbeSettings.Mode.Custom, finalCubemap);
|
||||
#else
|
||||
myProbe.customBakedTexture = finalCubemap;
|
||||
#endif
|
||||
refreshing = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bakes one face per time into a render texture
|
||||
/// </summary>
|
||||
/// <param name="face"></param>
|
||||
/// <param name="res"></param>
|
||||
/// <returns></returns>
|
||||
public RenderTexture BakeCubemapFace(int face, int res)
|
||||
{
|
||||
if (bakeMat == null)
|
||||
bakeMat = new Material(Shader.Find("Hidden/Enviro/BakeCubemap"));
|
||||
|
||||
if (bakingCam == null)
|
||||
bakingCam = CreateBakingCamera();
|
||||
|
||||
bakingCam.transform.rotation = orientations[face];
|
||||
RenderTexture temp = RenderTexture.GetTemporary(res, res, 0, RenderTextureFormat.ARGBFloat);
|
||||
bakingCam.targetTexture = temp;
|
||||
bakingCam.Render();
|
||||
RenderTexture tex = new RenderTexture(res, res, 0, RenderTextureFormat.ARGBFloat);
|
||||
Graphics.Blit(temp, tex, bakeMat);
|
||||
RenderTexture.ReleaseTemporary(temp);
|
||||
return tex;
|
||||
}
|
||||
|
||||
private void ClearTextures()
|
||||
{
|
||||
RenderTexture rt = RenderTexture.active;
|
||||
RenderTexture.active = renderTexture;
|
||||
GL.Clear(true, true, Color.clear);
|
||||
RenderTexture.active = mirrorTexture;
|
||||
GL.Clear(true, true, Color.clear);
|
||||
RenderTexture.active = rt;
|
||||
}
|
||||
|
||||
|
||||
//This is not a proper convolution and very hacky to get anywhere near of unity realtime reflection probe mip convolution.
|
||||
private void ConvolutionCubemap()
|
||||
{
|
||||
int mipCount = 7;
|
||||
|
||||
GL.PushMatrix();
|
||||
GL.LoadOrtho();
|
||||
|
||||
cubemap.GenerateMips();
|
||||
|
||||
float texel = 1f;
|
||||
switch(finalCubemap.width)
|
||||
{
|
||||
|
||||
case 16:
|
||||
texel = 1f;
|
||||
break;
|
||||
|
||||
case 32:
|
||||
texel = 1f;
|
||||
break;
|
||||
|
||||
case 64:
|
||||
texel = 2f;
|
||||
break;
|
||||
|
||||
case 128:
|
||||
texel = 4f;
|
||||
break;
|
||||
|
||||
case 256:
|
||||
texel = 8f;
|
||||
break;
|
||||
|
||||
case 512:
|
||||
texel = 14f;
|
||||
break;
|
||||
|
||||
case 1024:
|
||||
texel = 30f;
|
||||
break;
|
||||
|
||||
case 2048:
|
||||
texel = 60f;
|
||||
break;
|
||||
}
|
||||
|
||||
float res = finalCubemap.width;
|
||||
|
||||
for (int mip = 0; mip < mipCount + 1; mip++)
|
||||
{
|
||||
//Copy each face
|
||||
Graphics.CopyTexture(cubemap, 0, mip, finalCubemap, 0, mip);
|
||||
Graphics.CopyTexture(cubemap, 1, mip, finalCubemap, 1, mip);
|
||||
Graphics.CopyTexture(cubemap, 2, mip, finalCubemap, 2, mip);
|
||||
Graphics.CopyTexture(cubemap, 3, mip, finalCubemap, 3, mip);
|
||||
Graphics.CopyTexture(cubemap, 4, mip, finalCubemap, 4, mip);
|
||||
Graphics.CopyTexture(cubemap, 5, mip, finalCubemap, 5, mip);
|
||||
|
||||
int dstMip = mip + 1;
|
||||
|
||||
if (dstMip == mipCount)
|
||||
break;
|
||||
|
||||
float texelSize = (texel * dstMip) / res;
|
||||
|
||||
convolutionMat.SetTexture("_MainTex", finalCubemap);
|
||||
convolutionMat.SetFloat("_Texel", texelSize);
|
||||
convolutionMat.SetFloat("_Level", mip);
|
||||
convolutionMat.SetPass(0);
|
||||
|
||||
res *= 0.75f;
|
||||
|
||||
// Positive X
|
||||
Graphics.SetRenderTarget(cubemap, dstMip, CubemapFace.PositiveX);
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.TexCoord3(1, 1, 1);
|
||||
GL.Vertex3(0, 0, 1);
|
||||
GL.TexCoord3(1, -1, 1);
|
||||
GL.Vertex3(0, 1, 1);
|
||||
GL.TexCoord3(1, -1, -1);
|
||||
GL.Vertex3(1, 1, 1);
|
||||
GL.TexCoord3(1, 1, -1);
|
||||
GL.Vertex3(1, 0, 1);
|
||||
GL.End();
|
||||
|
||||
// Negative X
|
||||
Graphics.SetRenderTarget(cubemap, dstMip, CubemapFace.NegativeX);
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.TexCoord3(-1, 1, -1);
|
||||
GL.Vertex3(0, 0, 1);
|
||||
GL.TexCoord3(-1, -1, -1);
|
||||
GL.Vertex3(0, 1, 1);
|
||||
GL.TexCoord3(-1, -1, 1);
|
||||
GL.Vertex3(1, 1, 1);
|
||||
GL.TexCoord3(-1, 1, 1);
|
||||
GL.Vertex3(1, 0, 1);
|
||||
GL.End();
|
||||
|
||||
// Positive Y
|
||||
Graphics.SetRenderTarget(cubemap, dstMip, CubemapFace.PositiveY);
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.TexCoord3(-1, 1, -1);
|
||||
GL.Vertex3(0, 0, 1);
|
||||
GL.TexCoord3(-1, 1, 1);
|
||||
GL.Vertex3(0, 1, 1);
|
||||
GL.TexCoord3(1, 1, 1);
|
||||
GL.Vertex3(1, 1, 1);
|
||||
GL.TexCoord3(1, 1, -1);
|
||||
GL.Vertex3(1, 0, 1);
|
||||
GL.End();
|
||||
|
||||
// Negative Y
|
||||
Graphics.SetRenderTarget(cubemap, dstMip, CubemapFace.NegativeY);
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.TexCoord3(-1, -1, 1);
|
||||
GL.Vertex3(0, 0, 1);
|
||||
GL.TexCoord3(-1, -1, -1);
|
||||
GL.Vertex3(0, 1, 1);
|
||||
GL.TexCoord3(1, -1, -1);
|
||||
GL.Vertex3(1, 1, 1);
|
||||
GL.TexCoord3(1, -1, 1);
|
||||
GL.Vertex3(1, 0, 1);
|
||||
GL.End();
|
||||
|
||||
// Positive Z
|
||||
Graphics.SetRenderTarget(cubemap, dstMip, CubemapFace.PositiveZ);
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.TexCoord3(-1, 1, 1);
|
||||
GL.Vertex3(0, 0, 1);
|
||||
GL.TexCoord3(-1, -1, 1);
|
||||
GL.Vertex3(0, 1, 1);
|
||||
GL.TexCoord3(1, -1, 1);
|
||||
GL.Vertex3(1, 1, 1);
|
||||
GL.TexCoord3(1, 1, 1);
|
||||
GL.Vertex3(1, 0, 1);
|
||||
GL.End();
|
||||
|
||||
// Negative Z
|
||||
Graphics.SetRenderTarget(cubemap, dstMip, CubemapFace.NegativeZ);
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.TexCoord3(1, 1, -1);
|
||||
GL.Vertex3(0, 0, 1);
|
||||
GL.TexCoord3(1, -1, -1);
|
||||
GL.Vertex3(0, 1, 1);
|
||||
GL.TexCoord3(-1, -1, -1);
|
||||
GL.Vertex3(1, 1, 1);
|
||||
GL.TexCoord3(-1, 1, -1);
|
||||
GL.Vertex3(1, 0, 1);
|
||||
GL.End();
|
||||
}
|
||||
|
||||
GL.PopMatrix();
|
||||
|
||||
}
|
||||
private void UpdateStandaloneReflection()
|
||||
{
|
||||
if ((EnviroManager.instance.Time.GetDateInHours() > lastRelfectionUpdate + reflectionsUpdateTreshhold ||EnviroManager.instance.Time.GetDateInHours() < lastRelfectionUpdate - reflectionsUpdateTreshhold) && updateReflectionOnGameTime)
|
||||
{
|
||||
lastRelfectionUpdate = EnviroManager.instance.Time.GetDateInHours();
|
||||
RefreshReflection(!useTimeSlicing);
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (currentMode != customRendering)
|
||||
{
|
||||
currentMode = customRendering;
|
||||
|
||||
if (customRendering)
|
||||
{
|
||||
OnEnable();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnEnable();
|
||||
Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
if (EnviroManager.instance != null && standalone)
|
||||
{
|
||||
UpdateStandaloneReflection();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 766b1caed0279ea4281500fc502a2853
|
||||
timeCreated: 1558916543
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Reflections/EnviroReflectionProbe.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,407 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroReflections
|
||||
{
|
||||
public enum GlobalReflectionResolution
|
||||
{
|
||||
R16,
|
||||
R32,
|
||||
R64,
|
||||
R128,
|
||||
R256,
|
||||
R512,
|
||||
R1024,
|
||||
R2048
|
||||
}
|
||||
|
||||
public bool globalReflections = true;
|
||||
[Tooltip("Set if enviro reflection probe should use custom rendering setup. For example to include post effectsin birp.")]
|
||||
public bool customRendering = true;
|
||||
[Tooltip("Set to use custom timeslicing when rendered in custom mode.")]
|
||||
public bool customRenderingTimeSlicing = true;
|
||||
|
||||
[Tooltip("Set if enviro reflection probe should update faces individual on different frames.")]
|
||||
public ReflectionProbeTimeSlicingMode globalReflectionTimeSlicingMode = ReflectionProbeTimeSlicingMode.IndividualFaces;
|
||||
[Tooltip("Enable/disable enviro reflection probe updates based on gametime changes..")]
|
||||
public bool globalReflectionsUpdateOnGameTime = true;
|
||||
[Tooltip("Enable/disable enviro reflection probe updates based on transform position changes..")]
|
||||
public bool globalReflectionsUpdateOnPosition = true;
|
||||
[Tooltip("Reflection probe intensity.")]
|
||||
[Range(0f, 2f)]
|
||||
public float globalReflectionsIntensity = 1.0f;
|
||||
[Tooltip("Reflection probe update rate based on game time.")]
|
||||
public float globalReflectionsTimeTreshold = 0.025f;
|
||||
[Tooltip("Reflection probe update rate based on camera position.")]
|
||||
public float globalReflectionsPositionTreshold = 0.5f;
|
||||
[Tooltip("Reflection probe scale. Increase that one to increase the area where reflection probe will influence your scene.")]
|
||||
[Range(10f, 10000f)]
|
||||
public float globalReflectionsScale = 10000f;
|
||||
[Tooltip("Reflection probe resolution.")]
|
||||
public GlobalReflectionResolution globalReflectionResolution = GlobalReflectionResolution.R256;
|
||||
[Tooltip("Reflection probe rendered Layers.")]
|
||||
public LayerMask globalReflectionLayers;
|
||||
[Tooltip("Enable this option to update the default reflection with global reflection probes cubemap. This can be needed for material that might not support direct reflection probes. (Instanced Indirect Rendering)")]
|
||||
public bool updateDefaultEnvironmentReflections = true;
|
||||
[Tooltip("Reflection cubemap used for default scene sky reflections in < Unity 2022.1 versions.")]
|
||||
public Cubemap defaultSkyReflectionTex;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[ExecuteInEditMode]
|
||||
public class EnviroReflectionsModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroReflections Settings;
|
||||
public EnviroReflectionsModule preset;
|
||||
|
||||
// Inspector
|
||||
public bool showReflectionControls;
|
||||
|
||||
public float lastReflectionUpdate;
|
||||
public Vector3 lastReflectionUpdatePos;
|
||||
|
||||
private Coroutine renderReflectionCoroutine;
|
||||
private Coroutine waitForProbeCoroutine;
|
||||
private Coroutine copyDefaultReflectionCoroutine;
|
||||
|
||||
public override void Enable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
Setup();
|
||||
|
||||
// Update global reflections once on enable.
|
||||
if(EnviroManager.instance.Objects.globalReflectionProbe != null)
|
||||
EnviroManager.instance.StartCoroutine(WaitToRefreshReflection());
|
||||
}
|
||||
|
||||
public override void Disable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
private void Cleanup()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance.Objects.globalReflectionProbe != null)
|
||||
DestroyImmediate(EnviroManager.instance.Objects.globalReflectionProbe.gameObject);
|
||||
}
|
||||
|
||||
// Unity warns with "Attempting to update a disabled Reflection Probe" even though the probe is enabled.
|
||||
// We have to wait a frame before interacting with reflection probes to allow Unity time to do any
|
||||
// setup in its internal OnEnable(). Otherwise, we will receive a warning:
|
||||
// "Attempting to update a disabled Reflection Probe. Action will be ignored."
|
||||
private IEnumerator WaitToRefreshReflection()
|
||||
{
|
||||
yield return null;
|
||||
RenderGlobalReflectionProbe(true, false);
|
||||
UpdateDefaultReflectionTextureMode ();
|
||||
}
|
||||
|
||||
private void Setup()
|
||||
{
|
||||
if(EnviroManager.instance.Objects.globalReflectionProbe == null)
|
||||
{
|
||||
GameObject newReflectionProbe = new GameObject();
|
||||
newReflectionProbe.name = "Global Reflection Probe";
|
||||
newReflectionProbe.transform.SetParent(EnviroManager.instance.transform);
|
||||
newReflectionProbe.transform.localPosition = Vector3.zero;
|
||||
EnviroManager.instance.Objects.globalReflectionProbe = newReflectionProbe.AddComponent<EnviroReflectionProbe>();
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance.Objects.globalReflectionProbe != null)
|
||||
UpdateReflection();
|
||||
}
|
||||
|
||||
private void UpdateReflection()
|
||||
{
|
||||
if(!Settings.globalReflections)
|
||||
{
|
||||
EnviroManager.instance.Objects.globalReflectionProbe.myProbe.enabled = false;
|
||||
UpdateDefaultReflectionTextureMode ();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnviroManager.instance.Objects.globalReflectionProbe.myProbe.enabled = true;
|
||||
}
|
||||
|
||||
EnviroReflectionProbe probe = EnviroManager.instance.Objects.globalReflectionProbe;
|
||||
|
||||
SetupProbeSettings(probe);
|
||||
|
||||
if(EnviroManager.instance.Time != null)
|
||||
{
|
||||
if ((lastReflectionUpdate < EnviroManager.instance.Time.Settings.timeOfDay || lastReflectionUpdate > EnviroManager.instance.Time.Settings.timeOfDay + (Settings.globalReflectionsTimeTreshold + 0.01f)) && Settings.globalReflectionsUpdateOnGameTime)
|
||||
{
|
||||
RenderGlobalReflectionProbe(false,Settings.customRenderingTimeSlicing);
|
||||
lastReflectionUpdate = EnviroManager.instance.Time.Settings.timeOfDay + Settings.globalReflectionsTimeTreshold;
|
||||
}
|
||||
}
|
||||
|
||||
if ((probe.transform.position.magnitude > lastReflectionUpdatePos.magnitude + Settings.globalReflectionsPositionTreshold || probe.transform.position.magnitude < lastReflectionUpdatePos.magnitude - Settings.globalReflectionsPositionTreshold) && Settings.globalReflectionsUpdateOnPosition)
|
||||
{
|
||||
RenderGlobalReflectionProbe(false,Settings.customRenderingTimeSlicing);
|
||||
lastReflectionUpdatePos = probe.transform.position;
|
||||
}
|
||||
|
||||
UpdateDefaultReflectionTextureMode ();
|
||||
}
|
||||
|
||||
public void RenderGlobalReflectionProbe(bool forced = false, bool timeslice = false)
|
||||
{
|
||||
EnviroReflectionProbe probe = EnviroManager.instance.Objects.globalReflectionProbe;
|
||||
|
||||
if (probe == null)
|
||||
return;
|
||||
|
||||
if(renderReflectionCoroutine != null)
|
||||
{
|
||||
EnviroManager.instance.StopCoroutine(renderReflectionCoroutine);
|
||||
renderReflectionCoroutine = null;
|
||||
}
|
||||
|
||||
#if !ENVIRO_HDRP
|
||||
renderReflectionCoroutine = EnviroManager.instance.StartCoroutine(RenderGlobalReflectionProbeTimed(probe,timeslice));
|
||||
|
||||
if(Settings.updateDefaultEnvironmentReflections)
|
||||
{
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
// We don't need to copy the texture to a cubemap anmyore
|
||||
#else
|
||||
// Prevent multiple coroutines from running at the same time
|
||||
if (copyDefaultReflectionCoroutine != null)
|
||||
{
|
||||
EnviroManager.instance.StopCoroutine(copyDefaultReflectionCoroutine);
|
||||
copyDefaultReflectionCoroutine = null;
|
||||
}
|
||||
|
||||
if(Settings.customRendering)
|
||||
copyDefaultReflectionCoroutine = EnviroManager.instance.StartCoroutine(CopyDefaultReflectionCustom(probe, timeslice));
|
||||
else
|
||||
CopyDefaultReflectionUnity(probe);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
renderReflectionCoroutine = EnviroManager.instance.StartCoroutine(RenderGlobalReflectionProbeTimed(probe,timeslice));
|
||||
#endif
|
||||
}
|
||||
|
||||
//Copy reflection probe to cubemap and assign as default reflections.
|
||||
private void CopyDefaultReflectionCubemap (EnviroReflectionProbe probe)
|
||||
{
|
||||
if(Settings.defaultSkyReflectionTex == null || Settings.defaultSkyReflectionTex.height != probe.myProbe.texture.height || Settings.defaultSkyReflectionTex.width != probe.myProbe.texture.width)
|
||||
{
|
||||
if(Settings.defaultSkyReflectionTex != null)
|
||||
DestroyImmediate(Settings.defaultSkyReflectionTex);
|
||||
|
||||
Settings.defaultSkyReflectionTex = new Cubemap(probe.myProbe.resolution, probe.myProbe.hdr ? TextureFormat.RGBAHalf : TextureFormat.RGBA32, true);
|
||||
Settings.defaultSkyReflectionTex.name = "Enviro Default Sky Reflection";
|
||||
}
|
||||
|
||||
if(probe.myProbe.texture != null)
|
||||
Graphics.CopyTexture(probe.myProbe.texture, Settings.defaultSkyReflectionTex as Texture);
|
||||
}
|
||||
|
||||
public void UpdateDefaultReflectionTextureMode ()
|
||||
{
|
||||
if(Settings.updateDefaultEnvironmentReflections && Settings.globalReflections)
|
||||
{
|
||||
RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Custom;
|
||||
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
RenderSettings.customReflectionTexture = EnviroManager.instance.Objects.globalReflectionProbe.myProbe.texture;
|
||||
#else
|
||||
if(Settings.defaultSkyReflectionTex != null)
|
||||
RenderSettings.customReflection = Settings.defaultSkyReflectionTex;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Skybox;
|
||||
}
|
||||
}
|
||||
|
||||
//Update all probe settings.
|
||||
private void SetupProbeSettings(EnviroReflectionProbe probe)
|
||||
{
|
||||
int res = 128;
|
||||
|
||||
switch (Settings.globalReflectionResolution)
|
||||
{
|
||||
case EnviroReflections.GlobalReflectionResolution.R16:
|
||||
res = 16;
|
||||
break;
|
||||
case EnviroReflections.GlobalReflectionResolution.R32:
|
||||
res = 32;
|
||||
break;
|
||||
case EnviroReflections.GlobalReflectionResolution.R64:
|
||||
res = 64;
|
||||
break;
|
||||
case EnviroReflections.GlobalReflectionResolution.R128:
|
||||
res = 128;
|
||||
break;
|
||||
case EnviroReflections.GlobalReflectionResolution.R256:
|
||||
res = 256;
|
||||
break;
|
||||
case EnviroReflections.GlobalReflectionResolution.R512:
|
||||
res = 512;
|
||||
break;
|
||||
case EnviroReflections.GlobalReflectionResolution.R1024:
|
||||
res = 1024;
|
||||
break;
|
||||
case EnviroReflections.GlobalReflectionResolution.R2048:
|
||||
res = 2048;
|
||||
break;
|
||||
}
|
||||
#if !ENVIRO_HDRP
|
||||
probe.myProbe.cullingMask = Settings.globalReflectionLayers;
|
||||
probe.myProbe.intensity = Settings.globalReflectionsIntensity;
|
||||
probe.myProbe.size = new Vector3 (Settings.globalReflectionsScale,Settings.globalReflectionsScale,Settings.globalReflectionsScale);
|
||||
probe.myProbe.resolution = res;
|
||||
#if ENVIRO_URP
|
||||
probe.customRendering = false;
|
||||
probe.myProbe.timeSlicingMode = Settings.globalReflectionTimeSlicingMode;
|
||||
#else
|
||||
probe.customRendering = Settings.customRendering;
|
||||
probe.useTimeSlicing = Settings.customRenderingTimeSlicing;
|
||||
probe.myProbe.timeSlicingMode = Settings.globalReflectionTimeSlicingMode;
|
||||
#endif
|
||||
RenderSettings.reflectionIntensity = Settings.globalReflectionsIntensity;
|
||||
#else
|
||||
probe.customRendering = false;
|
||||
probe.myProbe.resolution = res;
|
||||
|
||||
if(probe.hdprobe != null)
|
||||
{
|
||||
probe.hdprobe.settingsRaw.cameraSettings.culling.cullingMask = Settings.globalReflectionLayers;
|
||||
probe.hdprobe.settingsRaw.influence.boxSize = new Vector3 (Settings.globalReflectionsScale,Settings.globalReflectionsScale,Settings.globalReflectionsScale);
|
||||
probe.hdprobe.settingsRaw.influence.sphereRadius = Settings.globalReflectionsScale;
|
||||
probe.hdprobe.settingsRaw.lighting.multiplier = Settings.globalReflectionsIntensity;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private IEnumerator CopyDefaultReflectionCustom(EnviroReflectionProbe probe, bool timeslice)
|
||||
{
|
||||
if (timeslice)
|
||||
{
|
||||
// Wait for seven frames so probe finished rendering
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
CopyDefaultReflectionCubemap(probe);
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return null;
|
||||
yield return null;
|
||||
CopyDefaultReflectionCubemap(probe);
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyDefaultReflectionUnity(EnviroReflectionProbe probe)
|
||||
{
|
||||
if(probe.renderId == -1 || probe.myProbe.IsFinishedRendering(probe.renderId))
|
||||
{
|
||||
CopyDefaultReflectionCubemap(probe);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (waitForProbeCoroutine != null) {
|
||||
EnviroManager.instance.StopCoroutine(waitForProbeCoroutine);
|
||||
waitForProbeCoroutine = null;
|
||||
}
|
||||
waitForProbeCoroutine = EnviroManager.instance.StartCoroutine(WaitForUnityProbe(probe));
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator WaitForUnityProbe(EnviroReflectionProbe probe)
|
||||
{
|
||||
yield return null;
|
||||
CopyDefaultReflectionUnity(probe);
|
||||
}
|
||||
|
||||
private IEnumerator RenderGlobalReflectionProbeTimed (EnviroReflectionProbe probe, bool timeslice)
|
||||
{
|
||||
#if ENVIRO_HDRP
|
||||
EnviroManager.instance.Lighting.UpdateDirectLightingHDRP ();
|
||||
EnviroManager.instance.Lighting.UpdateAmbientLightingHDRP();
|
||||
yield return null;
|
||||
probe.RefreshReflection(timeslice);
|
||||
yield return null;
|
||||
EnviroManager.instance.Lighting.UpdateExposureHDRP ();
|
||||
#else
|
||||
if(EnviroManager.instance.Lighting != null)
|
||||
{
|
||||
//Force a lighting update before rendering the probe as it might has not updated yet.
|
||||
EnviroManager.instance.Lighting.UpdateDirectLighting ();
|
||||
EnviroManager.instance.Lighting.UpdateAmbientLighting(true);
|
||||
yield return null;
|
||||
probe.RefreshReflection(timeslice);
|
||||
}
|
||||
else
|
||||
{
|
||||
probe.RefreshReflection(timeslice);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroReflections>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroReflectionsModule t = ScriptableObject.CreateInstance<EnviroReflectionsModule>();
|
||||
t.name = "Reflections Module";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroReflections>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SaveModuleValues (EnviroReflectionsModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroReflections>(JsonUtility.ToJson(Settings));
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 153c2e7862a6cc74c80438e6d8e45aab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Reflections/EnviroReflectionsModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c513eea06098c7547b1d35f1e90e9a2a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 153c2e7862a6cc74c80438e6d8e45aab, type: 3}
|
||||
m_Name: Default Reflections Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 0
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
globalReflections: 1
|
||||
customRendering: 1
|
||||
customRenderingTimeSlicing: 1
|
||||
globalReflectionTimeSlicingMode: 0
|
||||
globalReflectionsUpdateOnGameTime: 1
|
||||
globalReflectionsUpdateOnPosition: 0
|
||||
globalReflectionsIntensity: 1
|
||||
globalReflectionsTimeTreshold: 0.025
|
||||
globalReflectionsPositionTreshold: 0.5
|
||||
globalReflectionsScale: 10000
|
||||
globalReflectionResolution: 3
|
||||
globalReflectionLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
updateDefaultEnvironmentReflections: 1
|
||||
defaultSkyReflectionTex: {fileID: 0}
|
||||
preset: {fileID: 0}
|
||||
showReflectionControls: 0
|
||||
lastReflectionUpdate: 0
|
||||
lastReflectionUpdatePos: {x: 0, y: 0, z: 0}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da668770e38694d49af97ecfd05fd7eb
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Reflections/Presets/Default
|
||||
Reflections Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c668cb547e9cc02458eabb38fbe3fdab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
#if ENVIRO_HDRP
|
||||
using System;
|
||||
using UnityEngine.Rendering.HighDefinition;
|
||||
|
||||
namespace UnityEngine.Rendering.HighDefinition
|
||||
{
|
||||
[VolumeComponentMenu("Sky/Enviro 3 Skybox")]
|
||||
[SkyUniqueID(990)]
|
||||
public class EnviroHDRPSky : SkySettings
|
||||
{
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hash = base.GetHashCode();
|
||||
|
||||
unchecked
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
public override int GetHashCode(Camera camera)
|
||||
{
|
||||
// Implement if your sky depends on the camera settings (like position for instance)
|
||||
return GetHashCode();
|
||||
}
|
||||
|
||||
public override Type GetSkyRendererType() { return typeof(EnviroHDRPSkyRenderer); }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e23fe585513df7b448c20370fa8a8671
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Sky/EnviroHDRPSky.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,71 @@
|
||||
#if ENVIRO_HDRP
|
||||
using System.Collections;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace UnityEngine.Rendering.HighDefinition
|
||||
{
|
||||
class EnviroHDRPSkyRenderer : SkyRenderer
|
||||
{
|
||||
Material skyMat;
|
||||
MaterialPropertyBlock m_PropertyBlock = new MaterialPropertyBlock();
|
||||
|
||||
public EnviroHDRPSkyRenderer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void Build()
|
||||
{
|
||||
if(skyMat == null)
|
||||
skyMat = CoreUtils.CreateEngineMaterial(Shader.Find("Enviro/HDRP/Sky"));
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
{
|
||||
CoreUtils.Destroy(skyMat);
|
||||
}
|
||||
|
||||
protected override bool Update(BuiltinSkyParameters builtinParams)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk)
|
||||
{
|
||||
if (Enviro.EnviroManager.instance == null || Enviro.EnviroManager.instance.Sky == null)
|
||||
return;
|
||||
|
||||
if (skyMat == null)
|
||||
Build();
|
||||
|
||||
Enviro.EnviroManager.instance.Sky.UpdateSkybox(skyMat);
|
||||
|
||||
if(Enviro.EnviroManager.instance.Sky != null && Enviro.EnviroManager.instance.Lighting != null)
|
||||
{
|
||||
Shader.SetGlobalColor("_AmbientColorTintHDRP", Enviro.EnviroManager.instance.Lighting.Settings.ambientColorTintHDRP.Evaluate(Enviro.EnviroManager.instance.solarTime));
|
||||
}
|
||||
|
||||
var enviroSky = builtinParams.skySettings as EnviroHDRPSky;
|
||||
|
||||
m_PropertyBlock.SetMatrix("_PixelCoordToViewDirWS", builtinParams.pixelCoordToViewDirMatrix);
|
||||
Shader.SetGlobalMatrix("_PixelCoordToViewDirWS", builtinParams.pixelCoordToViewDirMatrix);
|
||||
|
||||
Shader.SetGlobalFloat("_EnviroSkyIntensity", GetSkyIntensity(enviroSky, builtinParams.debugSettings));
|
||||
|
||||
if(Enviro.EnviroManager.instance.Objects.directionalLight != null)
|
||||
Enviro.EnviroManager.instance.Objects.directionalLight.transform.position = Vector3.zero;
|
||||
|
||||
if(Enviro.EnviroManager.instance.Objects.additionalDirectionalLight != null)
|
||||
Enviro.EnviroManager.instance.Objects.additionalDirectionalLight.transform.position = Vector3.zero;
|
||||
|
||||
if(builtinParams.hdCamera.camera.cameraType == CameraType.Reflection && renderForCubemap)
|
||||
{
|
||||
// return;
|
||||
}
|
||||
|
||||
CoreUtils.DrawFullScreen(builtinParams.commandBuffer, skyMat, m_PropertyBlock, renderForCubemap ? 0 : 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f77400c0734edcc47b5d98a75a6a284f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Sky/EnviroHDRPSkyRenderer.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,387 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroSky
|
||||
{
|
||||
public enum SkyMode
|
||||
{
|
||||
Normal,
|
||||
Simple
|
||||
}
|
||||
|
||||
public SkyMode skyMode;
|
||||
|
||||
public enum MoonMode
|
||||
{
|
||||
Realistic,
|
||||
Simple,
|
||||
Off
|
||||
}
|
||||
public MoonMode moonMode;
|
||||
|
||||
public bool forcedSkyboxSetup = true;
|
||||
//Front Colors
|
||||
[GradientUsage(true)]
|
||||
public Gradient frontColorGradient0,frontColorGradient1,frontColorGradient2,frontColorGradient3,frontColorGradient4,frontColorGradient5;
|
||||
|
||||
//Back Colors
|
||||
[GradientUsage(true)]
|
||||
public Gradient backColorGradient0,backColorGradient1,backColorGradient2,backColorGradient3,backColorGradient4,backColorGradient5;
|
||||
|
||||
//Other Colors
|
||||
[GradientUsage(true)]
|
||||
public Gradient sunDiscColorGradient, moonColorGradient, moonGlowColorGradient;
|
||||
|
||||
//Textures
|
||||
public Cubemap starsTex;
|
||||
public Cubemap starsTwinklingTex;
|
||||
public Cubemap galaxyTex;
|
||||
public Texture2D sunTex;
|
||||
public Texture2D moonTex;
|
||||
public Texture2D moonGlowTex;
|
||||
|
||||
//Distribution
|
||||
[Range(-0.1f,1f)]
|
||||
public float distribution0,distribution1,distribution2,distribution3;
|
||||
|
||||
public AnimationCurve mieScatteringIntensityCurve,moonGlowIntensityCurve,starIntensityCurve,galaxyIntensityCurve;
|
||||
public AnimationCurve intensityCurve = new AnimationCurve(new Keyframe(0,1), new Keyframe(1,1));
|
||||
public float intensity, sunScale, moonScale;
|
||||
|
||||
[Range(0f,2f)]
|
||||
public float mieScatteringMultiplier = 1.0f;
|
||||
|
||||
[Range(0f,1f)]
|
||||
public float starsTwinklingSpeed = 0.1f;
|
||||
[Range(-2f,2f)]
|
||||
public float moonPhase;
|
||||
public AnimationCurve skyExposureHDRP;
|
||||
#if ENVIRO_HDRP
|
||||
public UnityEngine.Rendering.HighDefinition.SkyAmbientMode skyAmbientModeHDRP = UnityEngine.Rendering.HighDefinition.SkyAmbientMode.Dynamic;
|
||||
#endif
|
||||
[ColorUsage(false,true)]
|
||||
public Color skyColorTint = Color.white;
|
||||
|
||||
[Range(0f,2f)]
|
||||
public float skyColorExponent = 1.0f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[ExecuteInEditMode]
|
||||
public class EnviroSkyModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroSky Settings;
|
||||
public EnviroSkyModule preset;
|
||||
|
||||
public bool showSkyControls;
|
||||
public bool showSkySunControls;
|
||||
public bool showSkyMoonControls;
|
||||
public bool showSkyStarsControls;
|
||||
|
||||
#if ENVIRO_HDRP
|
||||
UnityEngine.Rendering.HighDefinition.VisualEnvironment visualEnvironment;
|
||||
UnityEngine.Rendering.HighDefinition.EnviroHDRPSky enviroHDRPSky;
|
||||
#endif
|
||||
|
||||
public Material mySkyboxMat;
|
||||
|
||||
private float starsTwinkling;
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
#if !ENVIRO_HDRP
|
||||
SetupSkybox ();
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
|
||||
|
||||
#if !ENVIRO_HDRP
|
||||
if(mySkyboxMat != null)
|
||||
DestroyImmediate(mySkyboxMat);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
#if !ENVIRO_HDRP
|
||||
|
||||
if(mySkyboxMat == null || (mySkyboxMat != RenderSettings.skybox && Settings.forcedSkyboxSetup))
|
||||
SetupSkybox ();
|
||||
|
||||
UpdateSkybox (mySkyboxMat);
|
||||
#else
|
||||
UpdateHDRPSky ();
|
||||
#endif
|
||||
|
||||
if(EnviroManager.instance != null && EnviroManager.instance.Time != null && Settings.moonMode == EnviroSky.MoonMode.Realistic)
|
||||
UpdateMoonPhase ();
|
||||
}
|
||||
|
||||
public void SetupSkybox ()
|
||||
{
|
||||
if(mySkyboxMat == null)
|
||||
{
|
||||
mySkyboxMat = new Material (Shader.Find("Enviro/Skybox"));
|
||||
RenderSettings.skybox = mySkyboxMat;
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSettings.skybox = mySkyboxMat;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSkybox (Material mat)
|
||||
{
|
||||
float solarTime = EnviroManager.instance.solarTime;
|
||||
|
||||
|
||||
Shader.SetGlobalColor("_FrontColor1",Settings.frontColorGradient1.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_FrontColor2",Settings.frontColorGradient2.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_FrontColor5",Settings.frontColorGradient5.Evaluate(solarTime)); ;
|
||||
Shader.SetGlobalColor("_BackColor1",Settings.backColorGradient1.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_BackColor2",Settings.backColorGradient2.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_BackColor5",Settings.backColorGradient5.Evaluate(solarTime));
|
||||
|
||||
Shader.SetGlobalColor("_SkyColorTint",Settings.skyColorTint);
|
||||
|
||||
Shader.SetGlobalColor("_SunColor",Settings.sunDiscColorGradient.Evaluate(solarTime));
|
||||
mat.SetColor("_MoonColor",Settings.moonColorGradient.Evaluate(solarTime));
|
||||
mat.SetColor("_MoonGlowColor",Settings.moonGlowColorGradient.Evaluate(solarTime));
|
||||
|
||||
Shader.SetGlobalFloat("_Intensity", Settings.intensity * Settings.intensityCurve.Evaluate(solarTime));
|
||||
Shader.SetGlobalFloat("_SkyColorExponent", Settings.skyColorExponent);
|
||||
Shader.SetGlobalFloat("_MieScatteringIntensity", Settings.mieScatteringIntensityCurve.Evaluate(solarTime) * Settings.mieScatteringMultiplier);
|
||||
|
||||
mat.SetFloat("_MoonGlowIntensity", Settings.moonGlowIntensityCurve.Evaluate(solarTime));
|
||||
mat.SetFloat("_StarIntensity", Settings.starIntensityCurve.Evaluate(solarTime));
|
||||
mat.SetFloat("_GalaxyIntensity", Settings.galaxyIntensityCurve.Evaluate(solarTime));
|
||||
|
||||
Shader.SetGlobalFloat("_frontBackDistribution0",Settings.distribution0);
|
||||
Shader.SetGlobalFloat("_frontBackDistribution1",Settings.distribution1);
|
||||
|
||||
if (Settings.skyMode == EnviroSky.SkyMode.Simple)
|
||||
{
|
||||
Shader.EnableKeyword("ENVIRO_SIMPLESKY");
|
||||
}
|
||||
else
|
||||
{
|
||||
Shader.DisableKeyword("ENVIRO_SIMPLESKY");
|
||||
Shader.SetGlobalColor("_FrontColor0",Settings.frontColorGradient0.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_BackColor0",Settings.backColorGradient0.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_FrontColor3",Settings.frontColorGradient3.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_FrontColor4",Settings.frontColorGradient4.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_BackColor3",Settings.backColorGradient3.Evaluate(solarTime));
|
||||
Shader.SetGlobalColor("_BackColor4",Settings.backColorGradient4.Evaluate(solarTime));
|
||||
Shader.SetGlobalFloat("_frontBackDistribution2",Settings.distribution2);
|
||||
Shader.SetGlobalFloat("_frontBackDistribution3",Settings.distribution3);
|
||||
|
||||
if(Settings.galaxyTex != null)
|
||||
mat.SetTexture("_GalaxyTex",Settings.galaxyTex);
|
||||
}
|
||||
|
||||
|
||||
if(Settings.moonMode == EnviroSky.MoonMode.Off)
|
||||
mat.SetVector("_SkyMoonParameters", new Vector4(Settings.moonPhase,Settings.moonScale,Settings.moonScale,0f));
|
||||
else
|
||||
mat.SetVector("_SkyMoonParameters", new Vector4(Settings.moonPhase,Settings.moonScale,Settings.moonScale,1f));
|
||||
|
||||
mat.SetVector("_SkySunParameters", new Vector4(Settings.sunScale,Settings.sunScale,Settings.sunScale,Settings.sunScale));
|
||||
|
||||
if(Settings.starsTex != null)
|
||||
mat.SetTexture("_StarsTex",Settings.starsTex);
|
||||
if(Settings.starsTwinklingTex != null)
|
||||
mat.SetTexture("_StarsTwinklingTex",Settings.starsTwinklingTex);
|
||||
if(Settings.sunTex != null)
|
||||
mat.SetTexture("_SunTex",Settings.sunTex);
|
||||
if(Settings.moonTex != null)
|
||||
mat.SetTexture("_MoonTex",Settings.moonTex);
|
||||
if(Settings.moonGlowTex != null)
|
||||
mat.SetTexture("_MoonGlowTex",Settings.moonGlowTex);
|
||||
|
||||
Shader.SetGlobalVector("_SunDir",-EnviroManager.instance.Objects.sun.transform.forward);
|
||||
Shader.SetGlobalVector("_MoonDir",EnviroManager.instance.Objects.moon.transform.forward);
|
||||
|
||||
//Deactivate flat and cirrus clouds when no flat clouds module found.
|
||||
if(EnviroManager.instance.FlatClouds == null)
|
||||
{
|
||||
Shader.SetGlobalFloat("_CirrusClouds",0f);
|
||||
Shader.SetGlobalFloat("_FlatClouds",0f);
|
||||
}
|
||||
//Deactivate auroira when no flat clouds module found.
|
||||
if(EnviroManager.instance.Aurora == null)
|
||||
{
|
||||
Shader.SetGlobalFloat("_Aurora",0f);
|
||||
}
|
||||
|
||||
mat.SetFloat("_StarsTwinkling", Settings.starsTwinklingSpeed);
|
||||
|
||||
if (Settings.starsTwinklingSpeed > 0.0f)
|
||||
{
|
||||
starsTwinkling += Settings.starsTwinklingSpeed * Time.deltaTime;
|
||||
Quaternion rot = Quaternion.Euler(starsTwinkling, starsTwinkling, starsTwinkling);
|
||||
Matrix4x4 NoiseRot = Matrix4x4.TRS(Vector3.zero, rot, new Vector3(1, 1, 1));
|
||||
mat.SetMatrix("_StarsTwinklingMatrix", NoiseRot);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateMoonPhase ()
|
||||
{
|
||||
float angle = Vector3.SignedAngle(EnviroManager.instance.Objects.moon.transform.forward, EnviroManager.instance.Objects.sun.transform.forward, -EnviroManager.instance.transform.forward);
|
||||
|
||||
if (EnviroManager.instance.Time.Settings.latitude >= 0)
|
||||
{
|
||||
if (angle < 0)
|
||||
{
|
||||
Settings.moonPhase = EnviroHelper.Remap(angle, 0f, -180f, -2f, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.moonPhase = EnviroHelper.Remap(angle, 0f, 180f, 2f, 0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (angle < 0)
|
||||
{
|
||||
Settings.moonPhase = EnviroHelper.Remap(angle, 0f, -180f, 2f, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.moonPhase = EnviroHelper.Remap(angle, 0f, 180f, -2f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if ENVIRO_HDRP
|
||||
public void UpdateHDRPSky ()
|
||||
{
|
||||
if(EnviroManager.instance.volumeHDRP != null && EnviroManager.instance.volumeProfileHDRP != null)
|
||||
{
|
||||
if(visualEnvironment == null)
|
||||
{
|
||||
UnityEngine.Rendering.HighDefinition.VisualEnvironment TempEnv;
|
||||
|
||||
if (EnviroManager.instance.volumeProfileHDRP.TryGet<UnityEngine.Rendering.HighDefinition.VisualEnvironment>(out TempEnv))
|
||||
{
|
||||
visualEnvironment = TempEnv;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnviroManager.instance.volumeProfileHDRP.Add<UnityEngine.Rendering.HighDefinition.VisualEnvironment>();
|
||||
|
||||
if (EnviroManager.instance.volumeProfileHDRP.TryGet<UnityEngine.Rendering.HighDefinition.VisualEnvironment>(out TempEnv))
|
||||
{
|
||||
visualEnvironment = TempEnv;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
visualEnvironment.skyType.value = 990;
|
||||
visualEnvironment.skyType.overrideState = true;
|
||||
visualEnvironment.skyAmbientMode.value = Settings.skyAmbientModeHDRP;
|
||||
visualEnvironment.skyAmbientMode.overrideState = true;
|
||||
}
|
||||
|
||||
if(enviroHDRPSky == null)
|
||||
{
|
||||
UnityEngine.Rendering.HighDefinition.EnviroHDRPSky TempSky;
|
||||
if (EnviroManager.instance.volumeProfileHDRP.TryGet<UnityEngine.Rendering.HighDefinition.EnviroHDRPSky>(out TempSky))
|
||||
{
|
||||
enviroHDRPSky = TempSky;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnviroManager.instance.volumeProfileHDRP.Add<UnityEngine.Rendering.HighDefinition.EnviroHDRPSky>();
|
||||
|
||||
if (EnviroManager.instance.volumeProfileHDRP.TryGet<UnityEngine.Rendering.HighDefinition.EnviroHDRPSky>(out TempSky))
|
||||
{
|
||||
enviroHDRPSky = TempSky;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
enviroHDRPSky.skyIntensityMode.overrideState = true;
|
||||
enviroHDRPSky.skyIntensityMode.value = UnityEngine.Rendering.HighDefinition.SkyIntensityMode.Exposure;
|
||||
enviroHDRPSky.exposure.overrideState = true;
|
||||
|
||||
enviroHDRPSky.exposure.value = Settings.skyExposureHDRP.Evaluate(EnviroManager.instance.solarTime);
|
||||
|
||||
enviroHDRPSky.updateMode.overrideState = true;
|
||||
|
||||
if(Application.isPlaying)
|
||||
enviroHDRPSky.updateMode.value = UnityEngine.Rendering.HighDefinition.EnvironmentUpdateMode.OnChanged;
|
||||
else
|
||||
enviroHDRPSky.updateMode.value = UnityEngine.Rendering.HighDefinition.EnvironmentUpdateMode.Realtime;
|
||||
|
||||
/* if (UnityEngine.Rendering.RenderPipelineManager.currentPipeline is UnityEngine.Rendering.HighDefinition.HDRenderPipeline)
|
||||
{
|
||||
if(EnviroManager.instance.updateSkyAndLightingHDRP)
|
||||
{
|
||||
UnityEngine.Rendering.HighDefinition.HDRenderPipeline hd = (UnityEngine.Rendering.HighDefinition.HDRenderPipeline)UnityEngine.Rendering.RenderPipelineManager.currentPipeline;
|
||||
hd.RequestSkyEnvironmentUpdate();
|
||||
}
|
||||
} */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroSky>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroSkyModule t = ScriptableObject.CreateInstance<EnviroSkyModule>();
|
||||
t.name = "Sky Module";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroSky>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SaveModuleValues (EnviroSkyModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroSky>(JsonUtility.ToJson(Settings));
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 375eef0084d44344ebf50cbba7c1eadb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Sky/EnviroSkyModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28103e1020df9d24fbe65d103e2e17e5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,687 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 375eef0084d44344ebf50cbba7c1eadb, type: 3}
|
||||
m_Name: Default Sky Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 1
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
skyMode: 0
|
||||
moonMode: 1
|
||||
forcedSkyboxSetup: 1
|
||||
frontColorGradient0:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0, g: 0, b: 0, a: 1}
|
||||
key2: {r: 0.18743324, g: 0.27322546, b: 0.49056602, a: 0}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 32768
|
||||
ctime2: 65535
|
||||
ctime3: 0
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 3
|
||||
m_NumAlphaKeys: 2
|
||||
frontColorGradient1:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.016509429, g: 0.021462252, b: 0.066037714, a: 1}
|
||||
key2: {r: 0.11814703, g: 0.14878513, b: 0.4245283, a: 0}
|
||||
key3: {r: 0.6226415, g: 0.32617846, b: 0.27901387, a: 0}
|
||||
key4: {r: 0.50271446, g: 0.5662443, b: 0.745283, a: 0}
|
||||
key5: {r: 1.2720131, g: 1.331453, b: 1.4562767, a: 0}
|
||||
key6: {r: 1.2720131, g: 1.331453, b: 1.4562767, a: 0}
|
||||
key7: {r: 1.2720131, g: 1.331453, b: 1.4562767, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 21781
|
||||
ctime3: 30840
|
||||
ctime4: 35466
|
||||
ctime5: 65535
|
||||
ctime6: 65535
|
||||
ctime7: 65535
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
frontColorGradient2:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.0146404365, g: 0.019780159, b: 0.066037714, a: 1}
|
||||
key2: {r: 0.12589, g: 0.15198022, b: 0.38679248, a: 0}
|
||||
key3: {r: 0.6415094, g: 0.39747813, b: 0.26326096, a: 0}
|
||||
key4: {r: 0.34282663, g: 0.4525284, b: 0.6792453, a: 0}
|
||||
key5: {r: 0.4764151, g: 0.6458101, b: 1, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 23130
|
||||
ctime3: 32768
|
||||
ctime4: 36430
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
frontColorGradient3:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.010457456, g: 0.013281485, b: 0.047169805, a: 1}
|
||||
key2: {r: 0.112896055, g: 0.14217246, b: 0.4056604, a: 0}
|
||||
key3: {r: 0.3773585, g: 0.3652376, b: 0.35777858, a: 0}
|
||||
key4: {r: 0.21560162, g: 0.36202627, b: 0.5377358, a: 0}
|
||||
key5: {r: 0.15806337, g: 0.40404686, b: 0.9056604, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 23323
|
||||
ctime3: 32768
|
||||
ctime4: 36044
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
frontColorGradient4:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.008721959, g: 0.011945723, b: 0.03773582, a: 1}
|
||||
key2: {r: 0.12896048, g: 0.15503518, b: 0.3962264, a: 0}
|
||||
key3: {r: 0.16398183, g: 0.34142488, b: 0.5188679, a: 0}
|
||||
key4: {r: 0.14276282, g: 0.29724503, b: 0.45172718, a: 0}
|
||||
key5: {r: 0.12495552, g: 0.30849513, b: 0.6792453, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 22552
|
||||
ctime3: 32768
|
||||
ctime4: 36044
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
frontColorGradient5:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.0060074786, g: 0.009723211, b: 0.028301895, a: 1}
|
||||
key2: {r: 0.13349947, g: 0.15872619, b: 0.3773585, a: 0}
|
||||
key3: {r: 0.06541474, g: 0.26604164, b: 0.6603774, a: 0}
|
||||
key4: {r: 0.05502618, g: 0.22379138, b: 0.5555024, a: 0}
|
||||
key5: {r: 0.055535786, g: 0.13623697, b: 0.3018868, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 23516
|
||||
ctime3: 32768
|
||||
ctime4: 36044
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
backColorGradient0:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0, g: 0, b: 0, a: 1}
|
||||
key2: {r: 0.18743324, g: 0.27322546, b: 0.49056602, a: 0}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29491
|
||||
ctime2: 65535
|
||||
ctime3: 0
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 3
|
||||
m_NumAlphaKeys: 2
|
||||
backColorGradient1:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.010946958, g: 0.015512637, b: 0.05660379, a: 1}
|
||||
key2: {r: 0.08810965, g: 0.113260925, b: 0.33962262, a: 0}
|
||||
key3: {r: 0.1439124, g: 0.24335337, b: 0.3962264, a: 0}
|
||||
key4: {r: 0.14462443, g: 0.22903053, b: 0.4716981, a: 0}
|
||||
key5: {r: 1.0093603, g: 1.120279, b: 1.3587542, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 22552
|
||||
ctime3: 32768
|
||||
ctime4: 36623
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
backColorGradient2:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.017221436, g: 0.024346098, b: 0.084905684, a: 1}
|
||||
key2: {r: 0.06977572, g: 0.092986815, b: 0.3018868, a: 0}
|
||||
key3: {r: 0.14462443, g: 0.2701294, b: 0.4716981, a: 0}
|
||||
key4: {r: 0.11814703, g: 0.235986, b: 0.4245283, a: 0}
|
||||
key5: {r: 0.5594963, g: 0.67877066, b: 0.9339623, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 22937
|
||||
ctime3: 32768
|
||||
ctime4: 36044
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
backColorGradient3:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.016464932, g: 0.023881558, b: 0.09433961, a: 1}
|
||||
key2: {r: 0.047436804, g: 0.06790358, b: 0.24528301, a: 0}
|
||||
key3: {r: 0.12615699, g: 0.2354197, b: 0.4245283, a: 0}
|
||||
key4: {r: 0.11881164, g: 0.21231776, b: 0.36504444, a: 0}
|
||||
key5: {r: 0.10622107, g: 0.30720985, b: 0.7264151, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 21203
|
||||
ctime3: 32189
|
||||
ctime4: 36044
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
backColorGradient4:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.012148449, g: 0.015318409, b: 0.066037714, a: 1}
|
||||
key2: {r: 0.052064795, g: 0.06886638, b: 0.24528301, a: 0}
|
||||
key3: {r: 0.13510145, g: 0.23963216, b: 0.41509432, a: 0}
|
||||
key4: {r: 0.12047333, g: 0.21410206, b: 0.37014997, a: 0}
|
||||
key5: {r: 0.16838734, g: 0.38746652, b: 0.8301887, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 22359
|
||||
ctime3: 32768
|
||||
ctime4: 36044
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
backColorGradient5:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.009344964, g: 0.016615558, b: 0.05660379, a: 1}
|
||||
key2: {r: 0.052064802, g: 0.073716745, b: 0.2830189, a: 0}
|
||||
key3: {r: 0.13883945, g: 0.256586, b: 0.4528302, a: 0}
|
||||
key4: {r: 0.10290611, g: 0.1901784, b: 0.3356322, a: 0}
|
||||
key5: {r: 0.12322002, g: 0.30227578, b: 0.6698113, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 24479
|
||||
ctime3: 32768
|
||||
ctime4: 36044
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumAlphaKeys: 2
|
||||
sunDiscColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0, g: 0, b: 0, a: 1}
|
||||
key2: {r: 33.89676, g: 9.719456, b: 3.7268682, a: 0}
|
||||
key3: {r: 5.2437057, g: 2.6674795, b: 1.5582712, a: 0}
|
||||
key4: {r: 10.432951, g: 8.302663, b: 5.89926, a: 0}
|
||||
key5: {r: 10.432951, g: 8.302663, b: 5.89926, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29491
|
||||
ctime2: 32189
|
||||
ctime3: 36044
|
||||
ctime4: 65535
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
moonColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 4.237095, g: 4.237095, b: 4.237095, a: 1}
|
||||
key1: {r: 4.237095, g: 4.237095, b: 4.237095, a: 1}
|
||||
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||
key3: {r: 9.082411, g: 9.082411, b: 9.082411, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 36147
|
||||
ctime2: 37478
|
||||
ctime3: 65535
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 3
|
||||
m_NumAlphaKeys: 2
|
||||
moonGlowColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 1, g: 1, b: 1, a: 1}
|
||||
key1: {r: 2.297397, g: 2.297397, b: 2.297397, a: 1}
|
||||
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 65535
|
||||
ctime2: 0
|
||||
ctime3: 0
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 2
|
||||
m_NumAlphaKeys: 2
|
||||
starsTex: {fileID: 8900000, guid: b5a7175da0f133b4d951c19c9c2cebfc, type: 3}
|
||||
starsTwinklingTex: {fileID: 8900000, guid: a25af6a439465e247b1c97f4608d75ce, type: 3}
|
||||
galaxyTex: {fileID: 8900000, guid: 5734983fc81450b4187c3cfa5985edef, type: 3}
|
||||
sunTex: {fileID: 2800000, guid: c95bed5306e94f24ba5802d841607ac7, type: 3}
|
||||
moonTex: {fileID: 2800000, guid: c6fd9f694390e0245b6dca5812065950, type: 3}
|
||||
moonGlowTex: {fileID: 2800000, guid: 6838e0810da4e49488b5d9a6ee76eb07, type: 3}
|
||||
distribution0: 0.015
|
||||
distribution1: 0.129
|
||||
distribution2: 0.358
|
||||
distribution3: 0.779
|
||||
mieScatteringIntensityCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: -0.007847921
|
||||
outSlope: -0.007847921
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.3561647
|
||||
value: -0.0027951524
|
||||
inSlope: -0.038249854
|
||||
outSlope: -0.038249854
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.6600225
|
||||
- serializedVersion: 3
|
||||
time: 0.5428551
|
||||
value: 0.68094885
|
||||
inSlope: 1.574418
|
||||
outSlope: 1.574418
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.17693263
|
||||
outWeight: 0.16409834
|
||||
- serializedVersion: 3
|
||||
time: 0.9999943
|
||||
value: 0.879508
|
||||
inSlope: -0.080521375
|
||||
outSlope: -0.080521375
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.17235015
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
moonGlowIntensityCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: -0.0041648876
|
||||
value: 0.5331504
|
||||
inSlope: 0.02708037
|
||||
outSlope: 0.02708037
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.4766767
|
||||
- serializedVersion: 3
|
||||
time: 0.4666333
|
||||
value: 0.42919362
|
||||
inSlope: -0.5320517
|
||||
outSlope: -0.5320517
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.29416153
|
||||
- serializedVersion: 3
|
||||
time: 1.0000203
|
||||
value: 0.0000010535587
|
||||
inSlope: 0.04149956
|
||||
outSlope: 0.04149956
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.40983278
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
starIntensityCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 2
|
||||
inSlope: 0.085266516
|
||||
outSlope: 0.085266516
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.50991267
|
||||
- serializedVersion: 3
|
||||
time: 0.24226823
|
||||
value: 1.6664829
|
||||
inSlope: -2.991319
|
||||
outSlope: -2.991319
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.06692798
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.5965074
|
||||
value: 0.008752085
|
||||
inSlope: -0.09524627
|
||||
outSlope: -0.09524627
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.42628345
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0.021690818
|
||||
outSlope: -0.021690818
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
galaxyIntensityCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: -0.030366909
|
||||
value: 0.5
|
||||
inSlope: -0.0010944334
|
||||
outSlope: -0.0010944334
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.115316436
|
||||
- serializedVersion: 3
|
||||
time: 0.2869789
|
||||
value: 0.4267584
|
||||
inSlope: -0.78694266
|
||||
outSlope: -0.78694266
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.12658444
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 0.5994185
|
||||
value: 0.0009220154
|
||||
inSlope: -0.032852825
|
||||
outSlope: -0.032852825
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.18183947
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0.0023016925
|
||||
outSlope: -0.0023016925
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
intensityCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
intensity: 1
|
||||
sunScale: 7
|
||||
moonScale: 7
|
||||
mieScatteringMultiplier: 0.6
|
||||
starsTwinklingSpeed: 0.25
|
||||
moonPhase: 0
|
||||
skyExposureHDRP:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 5
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
skyColorTint: {r: 1, g: 1, b: 1, a: 1}
|
||||
skyColorExponent: 1.2
|
||||
preset: {fileID: 0}
|
||||
showSkyControls: 0
|
||||
showSkySunControls: 0
|
||||
showSkyMoonControls: 0
|
||||
showSkyStarsControls: 0
|
||||
mySkyboxMat: {fileID: 0}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44f43418b8d8b8142863e38d1e49e174
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Sky/Preset/Default
|
||||
Sky Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60bb36661457fd841a90d3adea4eec5d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,643 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroTime
|
||||
{
|
||||
public bool simulate;
|
||||
public DateTime date = new DateTime(1,1,1,0,0,0);
|
||||
|
||||
[SerializeField]
|
||||
public int secSerial, minSerial, hourSerial, daySerial, monthSerial, yearSerial;
|
||||
public float timeOfDay;
|
||||
|
||||
[Range(-90, 90)]
|
||||
[Tooltip("-90, 90 Horizontal earth lines")]
|
||||
public float latitude;
|
||||
[Range(-180, 180)]
|
||||
[Tooltip("-180, 180 Vertical earth line")]
|
||||
public float longitude;
|
||||
[Range(-13, 13)]
|
||||
[Tooltip("Time offset for timezones")]
|
||||
public int utcOffset;
|
||||
[Tooltip("Realtime minutes for a 24h game time cycle.")]
|
||||
public float cycleLengthInMinutes = 10f;
|
||||
[Tooltip("Day length modifier will increase/decrease time progression speed at daytime.")]
|
||||
[Range(0.1f, 10f)]
|
||||
public float dayLengthModifier = 1f;
|
||||
[Tooltip("Night length modifier will increase/decrease time progression speed at nighttime.")]
|
||||
[Range(0.1f, 10f)]
|
||||
public float nightLengthModifier = 1f;
|
||||
|
||||
|
||||
public enum CalenderType
|
||||
{
|
||||
Realistic,
|
||||
Custom
|
||||
}
|
||||
|
||||
public CalenderType calenderType;
|
||||
public int daysInMonth = 10;
|
||||
public int monthsInYear = 4;
|
||||
|
||||
public float customSunOffset = -8f;
|
||||
[Range(0,360)]
|
||||
public float customSunRotation = 0f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[ExecuteInEditMode]
|
||||
public class EnviroTimeModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroTime Settings;
|
||||
public EnviroTimeModule preset;
|
||||
public bool showTimeControls,showLocationControls;
|
||||
public float LST; // changed to make accessible outside the module
|
||||
private float internalTimeOverflow;
|
||||
|
||||
///////// Time
|
||||
public void SetDateTime (int sec, int min, int hours, int day, int month, int year)
|
||||
{
|
||||
//Check for incorrect dates
|
||||
if(year == 0)
|
||||
year = 1;
|
||||
if(month == 0)
|
||||
month = 1;
|
||||
if(day == 0)
|
||||
day = 1;
|
||||
|
||||
Settings.secSerial = sec;
|
||||
Settings.minSerial = min;
|
||||
Settings.hourSerial = hours;
|
||||
Settings.daySerial = day;
|
||||
Settings.monthSerial = month;
|
||||
Settings.yearSerial = year;
|
||||
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Realistic)
|
||||
{
|
||||
DateTime curTime = new DateTime(1,1,1,0,0,0);
|
||||
|
||||
curTime = curTime.AddYears(Settings.yearSerial-1);
|
||||
curTime = curTime.AddMonths(Settings.monthSerial-1);
|
||||
curTime = curTime.AddDays(Settings.daySerial-1);
|
||||
curTime = curTime.AddHours(Settings.hourSerial);
|
||||
curTime = curTime.AddMinutes(Settings.minSerial);
|
||||
curTime = curTime.AddSeconds(Settings.secSerial);
|
||||
|
||||
//Events
|
||||
if(EnviroManager.instance != null && EnviroManager.instance.Events != null && EnviroManager.instance.notFirstFrame && Application.isPlaying)
|
||||
{
|
||||
if(Settings.date.Hour != curTime.Hour)
|
||||
EnviroManager.instance.NotifyHourPassed();
|
||||
|
||||
if(Settings.date.Day != curTime.Day)
|
||||
EnviroManager.instance.NotifyDayPassed();
|
||||
|
||||
if(Settings.date.Year != curTime.Year)
|
||||
EnviroManager.instance.NotifyYearPassed();
|
||||
}
|
||||
|
||||
Settings.date = curTime;
|
||||
|
||||
Settings.secSerial = Settings.date.Second;
|
||||
Settings.minSerial = Settings.date.Minute;
|
||||
Settings.hourSerial = Settings.date.Hour;
|
||||
Settings.daySerial = Settings.date.Day;
|
||||
Settings.monthSerial = Settings.date.Month;
|
||||
Settings.yearSerial = Settings.date.Year;
|
||||
|
||||
Settings.timeOfDay = Settings.date.Hour + (Settings.date.Minute * 0.0166667f) + (Settings.date.Second * 0.000277778f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(Settings.secSerial >= 60)
|
||||
{
|
||||
Settings.minSerial += 1;
|
||||
Settings.secSerial = 0;
|
||||
}
|
||||
|
||||
if(Settings.minSerial >= 60)
|
||||
{
|
||||
Settings.hourSerial += 1;
|
||||
Settings.minSerial = 0;
|
||||
if(EnviroManager.instance.Events != null && EnviroManager.instance.notFirstFrame && Application.isPlaying)
|
||||
EnviroManager.instance.NotifyHourPassed();
|
||||
}
|
||||
|
||||
if(Settings.hourSerial >= 24)
|
||||
{
|
||||
Settings.daySerial += 1;
|
||||
Settings.hourSerial = 0;
|
||||
if(EnviroManager.instance.Events != null && EnviroManager.instance.notFirstFrame && Application.isPlaying)
|
||||
EnviroManager.instance.NotifyDayPassed();
|
||||
}
|
||||
|
||||
if(Settings.daySerial > Settings.daysInMonth)
|
||||
{
|
||||
Settings.monthSerial += 1;
|
||||
Settings.daySerial = 1;
|
||||
}
|
||||
|
||||
if(Settings.monthSerial > Settings.monthsInYear)
|
||||
{
|
||||
Settings.yearSerial += 1;
|
||||
Settings.monthSerial = 1;
|
||||
if(EnviroManager.instance.Events != null && EnviroManager.instance.notFirstFrame && Application.isPlaying)
|
||||
EnviroManager.instance.NotifyYearPassed();
|
||||
}
|
||||
|
||||
Settings.timeOfDay = hours + (minutes * 0.0166667f) + (seconds * 0.000277778f);
|
||||
}
|
||||
}
|
||||
|
||||
//Time
|
||||
public int seconds
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Realistic)
|
||||
return Settings.date.Second;
|
||||
else
|
||||
return Settings.secSerial;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetDateTime(value,Settings.minSerial,Settings.hourSerial,Settings.daySerial,Settings.monthSerial,Settings.yearSerial);
|
||||
}
|
||||
}
|
||||
|
||||
public int minutes
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Realistic)
|
||||
return Settings.date.Minute;
|
||||
else
|
||||
return Settings.minSerial;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetDateTime(Settings.secSerial,value,Settings.hourSerial,Settings.daySerial,Settings.monthSerial,Settings.yearSerial);
|
||||
}
|
||||
}
|
||||
|
||||
public int hours
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Realistic)
|
||||
return Settings.date.Hour;
|
||||
else
|
||||
return Settings.hourSerial;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetDateTime(Settings.secSerial,Settings.minSerial,value,Settings.daySerial,Settings.monthSerial,Settings.yearSerial);
|
||||
}
|
||||
}
|
||||
|
||||
public int days
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Realistic)
|
||||
return Settings.date.Day;
|
||||
else
|
||||
return Settings.daySerial;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetDateTime(Settings.secSerial,Settings.minSerial,Settings.hourSerial,value,Settings.monthSerial,Settings.yearSerial);
|
||||
}
|
||||
}
|
||||
|
||||
public int months
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Realistic)
|
||||
return Settings.date.Month;
|
||||
else
|
||||
return Settings.monthSerial;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetDateTime(Settings.secSerial,Settings.minSerial,Settings.hourSerial,Settings.daySerial,value,Settings.yearSerial);
|
||||
}
|
||||
}
|
||||
public int years
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Realistic)
|
||||
return Settings.date.Year;
|
||||
else
|
||||
return Settings.yearSerial;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetDateTime(Settings.secSerial,Settings.minSerial,Settings.hourSerial,Settings.daySerial,Settings.monthSerial,value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
if(Settings.simulate && Application.isPlaying)
|
||||
{
|
||||
float t = 0f;
|
||||
|
||||
float timeProgressionModifier = 1f;
|
||||
|
||||
if(!EnviroManager.instance.isNight)
|
||||
{
|
||||
timeProgressionModifier = Settings.dayLengthModifier;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeProgressionModifier = Settings.nightLengthModifier;
|
||||
}
|
||||
|
||||
t = (24.0f / 60.0f) / (Settings.cycleLengthInMinutes * timeProgressionModifier);
|
||||
t = t * 3600f * Time.deltaTime;
|
||||
|
||||
internalTimeOverflow += t;
|
||||
seconds += (int)internalTimeOverflow;
|
||||
|
||||
if (internalTimeOverflow >= 1f)
|
||||
internalTimeOverflow -= (int)internalTimeOverflow;
|
||||
}
|
||||
|
||||
SetDateTime(Settings.secSerial,Settings.minSerial,Settings.hourSerial,Settings.daySerial,Settings.monthSerial,Settings.yearSerial);
|
||||
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Realistic)
|
||||
UpdateSunAndMoonPosition();
|
||||
else
|
||||
UpdateCustomSunAndMoonPosition();
|
||||
}
|
||||
|
||||
|
||||
public void UpdateSunAndMoonPosition()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
float d = 367 * years - 7 * (years + (months + 9) / 12) / 4 + 275 * months / 9 + days - 730530; // corrected a bracket typo
|
||||
|
||||
d += (GetUniversalTimeOfDay() / 24f); //Universal ToD
|
||||
|
||||
float ecl = 23.4393f - 3.563E-7f * d;
|
||||
|
||||
if(EnviroManager.instance.Sky != null)
|
||||
{
|
||||
if(EnviroManager.instance.Sky.Settings.moonMode == EnviroSky.MoonMode.Simple)
|
||||
{
|
||||
CalculateSunPosition(d, ecl, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculateSunPosition(d, ecl, false);
|
||||
CalculateMoonPosition(d, ecl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculateSunPosition(d, ecl, false);
|
||||
CalculateMoonPosition(d, ecl);
|
||||
}
|
||||
|
||||
CalculateStarsPosition(LST);
|
||||
}
|
||||
|
||||
public void UpdateCustomSunAndMoonPosition()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
//Rotate Sun and Moon
|
||||
EnviroManager.instance.sunRotationX = (Settings.timeOfDay + Settings.customSunOffset) * 15;
|
||||
|
||||
if(EnviroManager.instance.sunRotationX >= 360)
|
||||
EnviroManager.instance.sunRotationX = 0;
|
||||
|
||||
if(EnviroManager.instance.sunRotationX < 0)
|
||||
EnviroManager.instance.sunRotationX = 360 + EnviroManager.instance.sunRotationX;
|
||||
|
||||
EnviroManager.instance.sunRotationY = Settings.customSunRotation;
|
||||
|
||||
EnviroManager.instance.moonRotationX = EnviroManager.instance.sunRotationX - 180;
|
||||
|
||||
if(EnviroManager.instance.moonRotationX >= 360)
|
||||
EnviroManager.instance.moonRotationX = 0;
|
||||
|
||||
if(EnviroManager.instance.moonRotationX < 0)
|
||||
EnviroManager.instance.moonRotationX = 360 + EnviroManager.instance.moonRotationX;
|
||||
|
||||
EnviroManager.instance.moonRotationY = EnviroManager.instance.sunRotationY;
|
||||
EnviroManager.instance.UpdateNonTime();
|
||||
|
||||
//Rotate Stars
|
||||
EnviroManager.instance.Objects.stars.transform.localRotation = EnviroManager.instance.Objects.sun.transform.localRotation;
|
||||
Shader.SetGlobalMatrix("_StarsMatrix", EnviroManager.instance.Objects.stars.transform.worldToLocalMatrix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current time in hours. UTC0 (12.5 = 12:30)
|
||||
/// </summary>
|
||||
/// <returns>The the current time of day in hours.</returns>
|
||||
public float GetUniversalTimeOfDay()
|
||||
{
|
||||
return Settings.timeOfDay - Settings.utcOffset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current time in hours with UTC time offset.
|
||||
/// </summary>
|
||||
/// <returns>The the current time of day in hours.</returns>
|
||||
public float GetTimeOfDay()
|
||||
{
|
||||
return Settings.timeOfDay;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current date in hours.
|
||||
/// </summary>
|
||||
/// <returns>The date in hour format</returns>
|
||||
public double GetDateInHours()
|
||||
{
|
||||
double dateInHours = 0.0f;
|
||||
if(Settings.calenderType == EnviroTime.CalenderType.Custom)
|
||||
dateInHours = Settings.timeOfDay + (days * 24f) + ((years * (Settings.monthsInYear * Settings.daysInMonth)) * 24f);
|
||||
else
|
||||
dateInHours = Settings.timeOfDay + (days * 24f) + ((years * 365) * 24f);
|
||||
return dateInHours;
|
||||
}
|
||||
|
||||
/// Get current time in a nicely formatted string with seconds!
|
||||
/// </summary>
|
||||
/// <returns>The time string.</returns>
|
||||
public string GetTimeStringWithSeconds()
|
||||
{
|
||||
return string.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current time in a nicely formatted string!
|
||||
/// </summary>
|
||||
/// <returns>The time string.</returns>
|
||||
public string GetTimeString()
|
||||
{
|
||||
return string.Format("{0:00}:{1:00}", hours, minutes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the time of day in hours. (12.5 = 12:30)
|
||||
/// </summary>
|
||||
public void SetTimeOfDay(float tod)
|
||||
{
|
||||
Settings.timeOfDay = tod;
|
||||
hours = (int)(tod);
|
||||
tod -= hours;
|
||||
minutes = (int)(tod * 60f);
|
||||
tod -= minutes * 0.0166667f;
|
||||
seconds = (int)(tod * 3600f);
|
||||
}
|
||||
|
||||
public Vector3 OrbitalToLocal(float theta, float phi)
|
||||
{
|
||||
Vector3 pos;
|
||||
|
||||
float sinTheta = Mathf.Sin(theta);
|
||||
float cosTheta = Mathf.Cos(theta);
|
||||
float sinPhi = Mathf.Sin(phi);
|
||||
float cosPhi = Mathf.Cos(phi);
|
||||
|
||||
pos.z = sinTheta * cosPhi;
|
||||
pos.y = cosTheta;
|
||||
pos.x = sinTheta * sinPhi;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
public float Remap(float value, float from1, float to1, float from2, float to2)
|
||||
{
|
||||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||
}
|
||||
|
||||
public void CalculateSunPosition(float d, float ecl, bool simpleMoon)
|
||||
{
|
||||
/////http://www.stjarnhimlen.se/comp/ppcomp.html#5////
|
||||
///////////////////////// SUN ////////////////////////
|
||||
float w = 282.9404f + 4.70935E-5f * d;
|
||||
float e = 0.016709f - 1.151E-9f * d;
|
||||
float M = 356.0470f + 0.9856002585f * d;
|
||||
// minor correction for turns
|
||||
while (M > 360.0f)
|
||||
{
|
||||
M -= 360.0f;
|
||||
}
|
||||
while (M < 0.0f)
|
||||
{
|
||||
M += 360.0f;
|
||||
}
|
||||
|
||||
float E = M + e * Mathf.Rad2Deg * Mathf.Sin(Mathf.Deg2Rad * M) * (1.0f + e * Mathf.Cos(Mathf.Deg2Rad * M));
|
||||
|
||||
float xv = Mathf.Cos(Mathf.Deg2Rad * E) - e;
|
||||
float yv = Mathf.Sin(Mathf.Deg2Rad * E) * Mathf.Sqrt(1 - e * e);
|
||||
|
||||
float v = Mathf.Rad2Deg * Mathf.Atan2(yv, xv);
|
||||
float r = Mathf.Sqrt(xv * xv + yv * yv);
|
||||
|
||||
float l = v + w;
|
||||
|
||||
float xs = r * Mathf.Cos(Mathf.Deg2Rad * l);
|
||||
float ys = r * Mathf.Sin(Mathf.Deg2Rad * l);
|
||||
|
||||
float xe = xs;
|
||||
float ye = ys * Mathf.Cos(Mathf.Deg2Rad * ecl);
|
||||
float ze = ys * Mathf.Sin(Mathf.Deg2Rad * ecl);
|
||||
|
||||
float decl_rad = Mathf.Atan2(ze, Mathf.Sqrt(xe * xe + ye * ye));
|
||||
float decl_sin = Mathf.Sin(decl_rad);
|
||||
float decl_cos = Mathf.Cos(decl_rad);
|
||||
|
||||
float Ls = M + w; // Sun's mean longitude correction
|
||||
|
||||
float GMST0 = (Ls + 180); // same as above
|
||||
float GMST = GMST0 + GetUniversalTimeOfDay() * 15;
|
||||
LST = GMST + Settings.longitude;
|
||||
// LST turn correction (fit to the right ascension of Zenith)
|
||||
while (LST > 360.0f)
|
||||
{
|
||||
LST -= 360.0f;
|
||||
}
|
||||
while (LST < 0.0f)
|
||||
{
|
||||
LST += 360.0f;
|
||||
}
|
||||
|
||||
float HA_deg = LST - Mathf.Rad2Deg * Mathf.Atan2(ye, xe);
|
||||
float HA_rad = Mathf.Deg2Rad * HA_deg;
|
||||
float HA_sin = Mathf.Sin(HA_rad);
|
||||
float HA_cos = Mathf.Cos(HA_rad);
|
||||
|
||||
float x = HA_cos * decl_cos;
|
||||
float y = HA_sin * decl_cos;
|
||||
float z = decl_sin;
|
||||
|
||||
float sin_Lat = Mathf.Sin(Mathf.Deg2Rad * Settings.latitude);
|
||||
float cos_Lat = Mathf.Cos(Mathf.Deg2Rad * Settings.latitude);
|
||||
|
||||
float xhor = x * sin_Lat - z * cos_Lat;
|
||||
float yhor = y;
|
||||
float zhor = x * cos_Lat + z * sin_Lat;
|
||||
|
||||
float azimuth = Mathf.Atan2(yhor, xhor) + Mathf.Deg2Rad * 180;
|
||||
float altitude = Mathf.Atan2(zhor, Mathf.Sqrt(xhor * xhor + yhor * yhor));
|
||||
|
||||
float sunTheta = (90 * Mathf.Deg2Rad) - altitude;
|
||||
float sunPhi = azimuth;
|
||||
|
||||
//Set SolarTime: 1 = mid-day (sun directly above you), 0.5 = sunset/dawn, 0 = midnight;
|
||||
EnviroManager.instance.solarTime = Mathf.Clamp01(Remap(sunTheta, -1.5f, 0f, 1.5f, 1f));
|
||||
|
||||
EnviroManager.instance.Objects.sun.transform.localPosition = OrbitalToLocal(sunTheta, sunPhi);
|
||||
EnviroManager.instance.Objects.sun.transform.LookAt(EnviroManager.instance.transform);
|
||||
|
||||
if (simpleMoon)
|
||||
{
|
||||
EnviroManager.instance.Objects.moon.transform.localPosition = OrbitalToLocal(sunTheta - Mathf.PI, sunPhi);
|
||||
EnviroManager.instance.lunarTime = Mathf.Clamp01(Remap(sunTheta - Mathf.PI, -3.0f, 0f, 0f, 1f));
|
||||
EnviroManager.instance.Objects.moon.transform.LookAt(EnviroManager.instance.transform);
|
||||
}
|
||||
}
|
||||
|
||||
public void CalculateMoonPosition(float d, float ecl)
|
||||
{
|
||||
float N = 125.1228f - 0.0529538083f * d;
|
||||
float i = 5.1454f;
|
||||
float w = 318.0634f + 0.1643573223f * d;
|
||||
float a = 60.2666f;
|
||||
float e = 0.054900f;
|
||||
float M = 115.3654f + 13.0649929509f * d;
|
||||
|
||||
float rad_M = Mathf.Deg2Rad * M;
|
||||
float E = rad_M + e * Mathf.Sin(rad_M) * (1f + e * Mathf.Cos(rad_M));
|
||||
|
||||
float xv = a * (Mathf.Cos(E) - e);
|
||||
float yv = a * (Mathf.Sqrt(1f - e * e) * Mathf.Sin(E));
|
||||
|
||||
float v = Mathf.Rad2Deg * Mathf.Atan2(yv, xv);
|
||||
float r = Mathf.Sqrt(xv * xv + yv * yv);
|
||||
|
||||
float rad_N = Mathf.Deg2Rad * N;
|
||||
float sin_N = Mathf.Sin(rad_N);
|
||||
float cos_N = Mathf.Cos(rad_N);
|
||||
|
||||
float l = Mathf.Deg2Rad * (v + w);
|
||||
float sin_l = Mathf.Sin(l);
|
||||
float cos_l = Mathf.Cos(l);
|
||||
|
||||
float rad_i = Mathf.Deg2Rad * i;
|
||||
float cos_i = Mathf.Cos(rad_i);
|
||||
|
||||
float xh = r * (cos_N * cos_l - sin_N * sin_l * cos_i);
|
||||
float yh = r * (sin_N * cos_l + cos_N * sin_l * cos_i);
|
||||
float zh = r * (sin_l * Mathf.Sin(rad_i));
|
||||
|
||||
float cos_ecl = Mathf.Cos(Mathf.Deg2Rad * ecl);
|
||||
float sin_ecl = Mathf.Sin(Mathf.Deg2Rad * ecl);
|
||||
|
||||
float xe = xh;
|
||||
float ye = yh * cos_ecl - zh * sin_ecl;
|
||||
float ze = yh * sin_ecl + zh * cos_ecl;
|
||||
|
||||
float ra = Mathf.Atan2(ye, xe);
|
||||
float decl = Mathf.Atan2(ze, Mathf.Sqrt(xe * xe + ye * ye));
|
||||
|
||||
float HA = Mathf.Deg2Rad * LST - ra;
|
||||
|
||||
float x = Mathf.Cos(HA) * Mathf.Cos(decl);
|
||||
float y = Mathf.Sin(HA) * Mathf.Cos(decl);
|
||||
float z = Mathf.Sin(decl);
|
||||
|
||||
float latitude = Mathf.Deg2Rad * Settings.latitude;
|
||||
float sin_latitude = Mathf.Sin(latitude);
|
||||
float cos_latitude = Mathf.Cos(latitude);
|
||||
|
||||
float xhor = x * sin_latitude - z * cos_latitude;
|
||||
float yhor = y;
|
||||
float zhor = x * cos_latitude + z * sin_latitude;
|
||||
|
||||
float azimuth = Mathf.Atan2(yhor, xhor) + Mathf.Deg2Rad * 180f;
|
||||
float altitude = Mathf.Atan2(zhor, Mathf.Sqrt(xhor * xhor + yhor * yhor));
|
||||
|
||||
float MoonTheta = (90f * Mathf.Deg2Rad) - altitude;
|
||||
float MoonPhi = azimuth;
|
||||
|
||||
EnviroManager.instance.Objects.moon.transform.localPosition = OrbitalToLocal(MoonTheta, MoonPhi);
|
||||
EnviroManager.instance.lunarTime = Mathf.Clamp01(Remap(MoonTheta, -1.5f, 0f, 1.5f, 1f));
|
||||
|
||||
EnviroManager.instance.Objects.moon.transform.LookAt(EnviroManager.instance.transform.position);
|
||||
}
|
||||
|
||||
public void CalculateStarsPosition(float siderealTime)
|
||||
{
|
||||
// LST was corrected in degrees in Sun position update
|
||||
|
||||
// The transform behaved incorrectly regarding longitude. The 180 degrees is to orientate the stars correctly
|
||||
// with the texture center with Zenith having 0 degrees right ascension towards the vernal equinox around 21 March
|
||||
Quaternion starsRotation = Quaternion.AngleAxis(90.0f - Settings.latitude, Vector3.right) * Quaternion.AngleAxis(180.0f + siderealTime, Vector3.up);
|
||||
EnviroManager.instance.Objects.stars.transform.localRotation = starsRotation;
|
||||
|
||||
Shader.SetGlobalMatrix("_StarsMatrix", EnviroManager.instance.Objects.stars.transform.worldToLocalMatrix);
|
||||
}
|
||||
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroTime>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroTimeModule t = ScriptableObject.CreateInstance<EnviroTimeModule>();
|
||||
t.name = "Time Preset";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroTime>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
public void SaveModuleValues (EnviroTimeModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroTime>(JsonUtility.ToJson(Settings));
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0081d4f9e5d6e0a4d9fe8e7a8d7256b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Time/EnviroTimeModule.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b27a0a884739f9844be0f49fdde0261c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0081d4f9e5d6e0a4d9fe8e7a8d7256b6, type: 3}
|
||||
m_Name: Default Time Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 1
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
Settings:
|
||||
simulate: 0
|
||||
secSerial: 0
|
||||
minSerial: 0
|
||||
hourSerial: 8
|
||||
daySerial: 8
|
||||
monthSerial: 5
|
||||
yearSerial: 2026
|
||||
timeOfDay: 8
|
||||
latitude: 0
|
||||
longitude: 0
|
||||
utcOffset: 0
|
||||
cycleLengthInMinutes: 10
|
||||
dayLengthModifier: 1
|
||||
nightLengthModifier: 1
|
||||
calenderType: 0
|
||||
daysInMonth: 10
|
||||
monthsInYear: 4
|
||||
customSunOffset: -8
|
||||
customSunRotation: 88
|
||||
preset: {fileID: 0}
|
||||
showTimeControls: 1
|
||||
showLocationControls: 0
|
||||
LST: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82acdd278499d74498ad37dd931734d1
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/Time/Preset/Default
|
||||
Time Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6c40d6b4d950e6498ef636b9a13a6d5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cae96c4b3ef46947a21c9615a74e6e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.2.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/VolumetricClouds/EnviroVolumetricCloudsModule.cs
|
||||
uploadId: 766468
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc26d2cbb2e02064287628118fabe2ab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,187 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2cae96c4b3ef46947a21c9615a74e6e4, type: 3}
|
||||
m_Name: Default Volumetric Clouds Preset
|
||||
m_EditorClassIdentifier:
|
||||
showModuleInspector: 0
|
||||
showSaveLoad: 0
|
||||
active: 1
|
||||
settingsVolume:
|
||||
cloudsWindDirectionXModifier: 1
|
||||
cloudsWindDirectionYModifier: 1
|
||||
windSpeedModifier: 0.05
|
||||
windUpwards: 0.025
|
||||
coverage: 0.171
|
||||
worleyFreq2: 48
|
||||
worleyFreq1: 12
|
||||
dilateCoverage: 0.126
|
||||
dilateType: 0.532
|
||||
cloudsTypeModifier: 0.604
|
||||
locationOffset: {x: 0, y: 0}
|
||||
bottomCloudsHeight: 2000
|
||||
topCloudsHeight: 8000
|
||||
density: 1
|
||||
densitySmoothness: 1.1
|
||||
scatteringIntensity: 5.16
|
||||
edgeHighlightStrength: 0
|
||||
silverLiningSpread: 0.15
|
||||
silverLiningIntensity: 0.5
|
||||
directIndirectBalance: 0
|
||||
curlIntensity: 1
|
||||
lightStepModifier: 0.1
|
||||
multiScatterStrength: 0.146
|
||||
multiScatterFalloff: 0.042
|
||||
ambientFloor: 0.129
|
||||
absorbtion: 0.25
|
||||
exposure: 1.119
|
||||
baseNoiseUV: 32
|
||||
detailNoiseUV: 32
|
||||
baseErosionIntensity: 0.102
|
||||
baseNoiseMultiplier: 1.057
|
||||
detailErosionIntensity: 0.15
|
||||
detailNoiseMultiplier: 0.948
|
||||
bottomShape: -0.35
|
||||
midShape: -0.44
|
||||
topShape: -0.43
|
||||
topLayer: 0
|
||||
cloudTypeShaping: 0.162
|
||||
rampShape: 0.405
|
||||
settingsGlobal:
|
||||
floatingPointOriginMod: {x: 0, y: 0, z: 0}
|
||||
sunLightColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0, g: 0, b: 0, a: 1}
|
||||
key2: {r: 0.24528301, g: 0.050489984, b: 0.0034709796, a: 0}
|
||||
key3: {r: 0.91764706, g: 0.78431374, b: 0.6431373, a: 0}
|
||||
key4: {r: 1, g: 0.9771408, b: 0.9575472, a: 0}
|
||||
key5: {r: 1, g: 0.94509804, b: 0.8980392, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29684
|
||||
ctime2: 30840
|
||||
ctime3: 36700
|
||||
ctime4: 65535
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
moonLightColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.009433985, g: 0.009433985, b: 0.009433985, a: 1}
|
||||
key2: {r: 0.19063722, g: 0.21091683, b: 0.26415092, a: 0}
|
||||
key3: {r: 0.066082254, g: 0.07146038, b: 0.084905684, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 27563
|
||||
ctime2: 65342
|
||||
ctime3: 65535
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 3
|
||||
m_NumAlphaKeys: 2
|
||||
ambientColorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key1: {r: 0.009433985, g: 0.009433985, b: 0.009433985, a: 1}
|
||||
key2: {r: 0.13576896, g: 0.1632185, b: 0.254717, a: 0}
|
||||
key3: {r: 0.1759968, g: 0.23233613, b: 0.3301887, a: 0}
|
||||
key4: {r: 0.3484336, g: 0.47746015, b: 0.8490566, a: 0}
|
||||
key5: {r: 0.40258992, g: 0.50222605, b: 0.7830189, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 29900
|
||||
ctime2: 32382
|
||||
ctime3: 35659
|
||||
ctime4: 65535
|
||||
ctime5: 65535
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 5
|
||||
m_NumAlphaKeys: 2
|
||||
sunLightColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
moonLightColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
ambientColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
depthBlending: 1
|
||||
depthTest: 1
|
||||
noise: {fileID: 11700000, guid: 51b453fb41985b54888feaccbd2df6b1, type: 2}
|
||||
detailNoise: {fileID: 11700000, guid: 148dc26686a73e04991a98fc584949f1, type: 2}
|
||||
curlTex: {fileID: 2800000, guid: ffcd1e36f4faf444aa9ea28b24424dd8, type: 3}
|
||||
bottomsOffsetNoise: {fileID: 2800000, guid: 6d1bd41afa691054c8a8f14b15ec608a, type: 3}
|
||||
blueNoise: {fileID: 2800000, guid: 3f714f8f28ab17e499e2e6c690af70cc, type: 3}
|
||||
customWeatherMap: {fileID: 0}
|
||||
cloudsWorldScale: 5000000
|
||||
maxRenderDistance: 70000
|
||||
atmosphereColorSaturateDistance: 15000
|
||||
ambientLighIntensity: 1
|
||||
cloudShadows: 0
|
||||
cloudShadowsIntensity: 2
|
||||
cloudsTravelSpeed: 0.01
|
||||
settingsQuality:
|
||||
volumetricClouds: 1
|
||||
lightningSupport: 1
|
||||
variableBottomNoise: 0
|
||||
downsampling: 4
|
||||
stepsLayer1: 128
|
||||
stepsLayer2: 64
|
||||
blueNoiseIntensity: 1
|
||||
reprojectionBlendTime: 10
|
||||
lodDistance: 0.25
|
||||
preset: {fileID: 0}
|
||||
showGlobalControls: 0
|
||||
showVolumeSettings: 0
|
||||
showCoverageControls: 0
|
||||
showLightingControls: 0
|
||||
showDensityControls: 0
|
||||
showTextureControls: 0
|
||||
showWindControls: 0
|
||||
cloudAnimLayer1: {x: 0, y: 0, z: 0}
|
||||
cloudAnimLayer2: {x: 0, y: 0, z: 0}
|
||||
cloudAnimNonScaledLayer1: {x: 0, y: 0, z: 0}
|
||||
cloudAnimNonScaledLayer2: {x: 0, y: 0, z: 0}
|
||||
weatherMap: {fileID: 0}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b3879673bba3ff488a4b539b4de69b7
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Runtime/Modules/VolumetricClouds/Preset/Default
|
||||
Volumetric Clouds Preset.asset
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fd954e5389df7d4d87cf6919cb44b36
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,597 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[Serializable]
|
||||
public class EnviroWeather
|
||||
{
|
||||
public List<EnviroWeatherType> weatherTypes = new List<EnviroWeatherType>();
|
||||
public float cloudsTransitionSpeed = 1f;
|
||||
public float fogTransitionSpeed = 1f;
|
||||
public float lightingTransitionSpeed = 1f;
|
||||
public float skyTransitionSpeed = 1f;
|
||||
public float effectsTransitionSpeed = 1f;
|
||||
public float auroraTransitionSpeed = 1f;
|
||||
public float environmentTransitionSpeed = 1f;
|
||||
public float audioTransitionSpeed = 1f;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[ExecuteInEditMode]
|
||||
public class EnviroWeatherModule : EnviroModule
|
||||
{
|
||||
public Enviro.EnviroWeather Settings;
|
||||
public EnviroWeatherModule preset;
|
||||
public EnviroWeatherType targetWeatherType;
|
||||
public float weatherBlendProgress = 0f;
|
||||
|
||||
//Zones
|
||||
public bool globalAutoWeatherChange = true;
|
||||
//Trigger
|
||||
public BoxCollider triggerCollider;
|
||||
public Rigidbody triggerRB;
|
||||
|
||||
//UI
|
||||
public bool showWeatherPresetsControls,showTransitionControls,showZoneControls;
|
||||
|
||||
private bool instantTransition = false;
|
||||
|
||||
public override void Enable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
if(targetWeatherType == null && Settings.weatherTypes.Count > 0)
|
||||
targetWeatherType = Settings.weatherTypes[0];
|
||||
|
||||
if(EnviroManager.instance.defaultZone != null)
|
||||
EnviroManager.instance.currentZone = EnviroManager.instance.defaultZone;
|
||||
|
||||
weatherBlendProgress = 1f;
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
public override void Disable ()
|
||||
{
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
private void Setup()
|
||||
{
|
||||
if(EnviroManager.instance.gameObject.GetComponent<BoxCollider>() == null)
|
||||
triggerCollider = EnviroManager.instance.gameObject.AddComponent<BoxCollider>();
|
||||
else
|
||||
triggerCollider = EnviroManager.instance.gameObject.GetComponent<BoxCollider>();
|
||||
|
||||
triggerCollider.isTrigger = true;
|
||||
triggerCollider.size = new Vector3(0.1f,0.1f,0.1f);
|
||||
|
||||
if(EnviroManager.instance.gameObject.GetComponent<Rigidbody>() == null)
|
||||
triggerRB = EnviroManager.instance.gameObject.AddComponent<Rigidbody>();
|
||||
else
|
||||
triggerRB = EnviroManager.instance.gameObject.GetComponent<Rigidbody>();
|
||||
|
||||
triggerRB.isKinematic = true;
|
||||
}
|
||||
|
||||
private void Cleanup()
|
||||
{
|
||||
if(triggerCollider != null)
|
||||
DestroyImmediate(triggerCollider);
|
||||
|
||||
if(triggerRB != null)
|
||||
DestroyImmediate(triggerRB);
|
||||
}
|
||||
|
||||
/// Adds weather type to the list or creates a new one.
|
||||
public void CreateNewWeatherType()
|
||||
{
|
||||
EnviroWeatherType type = EnviroWeatherTypeCreation.CreateMyAsset();
|
||||
Settings.weatherTypes.Add(type);
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Removes the weather type from the list.
|
||||
public void RemoveWeatherType(EnviroWeatherType type)
|
||||
{
|
||||
Settings.weatherTypes.Remove(type);
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
//Cleans the list from null entries.
|
||||
public void CleanupList()
|
||||
{
|
||||
for (int i = 0; i < Settings.weatherTypes.Count; i++)
|
||||
{
|
||||
if(Settings.weatherTypes[i] == null)
|
||||
Settings.weatherTypes.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator InstantTransition()
|
||||
{
|
||||
yield return null;
|
||||
instantTransition = false;
|
||||
}
|
||||
|
||||
// Update Method
|
||||
public override void UpdateModule ()
|
||||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
if(EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
//Instant changes when not playing or instant change is triggered
|
||||
if(!Application.isPlaying || instantTransition)
|
||||
{
|
||||
if(targetWeatherType != null)
|
||||
{
|
||||
BlendVolumetricCloudsOverride(1f);
|
||||
BlendFlatCloudsOverride(1f);
|
||||
BlendLightingOverride(1f);
|
||||
BlendSkyOverride(1f);
|
||||
BlendEffectsOverride(1f);
|
||||
BlendAuroraOverride(1f);
|
||||
BlendFogOverride(1f);
|
||||
BlendAudioOverride(1f);
|
||||
BlendEnvironmentOverride(1f);
|
||||
BlendLightningOverride(1f);
|
||||
}
|
||||
|
||||
if(instantTransition)
|
||||
instantTransition = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(targetWeatherType != null)
|
||||
{
|
||||
BlendVolumetricCloudsOverride(Settings.cloudsTransitionSpeed * Time.deltaTime);
|
||||
BlendFlatCloudsOverride(Settings.cloudsTransitionSpeed * Time.deltaTime);
|
||||
BlendLightingOverride(Settings.lightingTransitionSpeed * Time.deltaTime);
|
||||
BlendSkyOverride(Settings.skyTransitionSpeed * Time.deltaTime);
|
||||
BlendEffectsOverride(Settings.effectsTransitionSpeed * Time.deltaTime);
|
||||
BlendAuroraOverride(Settings.auroraTransitionSpeed * Time.deltaTime);
|
||||
BlendFogOverride(Settings.fogTransitionSpeed * Time.deltaTime);
|
||||
BlendAudioOverride(Settings.audioTransitionSpeed * Time.deltaTime);
|
||||
BlendEnvironmentOverride(Settings.environmentTransitionSpeed * Time.deltaTime);
|
||||
BlendLightningOverride(1f);
|
||||
UpdateWeatherBlendProgress(Settings.cloudsTransitionSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendLightingOverride(float blendTime)
|
||||
{
|
||||
EnviroLightingModule lighting = EnviroManager.instance.Lighting;
|
||||
|
||||
if(lighting != null)
|
||||
{
|
||||
lighting.Settings.directLightIntensityModifier = Mathf.Lerp(lighting.Settings.directLightIntensityModifier, targetWeatherType.lightingOverride.directLightIntensityModifier,blendTime);
|
||||
lighting.Settings.ambientIntensityModifier = Mathf.Lerp(lighting.Settings.ambientIntensityModifier, targetWeatherType.lightingOverride.ambientIntensityModifier,blendTime);
|
||||
lighting.Settings.shadowIntensity = Mathf.Lerp(lighting.Settings.shadowIntensity, targetWeatherType.lightingOverride.shadowIntensity,blendTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendSkyOverride(float blendTime)
|
||||
{
|
||||
EnviroSkyModule sky = EnviroManager.instance.Sky;
|
||||
|
||||
if(sky != null)
|
||||
{
|
||||
sky.Settings.mieScatteringMultiplier = Mathf.Lerp(sky.Settings.mieScatteringMultiplier, targetWeatherType.skyOverride.mieScatteringMultiplier,blendTime);
|
||||
|
||||
sky.Settings.skyColorExponent = Mathf.Lerp(sky.Settings.skyColorExponent, targetWeatherType.skyOverride.skyColorExponent,blendTime);
|
||||
sky.Settings.skyColorTint = Color.Lerp(sky.Settings.skyColorTint, targetWeatherType.skyOverride.skyColorTint,blendTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendFogOverride(float blendTime)
|
||||
{
|
||||
EnviroFogModule fog = EnviroManager.instance.Fog;
|
||||
|
||||
if(fog != null)
|
||||
{
|
||||
fog.Settings.fogDensity = Mathf.Lerp(fog.Settings.fogDensity, targetWeatherType.fogOverride.fogDensity,blendTime);
|
||||
fog.Settings.fogHeightFalloff = Mathf.Lerp(fog.Settings.fogHeightFalloff, targetWeatherType.fogOverride.fogHeightFalloff,blendTime);
|
||||
fog.Settings.fogHeight = Mathf.Lerp(fog.Settings.fogHeight, targetWeatherType.fogOverride.fogHeight,blendTime);
|
||||
|
||||
fog.Settings.fogDensity2 = Mathf.Lerp(fog.Settings.fogDensity2, targetWeatherType.fogOverride.fogDensity2,blendTime);
|
||||
fog.Settings.fogHeightFalloff2 = Mathf.Lerp(fog.Settings.fogHeightFalloff2, targetWeatherType.fogOverride.fogHeightFalloff2,blendTime);
|
||||
fog.Settings.fogHeight2 = Mathf.Lerp(fog.Settings.fogHeight2, targetWeatherType.fogOverride.fogHeight2,blendTime);
|
||||
|
||||
fog.Settings.fogColorBlend = Mathf.Lerp(fog.Settings.fogColorBlend, targetWeatherType.fogOverride.fogColorBlend,blendTime);
|
||||
fog.Settings.fogColorMod = Color.Lerp(fog.Settings.fogColorMod, targetWeatherType.fogOverride.fogColorMod,blendTime);
|
||||
|
||||
fog.Settings.scattering = Mathf.Lerp(fog.Settings.scattering, targetWeatherType.fogOverride.scattering,blendTime);
|
||||
fog.Settings.extinction = Mathf.Lerp(fog.Settings.extinction, targetWeatherType.fogOverride.extinction,blendTime);
|
||||
fog.Settings.anistropy = Mathf.Lerp(fog.Settings.anistropy, targetWeatherType.fogOverride.anistropy,blendTime);
|
||||
|
||||
#if ENVIRO_HDRP
|
||||
fog.Settings.fogAttenuationDistance = Mathf.Lerp(fog.Settings.fogAttenuationDistance, targetWeatherType.fogOverride.fogAttenuationDistance,blendTime);
|
||||
fog.Settings.baseHeight = Mathf.Lerp(fog.Settings.baseHeight, targetWeatherType.fogOverride.baseHeight,blendTime);
|
||||
fog.Settings.maxHeight = Mathf.Lerp(fog.Settings.maxHeight, targetWeatherType.fogOverride.maxHeight,blendTime);
|
||||
|
||||
fog.Settings.ambientDimmer = Mathf.Lerp(fog.Settings.ambientDimmer, targetWeatherType.fogOverride.ambientDimmer,blendTime);
|
||||
fog.Settings.directLightMultiplier = Mathf.Lerp(fog.Settings.directLightMultiplier, targetWeatherType.fogOverride.directLightMultiplier,blendTime);
|
||||
fog.Settings.directLightShadowdimmer = Mathf.Lerp(fog.Settings.ambientDimmer, targetWeatherType.fogOverride.directLightShadowdimmer,blendTime);
|
||||
#endif
|
||||
|
||||
fog.Settings.unityFogDensity = Mathf.Lerp(fog.Settings.unityFogDensity, targetWeatherType.fogOverride.unityFogDensity,blendTime);
|
||||
fog.Settings.unityFogStartDistance = Mathf.Lerp(fog.Settings.unityFogStartDistance, targetWeatherType.fogOverride.unityFogStartDistance,blendTime);
|
||||
fog.Settings.unityFogEndDistance = Mathf.Lerp(fog.Settings.unityFogEndDistance, targetWeatherType.fogOverride.unityFogEndDistance,blendTime);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendEffectsOverride(float blendTime)
|
||||
{
|
||||
EnviroEffectsModule effects = EnviroManager.instance.Effects;
|
||||
|
||||
if(effects != null)
|
||||
{
|
||||
for (int i = 0; i < effects.Settings.effectTypes.Count; i++)
|
||||
{
|
||||
bool hasOverride = false;
|
||||
|
||||
for(int a = 0; a < targetWeatherType.effectsOverride.effectsOverride.Count; a++)
|
||||
{
|
||||
if(effects.Settings.effectTypes[i].name == targetWeatherType.effectsOverride.effectsOverride[a].name)
|
||||
{
|
||||
effects.Settings.effectTypes[i].emissionRate = Mathf.Lerp(effects.Settings.effectTypes[i].emissionRate, targetWeatherType.effectsOverride.effectsOverride[a].emission,blendTime);
|
||||
hasOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasOverride)
|
||||
{
|
||||
effects.Settings.effectTypes[i].emissionRate = Mathf.Lerp(effects.Settings.effectTypes[i].emissionRate, 0f,blendTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendVolumetricCloudsOverride(float blendTime)
|
||||
{
|
||||
EnviroVolumetricCloudsModule clouds = EnviroManager.instance.VolumetricClouds;
|
||||
|
||||
if(clouds != null)
|
||||
{
|
||||
clouds.settingsGlobal.ambientLighIntensity = Mathf.Lerp(clouds.settingsGlobal.ambientLighIntensity, targetWeatherType.cloudsOverride.ambientLightIntensity,blendTime);
|
||||
|
||||
clouds.settingsVolume.coverage = Mathf.Lerp(clouds.settingsVolume.coverage, targetWeatherType.cloudsOverride.coverage,blendTime);
|
||||
clouds.settingsVolume.dilateCoverage = Mathf.Lerp(clouds.settingsVolume.dilateCoverage, targetWeatherType.cloudsOverride.dilateCoverage,blendTime);
|
||||
clouds.settingsVolume.dilateType = Mathf.Lerp(clouds.settingsVolume.dilateType, targetWeatherType.cloudsOverride.dilateType,blendTime);
|
||||
clouds.settingsVolume.cloudsTypeModifier = Mathf.Lerp(clouds.settingsVolume.cloudsTypeModifier, targetWeatherType.cloudsOverride.typeModifier,blendTime);
|
||||
clouds.settingsVolume.cloudTypeShaping = Mathf.Lerp(clouds.settingsVolume.cloudTypeShaping, targetWeatherType.cloudsOverride.cloudTypeShaping,blendTime);
|
||||
clouds.settingsVolume.silverLiningIntensity = Mathf.Lerp(clouds.settingsVolume.silverLiningIntensity, targetWeatherType.cloudsOverride.silverLiningIntensity,blendTime);
|
||||
clouds.settingsVolume.edgeHighlightStrength = Mathf.Lerp(clouds.settingsVolume.edgeHighlightStrength, targetWeatherType.cloudsOverride.edgeHighlightStrength,blendTime);
|
||||
|
||||
|
||||
clouds.settingsVolume.bottomShape = Mathf.Lerp(clouds.settingsVolume.bottomShape, targetWeatherType.cloudsOverride.bottomShape,blendTime);
|
||||
clouds.settingsVolume.midShape = Mathf.Lerp(clouds.settingsVolume.midShape, targetWeatherType.cloudsOverride.midShape,blendTime);
|
||||
clouds.settingsVolume.topShape = Mathf.Lerp(clouds.settingsVolume.topShape, targetWeatherType.cloudsOverride.topShape,blendTime);
|
||||
clouds.settingsVolume.topLayer = Mathf.Lerp(clouds.settingsVolume.topLayer, targetWeatherType.cloudsOverride.topLayer,blendTime);
|
||||
clouds.settingsVolume.rampShape = Mathf.Lerp(clouds.settingsVolume.rampShape, targetWeatherType.cloudsOverride.rampShape,blendTime);
|
||||
|
||||
|
||||
clouds.settingsVolume.scatteringIntensity = Mathf.Lerp(clouds.settingsVolume.scatteringIntensity, targetWeatherType.cloudsOverride.scatteringIntensity,blendTime);
|
||||
clouds.settingsVolume.multiScatterStrength = Mathf.Lerp(clouds.settingsVolume.multiScatterStrength, targetWeatherType.cloudsOverride.multiScatterStrength,blendTime);
|
||||
clouds.settingsVolume.multiScatterFalloff = Mathf.Lerp(clouds.settingsVolume.multiScatterFalloff, targetWeatherType.cloudsOverride.multiScatterFalloff,blendTime);
|
||||
clouds.settingsVolume.ambientFloor = Mathf.Lerp(clouds.settingsVolume.ambientFloor, targetWeatherType.cloudsOverride.ambientFloor,blendTime);
|
||||
clouds.settingsVolume.directIndirectBalance = Mathf.Lerp(clouds.settingsVolume.directIndirectBalance, targetWeatherType.cloudsOverride.directIndirectBalance,blendTime);
|
||||
clouds.settingsVolume.exposure = Mathf.Lerp(clouds.settingsVolume.exposure, targetWeatherType.cloudsOverride.exposure,blendTime);
|
||||
clouds.settingsVolume.silverLiningSpread = Mathf.Lerp(clouds.settingsVolume.silverLiningSpread, targetWeatherType.cloudsOverride.silverLiningSpread,blendTime);
|
||||
clouds.settingsVolume.absorbtion = Mathf.Lerp(clouds.settingsVolume.absorbtion, targetWeatherType.cloudsOverride.ligthAbsorbtion,blendTime);
|
||||
|
||||
clouds.settingsVolume.density = Mathf.Lerp(clouds.settingsVolume.density, targetWeatherType.cloudsOverride.density,blendTime);
|
||||
clouds.settingsVolume.densitySmoothness = Mathf.Lerp(clouds.settingsVolume.densitySmoothness, targetWeatherType.cloudsOverride.densitySmoothness,blendTime);
|
||||
clouds.settingsVolume.baseErosionIntensity = Mathf.Lerp(clouds.settingsVolume.baseErosionIntensity, targetWeatherType.cloudsOverride.baseErosionIntensity,blendTime);
|
||||
clouds.settingsVolume.detailErosionIntensity = Mathf.Lerp(clouds.settingsVolume.detailErosionIntensity, targetWeatherType.cloudsOverride.detailErosionIntensity,blendTime);
|
||||
clouds.settingsVolume.curlIntensity = Mathf.Lerp(clouds.settingsVolume.curlIntensity, targetWeatherType.cloudsOverride.curlIntensity,blendTime);
|
||||
|
||||
clouds.settingsVolume.baseNoiseMultiplier = Mathf.Lerp(clouds.settingsVolume.baseNoiseMultiplier, targetWeatherType.cloudsOverride.baseNoiseMultiplier,blendTime);
|
||||
clouds.settingsVolume.detailNoiseMultiplier = Mathf.Lerp(clouds.settingsVolume.detailNoiseMultiplier, targetWeatherType.cloudsOverride.detailNoiseMultiplier,blendTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendFlatCloudsOverride(float blendTime)
|
||||
{
|
||||
EnviroFlatCloudsModule flatClouds = EnviroManager.instance.FlatClouds;
|
||||
|
||||
if(flatClouds != null)
|
||||
{
|
||||
flatClouds.settings.cirrusCloudsAlpha = Mathf.Lerp(flatClouds.settings.cirrusCloudsAlpha, targetWeatherType.flatCloudsOverride.cirrusCloudsAlpha,blendTime);
|
||||
flatClouds.settings.cirrusCloudsCoverage = Mathf.Lerp(flatClouds.settings.cirrusCloudsCoverage, targetWeatherType.flatCloudsOverride.cirrusCloudsCoverage,blendTime);
|
||||
flatClouds.settings.cirrusCloudsColorPower = Mathf.Lerp(flatClouds.settings.cirrusCloudsColorPower, targetWeatherType.flatCloudsOverride.cirrusCloudsColorPower,blendTime);
|
||||
flatClouds.settings.flatCloudsCoverage = Mathf.Lerp(flatClouds.settings.flatCloudsCoverage, targetWeatherType.flatCloudsOverride.flatCloudsCoverage,blendTime);
|
||||
flatClouds.settings.flatCloudsDensity = Mathf.Lerp(flatClouds.settings.flatCloudsDensity, targetWeatherType.flatCloudsOverride.flatCloudsDensity,blendTime);
|
||||
flatClouds.settings.flatCloudsLightIntensity = Mathf.Lerp(flatClouds.settings.flatCloudsLightIntensity, targetWeatherType.flatCloudsOverride.flatCloudsLightIntensity,blendTime);
|
||||
flatClouds.settings.flatCloudsAmbientIntensity = Mathf.Lerp(flatClouds.settings.flatCloudsAmbientIntensity, targetWeatherType.flatCloudsOverride.flatCloudsAmbientIntensity,blendTime);
|
||||
flatClouds.settings.flatCloudsShadowIntensity = Mathf.Lerp(flatClouds.settings.flatCloudsShadowIntensity, targetWeatherType.flatCloudsOverride.flatCloudsShadowIntensity,blendTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendAuroraOverride(float blendTime)
|
||||
{
|
||||
EnviroAuroraModule aurora = EnviroManager.instance.Aurora;
|
||||
|
||||
if(aurora != null)
|
||||
{
|
||||
aurora.Settings.auroraIntensityModifier = Mathf.Lerp(aurora.Settings.auroraIntensityModifier, targetWeatherType.auroraOverride.auroraIntensity,blendTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendEnvironmentOverride(float blendTime)
|
||||
{
|
||||
EnviroEnvironmentModule environment = EnviroManager.instance.Environment;
|
||||
|
||||
if(environment != null)
|
||||
{
|
||||
environment.Settings.temperatureWeatherMod = Mathf.Lerp(environment.Settings.temperatureWeatherMod, targetWeatherType.environmentOverride.temperatureWeatherMod,blendTime);
|
||||
environment.Settings.wetnessTarget = Mathf.Lerp(environment.Settings.wetnessTarget, targetWeatherType.environmentOverride.wetnessTarget,blendTime);
|
||||
environment.Settings.snowTarget = Mathf.Lerp(environment.Settings.snowTarget, targetWeatherType.environmentOverride.snowTarget,blendTime);
|
||||
|
||||
environment.Settings.windDirectionX = Mathf.Lerp(environment.Settings.windDirectionX, targetWeatherType.environmentOverride.windDirectionX,blendTime);
|
||||
environment.Settings.windDirectionY = Mathf.Lerp(environment.Settings.windDirectionY, targetWeatherType.environmentOverride.windDirectionY,blendTime);
|
||||
environment.Settings.windSpeed = Mathf.Lerp(environment.Settings.windSpeed, targetWeatherType.environmentOverride.windSpeed,blendTime);
|
||||
environment.Settings.windTurbulence = Mathf.Lerp(environment.Settings.windTurbulence, targetWeatherType.environmentOverride.windTurbulence,blendTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void BlendAudioOverride(float blendTime)
|
||||
{
|
||||
EnviroAudioModule audio = EnviroManager.instance.Audio;
|
||||
|
||||
if(audio != null)
|
||||
{
|
||||
for(int i = 0; i < audio.Settings.ambientClips.Count; i++)
|
||||
{
|
||||
bool hasOverride = false;
|
||||
|
||||
for(int a = 0; a < targetWeatherType.audioOverride.ambientOverride.Count; a++)
|
||||
{
|
||||
if(targetWeatherType.audioOverride.ambientOverride[a].name == audio.Settings.ambientClips[i].name)
|
||||
{
|
||||
audio.Settings.ambientClips[i].volume = Mathf.Lerp(audio.Settings.ambientClips[i].volume ,targetWeatherType.audioOverride.ambientOverride[a].volume,blendTime);
|
||||
hasOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasOverride)
|
||||
audio.Settings.ambientClips[i].volume = Mathf.Lerp(audio.Settings.ambientClips[i].volume ,0f,blendTime);
|
||||
}
|
||||
|
||||
for(int i = 0; i < audio.Settings.weatherClips.Count; i++)
|
||||
{
|
||||
bool hasOverride = false;
|
||||
|
||||
for(int a = 0; a < targetWeatherType.audioOverride.weatherOverride.Count; a++)
|
||||
{
|
||||
if(targetWeatherType.audioOverride.weatherOverride[a].name == audio.Settings.weatherClips[i].name)
|
||||
{
|
||||
audio.Settings.weatherClips[i].volume = Mathf.Lerp(audio.Settings.weatherClips[i].volume ,targetWeatherType.audioOverride.weatherOverride[a].volume,blendTime);
|
||||
hasOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasOverride)
|
||||
audio.Settings.weatherClips[i].volume = Mathf.Lerp(audio.Settings.weatherClips[i].volume ,0f,blendTime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void BlendLightningOverride(float blendTime)
|
||||
{
|
||||
EnviroLightningModule lightning = EnviroManager.instance.Lightning;
|
||||
|
||||
if(lightning != null)
|
||||
{
|
||||
lightning.Settings.lightningStorm = targetWeatherType.lightningOverride.lightningStorm;
|
||||
lightning.Settings.randomLightingDelay = Mathf.Lerp(lightning.Settings.randomLightingDelay, targetWeatherType.lightningOverride.randomLightningDelay,blendTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWeatherBlendProgress(float blendTime)
|
||||
{
|
||||
//float currentCov = Math.Abs(EnviroManager.instance.VolumetricClouds.settingsVolume.coverage);
|
||||
//float targetCov = Math.Abs(targetWeatherType.cloudsOverride.coverageLayer1);
|
||||
//weatherBlendProgress = Mathf.Lerp(1f,0f,targetCov - currentCov);
|
||||
weatherBlendProgress = Mathf.Lerp(weatherBlendProgress, 1f,blendTime);
|
||||
weatherBlendProgress = Mathf.Clamp01(weatherBlendProgress);
|
||||
|
||||
if(weatherBlendProgress >= 0.99)
|
||||
weatherBlendProgress = 1f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Changes the Weather to new type.
|
||||
public void ChangeWeather(EnviroWeatherType type)
|
||||
{
|
||||
if(targetWeatherType != type)
|
||||
{
|
||||
EnviroManager.instance.NotifyWeatherChanged(type);
|
||||
EnviroManager.instance.NotifyZoneWeatherChanged(type,null);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.currentZone != null)
|
||||
EnviroManager.instance.currentZone.currentWeatherType = type;
|
||||
|
||||
targetWeatherType = type;
|
||||
weatherBlendProgress = 0f;
|
||||
}
|
||||
public void ChangeWeather(string typeName)
|
||||
{
|
||||
for(int i = 0; i < Settings.weatherTypes.Count; i++)
|
||||
{
|
||||
if(Settings.weatherTypes[i].name == typeName)
|
||||
{
|
||||
if(targetWeatherType != Settings.weatherTypes[i])
|
||||
{
|
||||
EnviroManager.instance.NotifyWeatherChanged(Settings.weatherTypes[i]);
|
||||
EnviroManager.instance.NotifyZoneWeatherChanged(Settings.weatherTypes[i],null);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.currentZone != null)
|
||||
EnviroManager.instance.currentZone.currentWeatherType = Settings.weatherTypes[i];
|
||||
|
||||
targetWeatherType = Settings.weatherTypes[i];
|
||||
weatherBlendProgress = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeWeather(int index)
|
||||
{
|
||||
for(int i = 0; i < Settings.weatherTypes.Count; i++)
|
||||
{
|
||||
if(i == index)
|
||||
{
|
||||
if(targetWeatherType != Settings.weatherTypes[i])
|
||||
{
|
||||
EnviroManager.instance.NotifyWeatherChanged(Settings.weatherTypes[i]);
|
||||
EnviroManager.instance.NotifyZoneWeatherChanged(Settings.weatherTypes[i],null);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.currentZone != null)
|
||||
EnviroManager.instance.currentZone.currentWeatherType = Settings.weatherTypes[i];
|
||||
|
||||
targetWeatherType = Settings.weatherTypes[i];
|
||||
weatherBlendProgress = 0f;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeZoneWeather(int weather, int zone)
|
||||
{
|
||||
if(EnviroManager.instance.zones.Count >= zone && Settings.weatherTypes.Count >= weather)
|
||||
{
|
||||
EnviroManager.instance.zones[zone].currentWeatherType = Settings.weatherTypes[weather];
|
||||
EnviroManager.instance.NotifyZoneWeatherChanged(Settings.weatherTypes[weather],EnviroManager.instance.zones[zone]);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeWeatherInstant(EnviroWeatherType type)
|
||||
{
|
||||
if(targetWeatherType != type)
|
||||
{
|
||||
EnviroManager.instance.NotifyWeatherChanged(type);
|
||||
EnviroManager.instance.NotifyZoneWeatherChanged(type,null);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.currentZone != null)
|
||||
EnviroManager.instance.currentZone.currentWeatherType = type;
|
||||
|
||||
targetWeatherType = type;
|
||||
weatherBlendProgress = 1f;
|
||||
instantTransition = true;
|
||||
}
|
||||
|
||||
public void ChangeWeatherInstant(string typeName)
|
||||
{
|
||||
for(int i = 0; i < Settings.weatherTypes.Count; i++)
|
||||
{
|
||||
if(Settings.weatherTypes[i].name == typeName)
|
||||
{
|
||||
if(targetWeatherType != Settings.weatherTypes[i])
|
||||
{
|
||||
EnviroManager.instance.NotifyWeatherChanged(Settings.weatherTypes[i]);
|
||||
EnviroManager.instance.NotifyZoneWeatherChanged(Settings.weatherTypes[i],null);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.currentZone != null)
|
||||
EnviroManager.instance.currentZone.currentWeatherType = Settings.weatherTypes[i];
|
||||
|
||||
targetWeatherType = Settings.weatherTypes[i];
|
||||
weatherBlendProgress = 1f;
|
||||
instantTransition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeWeatherInstant(int index)
|
||||
{
|
||||
for(int i = 0; i < Settings.weatherTypes.Count; i++)
|
||||
{
|
||||
if(i == index)
|
||||
{
|
||||
if(targetWeatherType != Settings.weatherTypes[i])
|
||||
{
|
||||
EnviroManager.instance.NotifyWeatherChanged(Settings.weatherTypes[i]);
|
||||
EnviroManager.instance.NotifyZoneWeatherChanged(Settings.weatherTypes[i],null);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.currentZone != null)
|
||||
EnviroManager.instance.currentZone.currentWeatherType = Settings.weatherTypes[i];
|
||||
|
||||
targetWeatherType = Settings.weatherTypes[i];
|
||||
weatherBlendProgress = 1f;
|
||||
instantTransition = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterZone(EnviroZone zone)
|
||||
{
|
||||
EnviroManager.instance.zones.Add(zone);
|
||||
}
|
||||
|
||||
public void RemoveZone(EnviroZone zone)
|
||||
{
|
||||
if(EnviroManager.instance.zones.Contains(zone))
|
||||
EnviroManager.instance.zones.Remove(zone);
|
||||
}
|
||||
|
||||
//Save and Load
|
||||
public void LoadModuleValues ()
|
||||
{
|
||||
if(preset != null)
|
||||
{
|
||||
Settings = JsonUtility.FromJson<Enviro.EnviroWeather>(JsonUtility.ToJson(preset.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Please assign a saved module to load from!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveModuleValues ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EnviroWeatherModule t = ScriptableObject.CreateInstance<EnviroWeatherModule>();
|
||||
t.name = "Weather Module";
|
||||
t.Settings = JsonUtility.FromJson<Enviro.EnviroWeather>(JsonUtility.ToJson(Settings));
|
||||
|
||||
string assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(EnviroHelper.assetPath + "/New " + t.name + ".asset");
|
||||
UnityEditor.AssetDatabase.CreateAsset(t, assetPathAndName);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SaveModuleValues (EnviroWeatherModule module)
|
||||
{
|
||||
module.Settings = JsonUtility.FromJson<Enviro.EnviroWeather>(JsonUtility.ToJson(Settings));
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(module);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user