add weather and time
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user