Readd missing import files

This commit is contained in:
Lucien
2026-05-07 10:14:44 +02:00
parent ecb44e63d8
commit cd608d5796
810 changed files with 263144 additions and 1 deletions
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f7375f08cb1248b4fba83d63d26dc771
folderAsset: yes
timeCreated: 1532145389
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,43 @@
using System;
using System.Linq;
using UnityEditor;
[InitializeOnLoad]
sealed class EnviroAddDefineSymbolsHD
{
const string k_Define = "ENVIRO_HD";
static EnviroAddDefineSymbolsHD()
{
var targets = Enum.GetValues(typeof(BuildTargetGroup))
.Cast<BuildTargetGroup>()
.Where(x => x != BuildTargetGroup.Unknown)
.Where(x => !IsObsolete(x));
foreach (var target in targets)
{
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(target).Trim();
var list = defines.Split(';', ' ')
.Where(x => !string.IsNullOrEmpty(x))
.ToList();
if (list.Contains(k_Define))
continue;
list.Add(k_Define);
defines = list.Aggregate((a, b) => a + ";" + b);
PlayerSettings.SetScriptingDefineSymbolsForGroup(target, defines);
}
}
static bool IsObsolete(BuildTargetGroup group)
{
var attrs = typeof(BuildTargetGroup)
.GetField(group.ToString())
.GetCustomAttributes(typeof(ObsoleteAttribute), false);
return attrs != null && attrs.Length > 0;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a350f2c206c86014d9d674c858979412
timeCreated: 1532145482
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4901dbd2b12bde446b399ffe9338826a
timeCreated: 1497912081
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,99 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(EnviroVolumeLight))]
[CanEditMultipleObjects]
public class EnviroVolumeLightEditor : Editor
{
private GUIStyle boxStyle;
private GUIStyle wrapStyle;
private GUIStyle headerStyle;
private EnviroVolumeLight myTarget;
SerializedProperty SampleCount, ScatteringCoef, ExtinctionCoef, Anistropy, Noise, scaleWithTime;
void OnEnable()
{
myTarget = serializedObject.targetObject as EnviroVolumeLight;
SampleCount = serializedObject.FindProperty("SampleCount");
scaleWithTime = serializedObject.FindProperty("scaleWithTime");
ScatteringCoef = serializedObject.FindProperty("ScatteringCoef");
ExtinctionCoef = serializedObject.FindProperty("ExtinctionCoef");
Anistropy = serializedObject.FindProperty("Anistropy");
Noise = serializedObject.FindProperty("Noise");
}
public override void OnInspectorGUI()
{
if (boxStyle == null)
{
boxStyle = new GUIStyle(GUI.skin.box);
boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
boxStyle.fontStyle = FontStyle.Bold;
boxStyle.alignment = TextAnchor.UpperLeft;
}
if (wrapStyle == null)
{
wrapStyle = new GUIStyle(GUI.skin.label);
wrapStyle.fontStyle = FontStyle.Normal;
wrapStyle.wordWrap = true;
}
if (headerStyle == null)
{
headerStyle = new GUIStyle(GUI.skin.label);
headerStyle.fontStyle = FontStyle.Bold;
headerStyle.wordWrap = true;
}
#if UNITY_5_6_OR_NEWER
serializedObject.UpdateIfRequiredOrScript();
#else
serializedObject.UpdateIfDirtyOrScript();
#endif
EditorGUI.BeginChangeCheck();
GUILayout.BeginVertical("Enviro - Volume Light", boxStyle);
GUILayout.Space(20);
EditorGUILayout.LabelField("This component adds volume lighting effects to your scene lights!", wrapStyle);
GUILayout.EndVertical();
if (myTarget != null)
{
if (myTarget.GetComponent<Light>() == null)
{
EditorGUILayout.LabelField("No Light found on this gameobject. Please add Point or Spot Light!", wrapStyle);
}
else if (myTarget.GetComponent<Light>().type == LightType.Directional)
{
GUILayout.BeginVertical("", boxStyle);
EditorGUILayout.LabelField("Please control directional light directly in EnviroSky Manager -> Lighting category!", wrapStyle);
GUILayout.EndVertical();
}
else
{
GUILayout.BeginVertical("Settings", boxStyle);
GUILayout.Space(20);
EditorGUILayout.PropertyField(SampleCount, true, null);
GUILayout.Space(10);
EditorGUILayout.LabelField("Light Settings", headerStyle);
EditorGUILayout.PropertyField(scaleWithTime, true, null);
EditorGUILayout.PropertyField(ScatteringCoef, true, null);
EditorGUILayout.PropertyField(ExtinctionCoef, true, null);
EditorGUILayout.PropertyField(Anistropy, true, null);
GUILayout.Space(10);
EditorGUILayout.PropertyField(Noise, true, null);
GUILayout.EndVertical();
}
}
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8b47cfe7f182c1f49affa6d0967a7234
timeCreated: 1505175887
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a99eb650cb4a5984bbd1dd226dd17d30
timeCreated: 1502205622
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 25662192fc626eb47a5e9eb586e7fd50
timeCreated: 1493723296
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,268 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
[System.Serializable]
public class EnviroVolumeCloudsQualitySettings
{
// Reprojection
public enum ReprojectionPixelSize
{
Off,
Low,
Medium,
High
}
public enum CloudDetailQuality
{
Low,
High
}
[Header("Clouds Height Settings")]
[Tooltip("Clouds start height.")]
public float bottomCloudHeight = 3000f;
[Tooltip("Clouds end height.")]
public float topCloudHeight = 7000f;
[Header("Raymarch Step Settings")]
[Range(32, 256)]
[Tooltip("Number of raymarching samples.")]
public int raymarchSteps = 150;
[Tooltip("Increase performance by using less steps when clouds are hidden by objects.")]
[Range(0.1f, 1f)]
public float stepsInDepthModificator = 0.75f;
[Tooltip("Increase performance by using early exit expensive raymarching. Higher values = more performant but less accurate lighting.")]
[Range(0.0f, 0.5f)]
public float transmissionToExit = 0.05f;
[Range(1, 8)]
[Header("Resolution, Upsample and Reprojection")]
[Tooltip("Downsampling of clouds rendering. 1 = full res, 2 = half Res, ...")]
public int cloudsRenderResolution = 1;
public ReprojectionPixelSize reprojectionPixelSize;
[Header("Clouds Modelling")]
[Tooltip("LOD Distance for using lower res 3d texture for far away clouds. ")]
[Range(0f, 1f)]
public float lodDistance = 0.5f;
[Tooltip("The UV scale of base noise. High Values = Low performance!")]
[Range(2f, 100f)]
public float baseNoiseUV = 20f;
[Tooltip("The UV scale of detail noise. High Values = Low performance!")]
[Range(2f, 100f)]
public float detailNoiseUV = 50f;
[Tooltip("Enable to use a curl noise to further enhance the detail erode.")]
public bool useCurlNoise = false;
[Tooltip("Resolution of Base Noise Texture.")]
public CloudDetailQuality baseQuality;
[Tooltip("Resolution of Detail Noise Texture.")]
public CloudDetailQuality detailQuality;
}
[System.Serializable]
public class EnviroVolumeCloudsQuality : ScriptableObject
{
public EnviroVolumeCloudsQualitySettings qualitySettings;
}
public static class EnviroCloudsQualityCreation
{
#if UNITY_EDITOR
[MenuItem("Assets/Create/Enviro/Volume Clouds Quality")]
public static EnviroVolumeCloudsQuality CreateNewEnviroCloudsQualityPreset()
{
EnviroVolumeCloudsQuality preset = ScriptableObject.CreateInstance<EnviroVolumeCloudsQuality>();
// Create and save the new profile with unique name
string path = "Assets/Enviro - Sky and Weather/Enviro Standard/Profiles/Clouds Quality";
string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath (path + "/New " + "Clouds Quality" + ".asset");
AssetDatabase.CreateAsset (preset, assetPathAndName);
AssetDatabase.SaveAssets ();
AssetDatabase.Refresh();
return preset;
}
#endif
public static GameObject GetAssetPrefab(string name)
{
#if UNITY_EDITOR
string[] assets = AssetDatabase.FindAssets(name, null);
for (int idx = 0; idx < assets.Length; idx++)
{
string path = AssetDatabase.GUIDToAssetPath(assets[idx]);
if (path.Contains(".prefab"))
{
return AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
}
#endif
return null;
}
public static AudioClip GetAudioClip(string name)
{
#if UNITY_EDITOR
string[] assets = AssetDatabase.FindAssets(name, null);
for (int idx = 0; idx < assets.Length; idx++)
{
string path = AssetDatabase.GUIDToAssetPath(assets[idx]);
if (path.Contains(".wav"))
{
return AssetDatabase.LoadAssetAtPath<AudioClip>(path);
}
}
#endif
return null;
}
public static Cubemap GetAssetCubemap(string name)
{
#if UNITY_EDITOR
string[] assets = AssetDatabase.FindAssets(name, null);
for (int idx = 0; idx < assets.Length; idx++)
{
string path = AssetDatabase.GUIDToAssetPath(assets[idx]);
if (path.Contains(".png"))
{
return AssetDatabase.LoadAssetAtPath<Cubemap>(path);
}
else if (path.Contains(".jpg"))
{
return AssetDatabase.LoadAssetAtPath<Cubemap>(path);
}
}
#endif
return null;
}
public static EnviroProfile GetDefaultProfile(string name)
{
#if UNITY_EDITOR
string[] assets = AssetDatabase.FindAssets(name, null);
for (int idx = 0; idx < assets.Length; idx++)
{
string path = AssetDatabase.GUIDToAssetPath(assets[idx]);
if (path.Contains(".asset"))
{
return AssetDatabase.LoadAssetAtPath<EnviroProfile>(path);
}
}
#endif
return null;
}
public static Texture GetAssetTexture(string name)
{
#if UNITY_EDITOR
string[] assets = AssetDatabase.FindAssets(name, null);
for (int idx = 0; idx < assets.Length; idx++)
{
string path = AssetDatabase.GUIDToAssetPath(assets[idx]);
if (path.Length > 0)
{
return AssetDatabase.LoadAssetAtPath<Texture>(path);
}
}
#endif
return null;
}
public static Gradient CreateGradient(Color clr1, float time1, Color clr2, float time2)
{
Gradient nG = new Gradient ();
GradientColorKey[] gClr = new GradientColorKey[2];
GradientAlphaKey[] gAlpha = new GradientAlphaKey[2];
gClr [0].color = clr1;
gClr [0].time = time1;
gClr [1].color = clr2;
gClr [1].time = time2;
gAlpha [0].alpha = 1f;
gAlpha [0].time = 0f;
gAlpha [1].alpha = 1f;
gAlpha [1].time = 1f;
nG.SetKeys (gClr, gAlpha);
return nG;
}
public static Gradient CreateGradient(List<Color> clrs,List<float>times)
{
Gradient nG = new Gradient ();
GradientColorKey[] gClr = new GradientColorKey[clrs.Count];
GradientAlphaKey[] gAlpha = new GradientAlphaKey[2];
for (int i = 0; i < clrs.Count; i++) {
gClr [i].color = clrs [i];
gClr [i].time = times[i];
}
gAlpha [0].alpha = 1f;
gAlpha [0].time = 0f;
gAlpha [1].alpha = 1f;
gAlpha [1].time = 1f;
nG.SetKeys (gClr, gAlpha);
return nG;
}
public static Gradient CreateGradient(List<Color> clrs, List<float> times, List<float> alpha, List<float> timesAlpha)
{
Gradient nG = new Gradient();
GradientColorKey[] gClr = new GradientColorKey[clrs.Count];
GradientAlphaKey[] gAlpha = new GradientAlphaKey[alpha.Count];
for (int i = 0; i < clrs.Count; i++)
{
gClr[i].color = clrs[i];
gClr[i].time = times[i];
}
for (int i = 0; i < alpha.Count; i++)
{
gAlpha[i].alpha = alpha[i];
gAlpha[i].time = timesAlpha[i];
}
nG.SetKeys(gClr, gAlpha);
return nG;
}
public static Color GetColor (string hex)
{
Color clr = new Color ();
ColorUtility.TryParseHtmlString (hex, out clr);
return clr;
}
public static Keyframe CreateKey (float value, float time)
{
Keyframe k = new Keyframe();
k.value = value;
k.time = time;
return k;
}
public static Keyframe CreateKey (float value, float time, float inTangent, float outTangent)
{
Keyframe k = new Keyframe();
k.value = value;
k.time = time;
k.inTangent = inTangent;
k.outTangent = outTangent;
return k;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 45059fbebc46ffa4c8c6354982415231
timeCreated: 1497829795
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,634 @@
// Copyright(c) 2016, Michal Skalsky, (Modified for use in Enviro - Sky and Weather)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Rendering;
using System;
[AddComponentMenu("Enviro/Volume Light")]
[RequireComponent(typeof(Light))]
[ExecuteInEditMode]
public class EnviroVolumeLight : MonoBehaviour
{
#if ENVIRO_HD
public event Action<EnviroSkyRendering, EnviroVolumeLight, CommandBuffer, Matrix4x4> CustomRenderEvent;
private Light _light;
public Material _material;
public Shader volumeLightShader;
public Shader volumeLightBlurShader;
private CommandBuffer _commandBuffer;
private CommandBuffer _cascadeShadowCommandBuffer;
public RenderTexture temp;
//[Header("Quality")]
[Range(1, 64)]
public int SampleCount = 8;
//[Header("Light Settings")]
public bool scaleWithTime = true;
[Range(0.0f, 1.0f)]
public float ScatteringCoef = 0.5f;
[Range(0.0f, 0.1f)]
public float ExtinctionCoef = 0.01f;
[Range(0.0f, 0.999f)]
public float Anistropy = 0.1f;
[Header("3D Noise")]
public bool Noise = false;
[HideInInspector]
public float NoiseScale = 0.015f;
[HideInInspector]
public float NoiseIntensity = 1.0f;
[HideInInspector]
public float NoiseIntensityOffset = 0.3f;
[HideInInspector]
public Vector2 NoiseVelocity = new Vector2(3.0f, 3.0f);
public Light Light { get { return _light; } }
public Material VolumetricMaterial { get { return _material; } }
private bool _reversedZ = false;
/// <summary>
///
/// </summary>
void Start()
{
#if UNITY_5_5_OR_NEWER
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12 ||
SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal || SystemInfo.graphicsDeviceType == GraphicsDeviceType.PlayStation4 ||
SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan || SystemInfo.graphicsDeviceType == GraphicsDeviceType.XboxOne)
{
_reversedZ = true;
}
#endif
#if UNITY_2017_3_OR_NEWER
//
#else
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D9)
{
this.enabled = false;
return;
}
#endif
}
/// <summary>
///
/// </summary>
void OnEnable()
{
#if ENVIRO_LW
if (EnviroSkyMgr.instance != null && EnviroSkyMgr.instance.currentEnviroSkyVersion == EnviroSkyMgr.EnviroSkyVersion.LW)
{
this.enabled = false;
return;
}
#endif
#if ENVIRO_HDRP || ENVIRO_LWRP
this.enabled = false;
return;
#endif
_commandBuffer = new CommandBuffer();
_commandBuffer.name = "Light Command Buffer";
_cascadeShadowCommandBuffer = new CommandBuffer();
_cascadeShadowCommandBuffer.name = "Dir Light Command Buffer";
_cascadeShadowCommandBuffer.SetGlobalTexture("_CascadeShadowMapTexture", new UnityEngine.Rendering.RenderTargetIdentifier(UnityEngine.Rendering.BuiltinRenderTextureType.CurrentActive));
_light = GetComponent<Light>();
if (_light.type == LightType.Directional)
{
_light.AddCommandBuffer(LightEvent.BeforeScreenspaceMask, _commandBuffer);
_light.AddCommandBuffer(LightEvent.AfterShadowMap, _cascadeShadowCommandBuffer);
}
else
{
_light.AddCommandBuffer(LightEvent.AfterShadowMap, _commandBuffer);
}
if (volumeLightShader == null)
volumeLightShader = Shader.Find("Enviro/Standard/VolumeLight");
if (volumeLightShader == null)
throw new Exception("Critical Error: \"Enviro/VolumeLight\" shader is missing.");
if (_light.type != LightType.Directional)
{
_material = new Material(volumeLightShader);
}
EnviroSkyRendering.PreRenderEvent += VolumetricLightRenderer_PreRenderEvent;
}
/// <summary>
///
/// </summary>
void OnDisable()
{
if (_light != null && _commandBuffer != null)
{
if (_light.type == LightType.Directional)
{
_light.RemoveCommandBuffer(LightEvent.BeforeScreenspaceMask, _commandBuffer);
_light.RemoveCommandBuffer(LightEvent.AfterShadowMap, _cascadeShadowCommandBuffer);
}
else
{
_light.RemoveCommandBuffer(LightEvent.AfterShadowMap, _commandBuffer);
}
}
EnviroSkyRendering.PreRenderEvent -= VolumetricLightRenderer_PreRenderEvent;
}
/// <summary>
///
/// </summary>
public void OnDestroy()
{
DestroyImmediate(_material);
}
/// <summary>
///
/// </summary>
/// <param name="renderer"></param>
/// <param name="viewProj"></param>
private void VolumetricLightRenderer_PreRenderEvent(EnviroSkyRendering renderer, Matrix4x4 viewProj, Matrix4x4 viewProjSP)
{
if (EnviroSky.instance == null)
return;
// light was destroyed without deregistring, deregister now
if (_light == null || _light.gameObject == null)
{
EnviroSkyRendering.PreRenderEvent -= VolumetricLightRenderer_PreRenderEvent;
return;
}
if (!_light.gameObject.activeInHierarchy || _light.enabled == false)
return;
if (_material == null)
_material = new Material(volumeLightShader);
_material.SetVector("_CameraForward", Camera.current.transform.forward);
_material.SetInt("_SampleCount", SampleCount);
_material.SetVector("_NoiseVelocity", new Vector4(EnviroSky.instance.volumeLightSettings.noiseVelocity.x, EnviroSky.instance.volumeLightSettings.noiseVelocity.y) * EnviroSky.instance.volumeLightSettings.noiseScale);
_material.SetVector("_NoiseData", new Vector4(EnviroSky.instance.volumeLightSettings.noiseScale, EnviroSky.instance.volumeLightSettings.noiseIntensity, EnviroSky.instance.volumeLightSettings.noiseIntensityOffset));
_material.SetVector("_MieG", new Vector4(1 - (Anistropy * Anistropy), 1 + (Anistropy * Anistropy), 2 * Anistropy, 1.0f / (4.0f * Mathf.PI)));
float scatter = ScatteringCoef;
if (scaleWithTime)
scatter = ScatteringCoef * (1 - EnviroSky.instance.GameTime.solarTime);
_material.SetVector("_VolumetricLight", new Vector4(scatter, ExtinctionCoef, _light.range, 1.0f));// - SkyboxExtinctionCoef));
_material.SetTexture("_CameraDepthTexture", renderer.GetVolumeLightDepthBuffer());
_material.SetFloat("_ZTest", (int)UnityEngine.Rendering.CompareFunction.Always);
if (_light.type == LightType.Point)
{
SetupPointLight(renderer, viewProj, viewProjSP);
}
else if (_light.type == LightType.Spot)
{
SetupSpotLight(renderer, viewProj, viewProjSP);
}
}
/// <summary>
///
/// </summary>
/// <param name="renderer"></param>
/// <param name="viewProj"></param>
private void SetupPointLight(EnviroSkyRendering renderer, Matrix4x4 viewProj, Matrix4x4 viewProjSP)
{
_commandBuffer.Clear();
int pass = 0;
if (!IsCameraInPointLightBounds())
pass = 2;
_material.SetPass(pass);
Mesh mesh = EnviroSkyRendering.GetPointLightMesh();
float scale = _light.range * 2.0f;
Matrix4x4 world = Matrix4x4.TRS(transform.position, _light.transform.rotation, new Vector3(scale, scale, scale));
_material.SetMatrix("_WorldViewProj", viewProj * world);
_material.SetMatrix("_WorldViewProj_SP", viewProjSP * world);
if (Noise)
_material.EnableKeyword("NOISE");
else
_material.DisableKeyword("NOISE");
_material.SetVector("_LightPos", new Vector4(_light.transform.position.x, _light.transform.position.y, _light.transform.position.z, 1.0f / (_light.range * _light.range)));
_material.SetColor("_LightColor", _light.color * _light.intensity);
if (_light.cookie == null)
{
_material.EnableKeyword("POINT");
_material.DisableKeyword("POINT_COOKIE");
}
else
{
Matrix4x4 view = Matrix4x4.TRS(_light.transform.position, _light.transform.rotation, Vector3.one).inverse;
_material.SetMatrix("_MyLightMatrix0", view);
_material.EnableKeyword("POINT_COOKIE");
_material.DisableKeyword("POINT");
_material.SetTexture("_LightTexture0", _light.cookie);
}
bool forceShadowsOff = false;
if ((_light.transform.position - EnviroSky.instance.PlayerCamera.transform.position).magnitude >= QualitySettings.shadowDistance)
forceShadowsOff = true;
if (_light.shadows != LightShadows.None && forceShadowsOff == false)
{
#if UNITY_2018_1_OR_NEWER
if (UnityEngine.XR.XRSettings.enabled)
{
#else
if (UnityEngine.VR.VRSettings.enabled)
{
#endif
if (EnviroSky.instance.singlePassVR)
{
_material.EnableKeyword("SHADOWS_CUBE");
_commandBuffer.SetGlobalTexture("_ShadowMapTexture", BuiltinRenderTextureType.CurrentActive);
_commandBuffer.SetRenderTarget(renderer.GetVolumeLightBuffer());
_commandBuffer.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, _commandBuffer, viewProj);
}
else
{
/* _commandBuffer.SetShadowSamplingMode (BuiltinRenderTextureType.CurrentActive, ShadowSamplingMode.CompareDepths);
_commandBuffer.Blit (BuiltinRenderTextureType.CurrentActive,new RenderTargetIdentifier(temp));
renderer._afterLightPass.Clear ();
renderer._afterLightPass.SetGlobalTexture ("_ShadowMapTexture", temp);
_material.SetTexture ("_ShadowMapTexture", temp);
renderer._afterLightPass.SetRenderTarget (renderer.GetVolumeLightBuffer ());
renderer._afterLightPass.DrawMesh (mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent (renderer, this, _commandBuffer, viewProj);*/
_material.DisableKeyword("SHADOWS_CUBE");
renderer.GlobalCommandBuffer.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, renderer.GlobalCommandBuffer, viewProj);
}
}
else
{
_material.EnableKeyword("SHADOWS_CUBE");
_commandBuffer.SetGlobalTexture("_ShadowMapTexture", BuiltinRenderTextureType.CurrentActive);
_commandBuffer.SetRenderTarget(renderer.GetVolumeLightBuffer());
_commandBuffer.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, _commandBuffer, viewProj);
}
}
else
{
_material.DisableKeyword("SHADOWS_DEPTH");
if (EnviroSky.instance.PlayerCamera.actualRenderingPath == RenderingPath.Forward)
{
//renderer.GlobalCommandBufferForward.Clear ();
renderer.GlobalCommandBufferForward.SetRenderTarget(renderer.GetVolumeLightBuffer());
renderer.GlobalCommandBufferForward.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, renderer.GlobalCommandBufferForward, viewProj);
}
else
{
renderer.GlobalCommandBuffer.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, renderer.GlobalCommandBuffer, viewProj);
}
}
}
/// <summary>
///
/// </summary>
/// <param name="renderer"></param>
/// <param name="viewProj"></param>
private void SetupSpotLight(EnviroSkyRendering renderer, Matrix4x4 viewProj, Matrix4x4 viewProjSP)
{
_commandBuffer.Clear();
int pass = 1;
if (!IsCameraInSpotLightBounds())
{
pass = 3;
}
Mesh mesh = EnviroSkyRendering.GetSpotLightMesh();
float scale = _light.range;
float angleScale = Mathf.Tan((_light.spotAngle + 1) * 0.5f * Mathf.Deg2Rad) * _light.range;
Matrix4x4 world = Matrix4x4.TRS(transform.position, transform.rotation, new Vector3(angleScale, angleScale, scale));
Matrix4x4 view = Matrix4x4.TRS(_light.transform.position, _light.transform.rotation, Vector3.one).inverse;
Matrix4x4 clip = Matrix4x4.TRS(new Vector3(0.5f, 0.5f, 0.0f), Quaternion.identity, new Vector3(-0.5f, -0.5f, 1.0f));
Matrix4x4 proj = Matrix4x4.Perspective(_light.spotAngle, 1, 0, 1);
_material.SetMatrix("_MyLightMatrix0", clip * proj * view);
_material.SetMatrix("_WorldViewProj", viewProj * world);
_material.SetMatrix("_WorldViewProj_SP", viewProjSP * world);
_material.SetVector("_LightPos", new Vector4(_light.transform.position.x, _light.transform.position.y, _light.transform.position.z, 1.0f / (_light.range * _light.range)));
_material.SetVector("_LightColor", _light.color * _light.intensity);
Vector3 apex = transform.position;
Vector3 axis = transform.forward;
// plane equation ax + by + cz + d = 0; precompute d here to lighten the shader
Vector3 center = apex + axis * _light.range;
float d = -Vector3.Dot(center, axis);
// update material
_material.SetFloat("_PlaneD", d);
_material.SetFloat("_CosAngle", Mathf.Cos((_light.spotAngle + 1) * 0.5f * Mathf.Deg2Rad));
_material.SetVector("_ConeApex", new Vector4(apex.x, apex.y, apex.z));
_material.SetVector("_ConeAxis", new Vector4(axis.x, axis.y, axis.z));
_material.EnableKeyword("SPOT");
if (Noise)
_material.EnableKeyword("NOISE");
else
_material.DisableKeyword("NOISE");
if (_light.cookie == null)
{
_material.SetTexture("_LightTexture0", EnviroSkyRendering.GetDefaultSpotCookie());
}
else
{
_material.SetTexture("_LightTexture0", _light.cookie);
}
bool forceShadowsOff = false;
if ((_light.transform.position - EnviroSky.instance.PlayerCamera.transform.position).magnitude >= QualitySettings.shadowDistance)
forceShadowsOff = true;
if (_light.shadows != LightShadows.None && forceShadowsOff == false)
{
#if UNITY_2018_1_OR_NEWER
if (UnityEngine.XR.XRSettings.enabled)
{
#else
if (UnityEngine.VR.VRSettings.enabled)
{
#endif
if (EnviroSky.instance.singlePassVR)
{
clip = Matrix4x4.TRS(new Vector3(0.5f, 0.5f, 0.5f), Quaternion.identity, new Vector3(0.5f, 0.5f, 0.5f));
if (_reversedZ)
proj = Matrix4x4.Perspective(_light.spotAngle, 1, _light.range, _light.shadowNearPlane);
else
proj = Matrix4x4.Perspective(_light.spotAngle, 1, _light.shadowNearPlane, _light.range);
Matrix4x4 m = clip * proj;
m[0, 2] *= -1;
m[1, 2] *= -1;
m[2, 2] *= -1;
m[3, 2] *= -1;
//view = _light.transform.worldToLocalMatrix;
_material.SetMatrix("_MyWorld2Shadow", m * view);
_material.SetMatrix("_WorldView", m * view);
_material.EnableKeyword("SHADOWS_DEPTH");
_commandBuffer.SetGlobalTexture("_ShadowMapTexture", BuiltinRenderTextureType.CurrentActive);
_commandBuffer.SetRenderTarget(renderer.GetVolumeLightBuffer());
_commandBuffer.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, _commandBuffer, viewProj);
}
else
{
_material.DisableKeyword("SHADOWS_DEPTH");
renderer.GlobalCommandBuffer.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, renderer.GlobalCommandBuffer, viewProj);
}
}
else
{
clip = Matrix4x4.TRS(new Vector3(0.5f, 0.5f, 0.5f), Quaternion.identity, new Vector3(0.5f, 0.5f, 0.5f));
if (_reversedZ)
proj = Matrix4x4.Perspective(_light.spotAngle, 1, _light.range, _light.shadowNearPlane);
else
proj = Matrix4x4.Perspective(_light.spotAngle, 1, _light.shadowNearPlane, _light.range);
Matrix4x4 m = clip * proj;
m[0, 2] *= -1;
m[1, 2] *= -1;
m[2, 2] *= -1;
m[3, 2] *= -1;
//view = _light.transform.worldToLocalMatrix;
_material.SetMatrix("_MyWorld2Shadow", m * view);
_material.SetMatrix("_WorldView", m * view);
_material.EnableKeyword("SHADOWS_DEPTH");
// _commandBuffer.SetShadowSamplingMode(BuiltinRenderTextureType.CurrentActive, ShadowSamplingMode.CompareDepths);
_commandBuffer.SetGlobalTexture("_ShadowMapTexture", BuiltinRenderTextureType.CurrentActive);
_commandBuffer.SetRenderTarget(renderer.GetVolumeLightBuffer());
_commandBuffer.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, _commandBuffer, viewProj);
}
}
else
{
_material.DisableKeyword("SHADOWS_DEPTH");
if (EnviroSky.instance.PlayerCamera.actualRenderingPath == RenderingPath.Forward)
{
//renderer.GlobalCommandBufferForward.Clear ();
renderer.GlobalCommandBufferForward.SetRenderTarget(renderer.GetVolumeLightBuffer());
renderer.GlobalCommandBufferForward.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, renderer.GlobalCommandBufferForward, viewProj);
}
else
{
renderer.GlobalCommandBuffer.DrawMesh(mesh, world, _material, 0, pass);
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, renderer.GlobalCommandBuffer, viewProj);
}
}
}
/// <summary>
///
/// </summary>
/// <param name="renderer"></param>
/// <param name="viewProj"></param>
/*private void SetupDirectionalLight(EnviroVolumetricRenderer renderer, Matrix4x4 viewProj,Matrix4x4 viewProjSP)
{
_commandBuffer.Clear();
int pass = 4;
_material.SetPass(pass);
if (Noise)
_material.EnableKeyword("NOISE");
else
_material.DisableKeyword("NOISE");
_material.SetVector("_LightDir", new Vector4(_light.transform.forward.x, _light.transform.forward.y, _light.transform.forward.z, 1.0f / (_light.range * _light.range)));
_material.SetVector("_LightColor", _light.color * _light.intensity);
_material.SetFloat("_MaxRayLength", MaxRayLength);
if (_light.cookie == null)
{
_material.EnableKeyword("DIRECTIONAL");
_material.DisableKeyword("DIRECTIONAL_COOKIE");
}
else
{
_material.EnableKeyword("DIRECTIONAL_COOKIE");
_material.DisableKeyword("DIRECTIONAL");
_material.SetTexture("_LightTexture0", _light.cookie);
}
//bottom left
_frustumCorners[0] = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, Camera.main.farClipPlane));
// top left
_frustumCorners[2] = Camera.main.ViewportToWorldPoint(new Vector3(0, 1, Camera.main.farClipPlane));
// top right
_frustumCorners[3] = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, Camera.main.farClipPlane));
// bottom right
_frustumCorners[1] = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, Camera.main.farClipPlane));
_material.SetVectorArray("_FrustumCorners", _frustumCorners);
//_material.SetVectorArray("_FrustumCornersRight", _frustumCornersRight);
//_material.SetVectorArray("_FrustumCornersLeft", _frustumCornersLeft);
Texture nullTexture = null;
if (_light.shadows != LightShadows.None)
{
_material.EnableKeyword("SHADOWS_DEPTH");
//CustomGraphicsBlit (renderer.GetVolumeLightBuffer(), _material, pass);
_commandBuffer.Blit(BuiltinRenderTextureType.CurrentActive, renderer.GetVolumeLightBuffer());
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, _commandBuffer, viewProj);
}
else
{
_material.DisableKeyword("SHADOWS_DEPTH");
//CustomGraphicsBlit (renderer.GetVolumeLightBuffer(), _material, pass);
renderer.GlobalCommandBuffer.Blit(BuiltinRenderTextureType.CurrentActive, renderer.GetVolumeLightBuffer());
if (CustomRenderEvent != null)
CustomRenderEvent(renderer, this, renderer.GlobalCommandBuffer, viewProj);
}
}
*/
/// <summary>
///
/// </summary>
/// <returns></returns>
private bool IsCameraInPointLightBounds()
{
float distanceSqr = (_light.transform.position - EnviroSky.instance.PlayerCamera.transform.position).sqrMagnitude;
float extendedRange = _light.range + 1;
if (distanceSqr < (extendedRange * extendedRange))
return true;
return false;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
private bool IsCameraInSpotLightBounds()
{
// check range
float distance = Vector3.Dot(_light.transform.forward, (Camera.current.transform.position - _light.transform.position));
float extendedRange = _light.range + 1;
if (distance > (extendedRange))
return false;
// check angle
float cosAngle = Vector3.Dot(transform.forward, (Camera.current.transform.position - _light.transform.position).normalized);
if ((Mathf.Acos(cosAngle) * Mathf.Rad2Deg) > (_light.spotAngle + 3) * 0.5f)
return false;
return true;
}
#endif
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5c7457fc8c1b79f46b31cdd5ad46bfaf
timeCreated: 1459178235
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f2fe76d290f57ea42ba0dd4d753b4194
folderAsset: yes
timeCreated: 1535724145
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,232 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
[AddComponentMenu("Enviro/Standard/AddionalCamera")]
public class EnviroAdditionalCamera : MonoBehaviour {
#if ENVIRO_HD
public bool addEnviroSkyRendering = true;
public bool addEnviroSkyPostProcessing = true;
public bool addWeatherEffects = true;
private Camera myCam;
private EnviroSkyRendering skyRender;
private EnviroPostProcessing enviroPostProcessing;
private GameObject EffectHolder;
private GameObject VFX;
private List<EnviroWeatherPrefab> zoneWeather = new List<EnviroWeatherPrefab>();
private EnviroWeatherPrefab currentWeather;
private void OnEnable()
{
myCam = GetComponent<Camera>();
if (myCam != null)
InitImageEffects();
}
private void Start()
{
if (addWeatherEffects)
{
CreateEffectHolder();
StartCoroutine(SetupWeatherEffects());
}
}
void Update ()
{
if (addWeatherEffects)
UpdateWeatherEffects();
}
private void CreateEffectHolder ()
{
int childs = myCam.transform.childCount;
for (int i = childs - 1; i >= 0; i--)
{
if(myCam.transform.GetChild(i).gameObject.name == "Effect Holder")
DestroyImmediate(myCam.transform.GetChild(i).gameObject);
}
EffectHolder = new GameObject();
EffectHolder.name = "Effect Holder";
EffectHolder.transform.SetParent(myCam.transform,false);
VFX = new GameObject();
VFX.name = "VFX";
VFX.transform.SetParent(EffectHolder.transform, false);
}
IEnumerator SetupWeatherEffects()
{
yield return new WaitForSeconds(1f);
for (int i = 0; i < EnviroSky.instance.Weather.weatherPresets.Count; i++)
{
//Create Weather Prefab
GameObject wPrefab = new GameObject();
EnviroWeatherPrefab wP = wPrefab.AddComponent<EnviroWeatherPrefab>();
wP.weatherPreset = EnviroSky.instance.Weather.weatherPresets[i];
wPrefab.name = wP.weatherPreset.Name;
//Add Particle Effects
for (int w = 0; w < wP.weatherPreset.effectSystems.Count; w++)
{
if (wP.weatherPreset.effectSystems[w] == null || wP.weatherPreset.effectSystems[w].prefab == null)
{
Debug.Log("Warning! Missing Particle System Entry: " + wP.weatherPreset.Name);
Destroy(wPrefab);
break;
}
GameObject eS = (GameObject)Instantiate(wP.weatherPreset.effectSystems[w].prefab, wPrefab.transform);
eS.transform.localPosition = wP.weatherPreset.effectSystems[w].localPositionOffset;
eS.transform.localEulerAngles = wP.weatherPreset.effectSystems[w].localRotationOffset;
ParticleSystem pS = eS.GetComponent<ParticleSystem>();
if (pS != null)
wP.effectSystems.Add(pS);
else
{
pS = eS.GetComponentInChildren<ParticleSystem>();
if (pS != null)
wP.effectSystems.Add(pS);
else
{
Debug.Log("No Particle System found in prefab in weather preset: " + wP.weatherPreset.Name);
Destroy(wPrefab);
break;
}
}
}
wP.effectEmmisionRates.Clear();
wPrefab.transform.parent = VFX.transform;
wPrefab.transform.localPosition = Vector3.zero;
wPrefab.transform.localRotation = Quaternion.identity;
zoneWeather.Add(wP);
}
// Setup Particle Systems Emission Rates
for (int i = 0; i < zoneWeather.Count; i++)
{
for (int i2 = 0; i2 < zoneWeather[i].effectSystems.Count; i2++)
{
zoneWeather[i].effectEmmisionRates.Add(EnviroSkyMgr.instance.GetEmissionRate(zoneWeather[i].effectSystems[i2]));
EnviroSkyMgr.instance.SetEmissionRate(zoneWeather[i].effectSystems[i2], 0f);
}
}
//Set Current Weather
if (EnviroSky.instance.Weather.currentActiveWeatherPrefab != null)
{
for (int i = 0; i < zoneWeather.Count; i++)
{
if (zoneWeather[i].weatherPreset == EnviroSky.instance.Weather.currentActiveWeatherPrefab.weatherPreset)
currentWeather = zoneWeather[i];
}
}
}
private void UpdateWeatherEffects()
{
if (EnviroSky.instance.Weather.currentActiveWeatherPrefab == null || currentWeather == null)
return;
if(EnviroSky.instance.Weather.currentActiveWeatherPrefab.weatherPreset != currentWeather.weatherPreset)
{
for(int i = 0; i < zoneWeather.Count; i++)
{
if (zoneWeather[i].weatherPreset == EnviroSky.instance.Weather.currentActiveWeatherPrefab.weatherPreset)
currentWeather = zoneWeather[i];
}
}
UpdateEffectSystems(currentWeather, true);
}
private void UpdateEffectSystems(EnviroWeatherPrefab id, bool withTransition)
{
if (id != null)
{
float speed = 500f * Time.deltaTime;
if (withTransition)
speed = EnviroSkyMgr.instance.WeatherSettings.effectTransitionSpeed * Time.deltaTime;
for (int i = 0; i < id.effectSystems.Count; i++)
{
if (id.effectSystems[i].isStopped)
id.effectSystems[i].Play();
// Set EmissionRate
float val = Mathf.Lerp(EnviroSkyMgr.instance.GetEmissionRate(id.effectSystems[i]), id.effectEmmisionRates[i] * EnviroSky.instance.qualitySettings.GlobalParticleEmissionRates, speed) * EnviroSkyMgr.instance.InteriorZoneSettings.currentInteriorWeatherEffectMod;
EnviroSkyMgr.instance.SetEmissionRate(id.effectSystems[i], val);
}
for (int i = 0; i < zoneWeather.Count; i++)
{
if (zoneWeather[i].gameObject != id.gameObject)
{
for (int i2 = 0; i2 < zoneWeather[i].effectSystems.Count; i2++)
{
float val2 = Mathf.Lerp(EnviroSkyMgr.instance.GetEmissionRate(zoneWeather[i].effectSystems[i2]), 0f, speed);
if (val2 < 1f)
val2 = 0f;
EnviroSkyMgr.instance.SetEmissionRate(zoneWeather[i].effectSystems[i2], val2);
if (val2 == 0f && !zoneWeather[i].effectSystems[i2].isStopped)
{
zoneWeather[i].effectSystems[i2].Stop();
}
}
}
}
}
}
private void InitImageEffects()
{
if (addEnviroSkyRendering)
{
skyRender = myCam.gameObject.GetComponent<EnviroSkyRendering>();
if (skyRender == null)
skyRender = myCam.gameObject.AddComponent<EnviroSkyRendering>();
skyRender.isAddionalCamera = true;
#if UNITY_EDITOR
string[] assets = UnityEditor.AssetDatabase.FindAssets("enviro_spot_cookie", null);
for (int idx = 0; idx < assets.Length; idx++)
{
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(assets[idx]);
if (path.Length > 0)
{
skyRender.DefaultSpotCookie = UnityEditor.AssetDatabase.LoadAssetAtPath<Texture>(path);
}
}
#endif
}
if (addEnviroSkyPostProcessing)
{
enviroPostProcessing = myCam.gameObject.GetComponent<EnviroPostProcessing>();
if (enviroPostProcessing == null)
enviroPostProcessing = myCam.gameObject.AddComponent<EnviroPostProcessing>();
}
}
#endif
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0eb48866c08eec942becb3f4c632ac60
timeCreated: 1510847875
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class EnviroCloudsAnimateWithTime : MonoBehaviour {
void Update ()
{
if(EnviroSky.instance == null)
return;
float timeToAnimation = EnviroSky.instance.Remap(EnviroSky.instance.GetTimeOfDay(),0f,24f,-1f,1f);
float timeOfYearInHours = EnviroSky.instance.GetTimeOfDay() + (EnviroSky.instance.GameTime.Days * 24f);
EnviroSky.instance.cloudAnim = new Vector3(timeToAnimation * EnviroSky.instance.cloudsSettings.cloudsWindDirectionX,timeToAnimation * -1f,timeToAnimation * EnviroSky.instance.cloudsSettings.cloudsWindDirectionY);
EnviroSky.instance.cloudAnimNonScaled = new Vector2(timeOfYearInHours * EnviroSky.instance.cloudsSettings.cloudsWindDirectionX,timeOfYearInHours * EnviroSky.instance.cloudsSettings.cloudsWindDirectionY);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 80b3a100007d0c24585fedc9702ff5ce
timeCreated: 1593436234
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: