Initial commit
This commit is contained in:
1 parent
ee9615239e
commit
16feac691f
4093 files changed
+1030491
No files matched your search
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
public class DisableUnderwaterFXTrigger : MonoBehaviour
|
||||
{
|
||||
public string m_tagCheck = "Player";
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.tag == m_tagCheck)
|
||||
{
|
||||
if (GaiaUnderwaterEffects.Instance != null)
|
||||
{
|
||||
GaiaUnderwaterEffects.Instance.EnableUnderwaterEffects = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.tag == m_tagCheck)
|
||||
{
|
||||
if (GaiaUnderwaterEffects.Instance != null)
|
||||
{
|
||||
GaiaUnderwaterEffects.Instance.EnableUnderwaterEffects = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadTagFromGaia()
|
||||
{
|
||||
CharacterController controller = FindObjectOfType<CharacterController>();
|
||||
if (controller != null)
|
||||
{
|
||||
m_tagCheck = controller.tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f74e5eb35e5021c46a045a6956626d86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1b943e3e2780e344827c6617353bbb8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Gaia.Internal;
|
||||
using PWCommon4;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[CustomEditor(typeof(DisableUnderwaterFXTrigger))]
|
||||
public class DisableUnderwaterFXTriggerEditor : PWEditor
|
||||
{
|
||||
private DisableUnderwaterFXTrigger m_profile;
|
||||
private EditorUtils m_editorUtils;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_profile = (DisableUnderwaterFXTrigger) target;
|
||||
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
m_editorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (m_editorUtils != null)
|
||||
{
|
||||
m_editorUtils.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//Initialization
|
||||
m_editorUtils.Initialize(); // Do not remove this!
|
||||
|
||||
if (m_profile == null)
|
||||
{
|
||||
m_profile = (DisableUnderwaterFXTrigger) target;
|
||||
}
|
||||
|
||||
m_editorUtils.Panel("GlobalSettings", GlobalPanel, true);
|
||||
}
|
||||
|
||||
private void GlobalPanel(bool helpEnabled)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
m_profile.m_tagCheck = m_editorUtils.TextField("TagCheck", m_profile.m_tagCheck);
|
||||
if (m_editorUtils.Button("LoadTagFromGaia", GUILayout.MaxWidth(130f)))
|
||||
{
|
||||
m_profile.LoadTagFromGaia();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
m_editorUtils.InlineHelp("TagCheck", helpEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e325c798b6db83a44b5543d648522462
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using PWCommon4;
|
||||
using Gaia.Internal;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[CustomEditor(typeof(GaiaUnderwaterEffects))]
|
||||
public class GaiaUnderwaterEffectsEditor : PWEditor
|
||||
{
|
||||
private EditorUtils m_editorUtils;
|
||||
private GaiaUnderwaterEffects m_profile;
|
||||
private GaiaConstants.EnvironmentRenderer m_renderPipeline;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
//Get Profile object
|
||||
m_profile = (GaiaUnderwaterEffects)target;
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
m_editorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
|
||||
m_renderPipeline = GaiaUtils.GetActivePipeline();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup on destroy
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (m_editorUtils != null)
|
||||
{
|
||||
m_editorUtils.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//Initialization
|
||||
m_editorUtils.Initialize(); // Do not remove this!
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
m_editorUtils.Panel("GlobalSettings", GlobalSettings, true);
|
||||
|
||||
//Check for changes, make undo record, make changes and let editor know we are dirty
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(m_profile, "Made changes");
|
||||
EditorUtility.SetDirty(m_profile);
|
||||
}
|
||||
}
|
||||
|
||||
private void GlobalSettings(bool helpEnabled)
|
||||
{
|
||||
m_editorUtils.Heading("GlobalSettings");
|
||||
m_profile.EnableUnderwaterEffects = m_editorUtils.Toggle("EnableUnderwaterEffects", m_profile.EnableUnderwaterEffects, helpEnabled);
|
||||
m_profile.m_seaLevel = m_editorUtils.FloatField("SeaLevel", m_profile.m_seaLevel, helpEnabled);
|
||||
m_profile.m_playerCamera = (Transform)m_editorUtils.ObjectField("PlayerCamera", m_profile.m_playerCamera, typeof(Transform), helpEnabled);
|
||||
m_profile.m_startingUnderwater = m_editorUtils.Toggle("StartingUnderwater", m_profile.m_startingUnderwater, helpEnabled);
|
||||
bool transitionEnabled = m_profile.m_enableTransitionFX;
|
||||
transitionEnabled = m_editorUtils.Toggle("EnableTransitionFX", transitionEnabled, helpEnabled);
|
||||
if (m_profile.m_enableTransitionFX != transitionEnabled)
|
||||
{
|
||||
m_profile.m_enableTransitionFX = transitionEnabled;
|
||||
m_profile.SetupTransitionVFX( m_profile.m_enableTransitionFX);
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Heading("CausticSettings");
|
||||
m_profile.m_useCaustics = m_editorUtils.Toggle("UseCaustics", m_profile.m_useCaustics, helpEnabled);
|
||||
if (m_profile.m_useCaustics)
|
||||
{
|
||||
m_profile.m_mainLight = (Light)m_editorUtils.ObjectField("MainLight", m_profile.m_mainLight, typeof(Light), helpEnabled);
|
||||
m_profile.m_framesPerSecond = m_editorUtils.IntField("FramesPerSecond", m_profile.m_framesPerSecond, helpEnabled);
|
||||
m_profile.m_causticSize = m_editorUtils.Slider("CausticSize", m_profile.m_causticSize, 1f, 100f, helpEnabled);
|
||||
m_profile.m_editCausticTextures = m_editorUtils.Toggle("EditCausticTextures", m_profile.m_editCausticTextures, helpEnabled);
|
||||
if (m_profile.m_editCausticTextures)
|
||||
{
|
||||
for (int i = 0; i < m_profile.m_causticTextures.Count; i++)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
m_profile.m_causticTextures[i] = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("[" + i + "]" + m_editorUtils.GetTextValue("CausticTexture"), m_editorUtils.GetTooltip("CausticTexture")), m_profile.m_causticTextures[i], typeof(Texture2D), false, GUILayout.MaxHeight(16f));
|
||||
if (m_editorUtils.Button("Remove", GUILayout.MaxWidth(30f)))
|
||||
{
|
||||
m_profile.m_causticTextures.RemoveAt(i);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
if (m_editorUtils.Button("Add"))
|
||||
{
|
||||
m_profile.m_causticTextures.Add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Heading("FogSettings");
|
||||
m_profile.m_supportFog = m_editorUtils.Toggle("SupportFog", m_profile.m_supportFog, helpEnabled);
|
||||
if (m_profile.m_supportFog)
|
||||
{
|
||||
m_profile.m_fogColorGradient = EditorGUILayout.GradientField(new GUIContent(m_editorUtils.GetTextValue("FogColor"), m_editorUtils.GetTooltip("FogColor")), m_profile.m_fogColorGradient);
|
||||
m_editorUtils.InlineHelp("FogColor", helpEnabled);
|
||||
if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition)
|
||||
{
|
||||
if (RenderSettings.fogMode == FogMode.Linear)
|
||||
{
|
||||
m_profile.m_nearFogDistance = m_editorUtils.FloatField("FogStartDistance", m_profile.m_nearFogDistance, helpEnabled);
|
||||
m_profile.m_fogDistance = m_editorUtils.FloatField("FogEndDistance", m_profile.m_fogDistance, helpEnabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profile.m_fogDensity = m_editorUtils.Slider("FogDensity", m_profile.m_fogDensity, 0f, 1f, helpEnabled);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profile.m_fogDistance = m_editorUtils.FloatField("FogEndDistance", m_profile.m_fogDistance, helpEnabled);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Heading("AudioSettings");
|
||||
m_profile.m_playbackVolume = m_editorUtils.Slider("PlaybackVolume", m_profile.m_playbackVolume, 0f, 1f, helpEnabled);
|
||||
m_profile.m_submergeSoundFXDown = (AudioClip)m_editorUtils.ObjectField("SubmergeSoundFXDown", m_profile.m_submergeSoundFXDown, typeof(AudioClip), helpEnabled);
|
||||
m_profile.m_submergeSoundFXUp = (AudioClip)m_editorUtils.ObjectField("SubmergeSoundFXUp", m_profile.m_submergeSoundFXUp, typeof(AudioClip), helpEnabled);
|
||||
m_profile.m_underwaterSoundFX = (AudioClip)m_editorUtils.ObjectField("UnderwaterSoundFX", m_profile.m_underwaterSoundFX, typeof(AudioClip), helpEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b2f9fac79e0d3746b0744055d19a93d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e7a5fb944a62dc42908ea037d47367c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,239 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia.GX.ProceduralWorlds
|
||||
{
|
||||
public class GaiaWaterGX
|
||||
{
|
||||
#region Private values
|
||||
|
||||
private static string m_unityVersion;
|
||||
private static List<string> m_profileList = new List<string>();
|
||||
private static List<Material> m_allMaterials = new List<Material>();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Generic informational methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns the publisher name if provided.
|
||||
/// This will override the publisher name in the namespace ie Gaia.GX.PublisherName
|
||||
/// </summary>
|
||||
/// <returns>Publisher name</returns>
|
||||
public static string GetPublisherName()
|
||||
{
|
||||
return "Procedural Worlds";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the package name if provided
|
||||
/// This will override the package name in the class name ie public class PackageName.
|
||||
/// </summary>
|
||||
/// <returns>Package name</returns>
|
||||
public static string GetPackageName()
|
||||
{
|
||||
return "Water";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods exposed by Gaia as buttons must be prefixed with GX_
|
||||
|
||||
/// <summary>
|
||||
/// Adds water system to the scene
|
||||
/// </summary>
|
||||
public static void GX_WaterSetup_AddWater()
|
||||
{
|
||||
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
GaiaWaterProfile waterProfile = AssetDatabase.LoadAssetAtPath<GaiaWaterProfile>(GetAssetPath("Gaia Water System Profile"));
|
||||
Material material = GaiaWater.GetGaiaOceanMaterial();
|
||||
if (material != null)
|
||||
{
|
||||
GaiaUtils.GetRuntimeSceneObject();
|
||||
if (GaiaGlobal.Instance != null)
|
||||
{
|
||||
GaiaWater.GetProfile(0, material, GaiaGlobal.Instance.SceneProfile, true, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Material could not be found");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes water system from the scene
|
||||
/// </summary>
|
||||
public static void GX_WaterSetup_RemoveWater()
|
||||
{
|
||||
GaiaUtils.RemoveWaterSystems();
|
||||
}
|
||||
|
||||
public static void GX_WaterSetup_SelectLightingAndWaterProfile()
|
||||
{
|
||||
GaiaLighting.OpenProfileSelection();
|
||||
}
|
||||
|
||||
public static void GX_WaterSetup_SetupWaterProfiles()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Opening Water Profile", "This will open the water profile settings. In there you will be able to adjust water settings for Gaia, and you can also edit the default water shader parameters for the different water types.", "OK", "Cancel"))
|
||||
{
|
||||
GaiaUtils.FocusWaterProfile();
|
||||
}
|
||||
}
|
||||
|
||||
//public static void GX_WaterStyles_OceanTropical()
|
||||
//{
|
||||
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
// GaiaWaterProfile waterProfile = AssetDatabase.LoadAssetAtPath<GaiaWaterProfile>(GetAssetPath("Gaia Water System Profile"));
|
||||
// if (GaiaWater.SetupMaterials(gaiaSettings.m_currentRenderer, gaiaSettings, 10))
|
||||
// {
|
||||
// GaiaWater.GetProfile(GaiaConstants.GaiaWaterProfileType.StandardClearLake, waterProfile, gaiaSettings.m_pipelineProfile.m_activePipelineInstalled, true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log("Materials could not be found");
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets water style to deep blue
|
||||
/// </summary>
|
||||
//public static void GX_WaterStyles_OceanTropicalAngry()
|
||||
//{
|
||||
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
// GaiaWaterProfile waterProfile = AssetDatabase.LoadAssetAtPath<GaiaWaterProfile>(GetAssetPath("Gaia Water System Profile"));
|
||||
|
||||
// if (GaiaWater.SetupMaterials(gaiaSettings.m_currentRenderer, gaiaSettings, 6))
|
||||
// {
|
||||
// GaiaWater.GetProfile(GaiaConstants.GaiaWaterProfileType.DeepBlueOcean, waterProfile, gaiaSettings.m_pipelineProfile.m_activePipelineInstalled, true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log("Materials could not be found");
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Sets water style to deep blue
|
||||
///// </summary>
|
||||
//public static void GX_WaterStyles_OceanTropicalBlue()
|
||||
//{
|
||||
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
// GaiaWaterProfile waterProfile = AssetDatabase.LoadAssetAtPath<GaiaWaterProfile>(GetAssetPath("Gaia Water System Profile"));
|
||||
|
||||
// if (GaiaWater.SetupMaterials(gaiaSettings.m_currentRenderer, gaiaSettings, 7))
|
||||
// {
|
||||
// GaiaWater.GetProfile(GaiaConstants.GaiaWaterProfileType.ClearBlueOcean, waterProfile, gaiaSettings.m_pipelineProfile.m_activePipelineInstalled, true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log("Materials could not be found");
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Sets water style to deep blue
|
||||
///// </summary>
|
||||
//public static void GX_WaterStyles_OceanTropicalFlat()
|
||||
//{
|
||||
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
// GaiaWaterProfile waterProfile = AssetDatabase.LoadAssetAtPath<GaiaWaterProfile>(GetAssetPath("Gaia Water System Profile"));
|
||||
// if (GaiaWater.SetupMaterials(gaiaSettings.m_currentRenderer, gaiaSettings, 8))
|
||||
// {
|
||||
// GaiaWater.GetProfile(GaiaConstants.GaiaWaterProfileType.StandardLake, waterProfile, gaiaSettings.m_pipelineProfile.m_activePipelineInstalled, true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log("Materials could not be found");
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Sets water style to deep blue
|
||||
///// </summary>
|
||||
//public static void GX_WaterStyles_OceanTropicalGreen()
|
||||
//{
|
||||
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
// GaiaWaterProfile waterProfile = AssetDatabase.LoadAssetAtPath<GaiaWaterProfile>(GetAssetPath("Gaia Water System Profile"));
|
||||
// if(GaiaWater.SetupMaterials(gaiaSettings.m_currentRenderer, gaiaSettings, 9))
|
||||
// {
|
||||
// GaiaWater.GetProfile(GaiaConstants.GaiaWaterProfileType.StandardClearLake, waterProfile, gaiaSettings.m_pipelineProfile.m_activePipelineInstalled, true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log("Materials could not be found");
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Enables water reflections
|
||||
/// </summary>
|
||||
public static void GX_WaterReflections_EnableReflections()
|
||||
{
|
||||
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
GaiaWater.SetWaterReflectionsType(true, gaiaSettings.m_pipelineProfile.m_activePipelineInstalled, gaiaSettings.m_gaiaWaterProfile, gaiaSettings.m_gaiaWaterProfile.m_waterProfiles[gaiaSettings.m_gaiaWaterProfile.m_selectedWaterProfileValuesIndex]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables water reflections
|
||||
/// </summary>
|
||||
public static void GX_WaterReflections_DisableReflections()
|
||||
{
|
||||
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
GaiaWater.SetWaterReflectionsType(false, gaiaSettings.m_pipelineProfile.m_activePipelineInstalled, gaiaSettings.m_gaiaWaterProfile, gaiaSettings.m_gaiaWaterProfile.m_waterProfiles[gaiaSettings.m_gaiaWaterProfile.m_selectedWaterProfileValuesIndex]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Utils
|
||||
|
||||
/// <summary>
|
||||
/// Get the asset path of the first thing that matches the name
|
||||
/// </summary>
|
||||
/// <param name="name">Name to search for</param>
|
||||
/// <returns></returns>
|
||||
private static string GetAssetPath(string name)
|
||||
{
|
||||
string[] assets = AssetDatabase.FindAssets(name, null);
|
||||
if (assets.Length > 0)
|
||||
{
|
||||
return AssetDatabase.GUIDToAssetPath(assets[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Removes Suffix in file formats required
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
private static List<Material> GetMaterials(string path)
|
||||
{
|
||||
List<Material> materials = new List<Material>();
|
||||
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(path);
|
||||
var files = dirInfo.GetFiles();
|
||||
foreach (FileInfo file in files)
|
||||
{
|
||||
if (file.Extension.EndsWith("mat"))
|
||||
{
|
||||
materials.Add(AssetDatabase.LoadAssetAtPath<Material>(GaiaUtils.GetAssetPath(file.Name)));
|
||||
}
|
||||
}
|
||||
|
||||
m_allMaterials = materials;
|
||||
|
||||
return materials;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2253de7a5deb41b479f9f53ce8549c6f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,989 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using ProceduralWorlds.WaterSystem;
|
||||
using Gaia.Internal;
|
||||
using PWCommon4;
|
||||
using System.IO;
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
#endif
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[CustomEditor(typeof(GaiaWaterProfile))]
|
||||
public class GaiaWaterProfileEditor : PWEditor
|
||||
{
|
||||
private EditorUtils m_editorUtils;
|
||||
private string m_version;
|
||||
private GaiaSettings m_gaiaSettings;
|
||||
private GaiaWaterProfile m_profile;
|
||||
private GaiaWaterProfileValues m_profileValues;
|
||||
private PWS_WaterSystem m_waterSystemPro;
|
||||
private GaiaConstants.EnvironmentRenderer m_renderPipeline;
|
||||
private List<string> m_profileList = new List<string>();
|
||||
//private List<Material> m_allMaterials = new List<Material>();
|
||||
[SerializeField]
|
||||
private Material m_gaiaOceanMat;
|
||||
|
||||
private int newProfileListIndex = 1;
|
||||
private Texture2D m_waterTexture;
|
||||
private bool enableEditMode;
|
||||
|
||||
public Gradient gradient;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
//Get Gaia Lighting Profile object
|
||||
m_profile = (GaiaWaterProfile)target;
|
||||
|
||||
#if !GAIA_PRO_PRESENT
|
||||
if (m_profile != null)
|
||||
{
|
||||
for (int i = 0; i < m_profile.m_customRenderDistances.Length; i++)
|
||||
{
|
||||
m_profile.m_customRenderDistances[i] = 0f;
|
||||
}
|
||||
|
||||
m_profile.m_customRenderDistance = 0f;
|
||||
}
|
||||
#endif
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
m_editorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
|
||||
if (m_gaiaSettings == null)
|
||||
{
|
||||
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
}
|
||||
|
||||
m_renderPipeline = m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled;
|
||||
m_version = PWApp.CONF.Version;
|
||||
|
||||
m_waterSystemPro = Object.FindObjectOfType<PWS_WaterSystem>();
|
||||
|
||||
newProfileListIndex = m_gaiaSettings.m_gaiaWaterProfile.m_selectedWaterProfileValuesIndex;
|
||||
if (newProfileListIndex < 0)
|
||||
{
|
||||
newProfileListIndex = 1;
|
||||
}
|
||||
|
||||
m_gaiaOceanMat = GaiaWater.GetGaiaOceanMaterial();
|
||||
|
||||
enableEditMode = Directory.Exists(GaiaUtils.GetAssetPath("Dev Utilities"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup on destroy
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (m_editorUtils != null)
|
||||
{
|
||||
m_editorUtils.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//Initialization
|
||||
m_editorUtils.Initialize(); // Do not remove this!
|
||||
|
||||
if (m_gaiaSettings == null)
|
||||
{
|
||||
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
}
|
||||
|
||||
if (m_renderPipeline != m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled)
|
||||
{
|
||||
m_renderPipeline = m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled;
|
||||
}
|
||||
|
||||
//Monitor for changes
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.LabelField("Profile Version: " + m_version);
|
||||
|
||||
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.HighDefinition)
|
||||
{
|
||||
//EditorGUILayout.HelpBox("Water for High Definition Pipeline is not yet Supported in Gaia. This will be available in the near future.", MessageType.Info);
|
||||
}
|
||||
|
||||
if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.Lightweight)
|
||||
{
|
||||
if (enableEditMode)
|
||||
{
|
||||
m_profile.m_editSettings = EditorGUILayout.ToggleLeft("Use Procedural Worlds Editor Settings", m_profile.m_editSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profile.m_editSettings = false;
|
||||
}
|
||||
|
||||
if (m_profile.m_editSettings)
|
||||
{
|
||||
m_editorUtils.Panel("UpdateSettings", RealtimeUpdateEnabled);
|
||||
m_editorUtils.Panel("GlobalSettings", GlobalSettingsEnabled);
|
||||
m_editorUtils.Panel("ReflectionSettings", ReflectionSettingsEnabled);
|
||||
m_editorUtils.Panel("MeshQualitySettings", WaterMeshQualityEnabled);
|
||||
m_editorUtils.Panel("UnderwaterSettings", UnderwaterSettingsEnabled);
|
||||
m_editorUtils.Panel("WaterProfileSettings", WaterProfileSettingsEnabled);
|
||||
DrawDefaultInspector();
|
||||
}
|
||||
}
|
||||
|
||||
//Check for changes, make undo record, make changes and let editor know we are dirty
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(m_profile, "Made changes");
|
||||
EditorUtility.SetDirty(m_profile);
|
||||
|
||||
if (m_profile.m_updateInRealtime)
|
||||
{
|
||||
if (m_profile.m_selectedProfile != "None")
|
||||
{
|
||||
GaiaUtils.GetRuntimeSceneObject();
|
||||
}
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(m_profile);
|
||||
}
|
||||
}
|
||||
|
||||
private void RealtimeUpdateEnabled(bool helpEnabled)
|
||||
{
|
||||
m_profile.m_updateInRealtime = m_editorUtils.ToggleLeft("UpdateInRealtime", m_profile.m_updateInRealtime);
|
||||
if (m_profile.m_updateInRealtime)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Update In Realtime is enabled this will allow profiles to be endited inside the editor and automatically apply changes every frame. This feature can be expensive and should not be left enabled in testing and builds", MessageType.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_editorUtils.Button("UpdateToScene"))
|
||||
{
|
||||
if (m_profile.m_selectedProfile != "None")
|
||||
{
|
||||
GaiaUtils.GetRuntimeSceneObject();
|
||||
if (GaiaGlobal.Instance != null)
|
||||
{
|
||||
EditorUtility.SetDirty(m_profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GlobalSettingsEnabled(bool helpEnabled)
|
||||
{
|
||||
m_profile.m_waterPrefab = (GameObject)m_editorUtils.ObjectField("WaterPrefab", m_profile.m_waterPrefab, typeof(GameObject), false, GUILayout.Height(16f));
|
||||
if (m_profile.m_waterPrefab == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Missing a Water Prefab, please add one.", MessageType.Error);
|
||||
}
|
||||
m_profile.m_transitionFXPrefab = (GameObject)m_editorUtils.ObjectField("TransitionFXPrefab", m_profile.m_transitionFXPrefab, typeof(GameObject), false, GUILayout.Height(16f));
|
||||
if (m_profile.m_transitionFXPrefab == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Missing a Transition FX Prefab, please add one.", MessageType.Error);
|
||||
}
|
||||
m_profile.m_enableGPUInstancing = m_editorUtils.ToggleLeft("EnableGPUInstancing", m_profile.m_enableGPUInstancing);
|
||||
if (!m_profile.m_enableGPUInstancing)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Enabling GPU instancing will help improve performance. We recommend you enable this setting.", MessageType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReflectionSettingsEnabled(bool helpEnabled)
|
||||
{
|
||||
m_profile.m_enableReflections = m_editorUtils.ToggleLeft("EnableReflections", m_profile.m_enableReflections);
|
||||
if (m_profile.m_enableReflections)
|
||||
{
|
||||
if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.BuiltIn)
|
||||
{
|
||||
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.Lightweight)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Realtime reflections is not yet supported in SRP", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
|
||||
{
|
||||
m_editorUtils.Heading("ReflectionRendering");
|
||||
m_profile.m_reflectionSettingsData.m_Shadows = m_editorUtils.Toggle("EnableReflectionShadows", m_profile.m_reflectionSettingsData.m_Shadows, helpEnabled);
|
||||
m_profile.m_reflectionResolution = (GaiaConstants.GaiaProWaterReflectionsQuality)EditorGUILayout.EnumPopup("Reflection Resolution", m_profile.m_reflectionResolution);
|
||||
m_profile.UpdateTextureResolution();
|
||||
m_profile.m_reflectionSettingsData.m_ResolutionMultiplier = (GaiaConstants.ResolutionMulltiplier)m_editorUtils.EnumPopup("ReflectionResolutionMultiplier", m_profile.m_reflectionSettingsData.m_ResolutionMultiplier);
|
||||
m_profile.m_clipPlaneOffset = m_editorUtils.Slider("ClipPlaneOffset", m_profile.m_clipPlaneOffset, -5f, 100f);
|
||||
m_profile.m_reflectedLayers = LayerMaskField("ReflectedLayers", m_editorUtils, m_profile.m_reflectedLayers);
|
||||
m_profile.m_reflectionSettingsData.m_ReflectLayers = m_profile.m_reflectedLayers;
|
||||
m_profile.m_reflectionSettingsData.m_textureResolution = m_profile.m_textureResolution;
|
||||
|
||||
m_profile.m_reflectionSettingsData.m_enableRenderDistance = m_editorUtils.ToggleLeft("UseCustomRenderDistance", m_profile.m_reflectionSettingsData.m_enableRenderDistance, helpEnabled);
|
||||
if ( m_profile.m_reflectionSettingsData.m_enableRenderDistance)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
m_profile.m_reflectionSettingsData.m_enableRenderDistances = m_editorUtils.ToggleLeft("EnableMultiLayerDistance", m_profile.m_reflectionSettingsData.m_enableRenderDistances, helpEnabled);
|
||||
if (m_profile.m_reflectionSettingsData.m_enableRenderDistances)
|
||||
{
|
||||
List<string> layers = new List<string>();
|
||||
layers.Clear();
|
||||
int layerCount = 0;
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
if (layerName.Length > 1)
|
||||
{
|
||||
layers.Add(layerName);
|
||||
layerCount++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < layerCount; i++)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(layers[i]);
|
||||
m_profile.m_reflectionSettingsData.m_customRenderDistances[i] = EditorGUILayout.FloatField(m_profile.m_reflectionSettingsData.m_customRenderDistances[i]);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
m_profile.m_reflectionSettingsData.m_customRenderDistance = m_editorUtils.FloatField("CustomRenderDistance", m_profile.m_reflectionSettingsData.m_customRenderDistance);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_editorUtils.Heading("ReflectionRendering");
|
||||
m_profile.m_reflectionResolution = (GaiaConstants.GaiaProWaterReflectionsQuality)EditorGUILayout.EnumPopup("Reflection Resolution", m_profile.m_reflectionResolution);
|
||||
m_profile.UpdateTextureResolution();
|
||||
m_profile.m_reflectedLayers = LayerMaskField("ReflectedLayers", m_editorUtils, m_profile.m_reflectedLayers);
|
||||
m_profile.m_clipPlaneOffset = m_editorUtils.Slider("ClipPlaneOffset", m_profile.m_clipPlaneOffset, -5f, 100f);
|
||||
m_profile.m_hdrpReflectionIntensity = m_editorUtils.Slider("HDRPReflectionIntensity", m_profile.m_hdrpReflectionIntensity, 0f, 5f, helpEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Reflections render the object reflections on the water surface. This can be very expensive feature and could cause performance issue on low end machines.", MessageType.Info);
|
||||
|
||||
GUILayout.Space(15f);
|
||||
m_editorUtils.Heading("ReflectionSupport");
|
||||
m_profile.m_allowMSAA = m_editorUtils.ToggleLeft("AllowMSAA", m_profile.m_allowMSAA);
|
||||
m_profile.m_useHDR = m_editorUtils.ToggleLeft("UseHDR", m_profile.m_useHDR);
|
||||
m_profile.m_disablePixelLights = m_editorUtils.ToggleLeft("DisablePixelLights", m_profile.m_disablePixelLights);
|
||||
m_profile.m_enableDisabeHeightFeature = m_editorUtils.ToggleLeft("EnableHeightFeatures", m_profile.m_enableDisabeHeightFeature, helpEnabled);
|
||||
if (m_profile.m_enableDisabeHeightFeature)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
m_profile.m_disableHeight = m_editorUtils.FloatField("DisableHeight", m_profile.m_disableHeight, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
m_profile.m_useCustomRenderDistance = m_editorUtils.ToggleLeft("UseCustomRenderDistance", m_profile.m_useCustomRenderDistance, helpEnabled);
|
||||
if (m_profile.m_useCustomRenderDistance)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
m_profile.m_enableLayerDistances = m_editorUtils.ToggleLeft("EnableMultiLayerDistance", m_profile.m_enableLayerDistances, helpEnabled);
|
||||
if (m_profile.m_enableLayerDistances)
|
||||
{
|
||||
List<string> layers = new List<string>();
|
||||
layers.Clear();
|
||||
int layerCount = 0;
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
if (layerName.Length > 1)
|
||||
{
|
||||
layers.Add(layerName);
|
||||
layerCount++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < layerCount; i++)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(layers[i]);
|
||||
m_profile.m_customRenderDistances[i] = EditorGUILayout.FloatField(m_profile.m_customRenderDistances[i]);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
m_profile.m_customRenderDistance = m_editorUtils.FloatField("CustomRenderDistance", m_profile.m_customRenderDistance);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
//GUILayout.Space(15f);
|
||||
//m_editorUtils.Heading("ReflectionSetup");
|
||||
// m_profile.m_waterRenderUpdateMode = (GaiaConstants.RenderUpdateMode)EditorGUILayout.EnumPopup("Render Update Mode", m_profile.m_waterRenderUpdateMode);
|
||||
// if (m_profile.m_waterRenderUpdateMode == GaiaConstants.RenderUpdateMode.Interval)
|
||||
// {
|
||||
// m_profile.m_interval = m_editorUtils.Slider("IntervalTime", m_profile.m_interval, 0f, 50f);
|
||||
// }
|
||||
GUILayout.Space(15f);
|
||||
m_editorUtils.Heading("ReflectionRendering");
|
||||
m_profile.m_reflectionResolution = (GaiaConstants.GaiaProWaterReflectionsQuality)EditorGUILayout.EnumPopup("Reflection Resolution", m_profile.m_reflectionResolution);
|
||||
m_profile.UpdateTextureResolution();
|
||||
m_profile.m_clipPlaneOffset = m_editorUtils.Slider("ClipPlaneOffset", m_profile.m_clipPlaneOffset, -5f, 100f);
|
||||
m_profile.m_reflectedLayers = LayerMaskField("ReflectedLayers", m_editorUtils, m_profile.m_reflectedLayers);
|
||||
}
|
||||
|
||||
if (!m_profile.m_updateInRealtime)
|
||||
{
|
||||
if (m_editorUtils.Button("UpdateReflectionSettings"))
|
||||
{
|
||||
GaiaUtils.GetRuntimeSceneObject();
|
||||
if (GaiaGlobal.Instance != null)
|
||||
{
|
||||
GaiaWater.SetupWaterReflectionSettings(GaiaGlobal.Instance.SceneProfile, m_profileValues, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_profile.m_reflectionSettingsData.m_enableReflections = m_profile.m_enableReflections;
|
||||
}
|
||||
|
||||
private void WaterMeshQualityEnabled(bool helpEnabled)
|
||||
{
|
||||
//m_profile.m_enableWaterMeshQuality = EditorGUILayout.ToggleLeft("Enable Water Mesh Quality", m_profile.m_enableWaterMeshQuality);
|
||||
m_profile.m_enableWaterMeshQuality = true;
|
||||
if (m_profile.m_enableWaterMeshQuality)
|
||||
{
|
||||
m_profile.m_waterMeshQuality = (GaiaConstants.WaterMeshQuality)EditorGUILayout.EnumPopup("Water Mesh Quality", m_profile.m_waterMeshQuality);
|
||||
m_profile.m_meshType = (GaiaConstants.MeshType)EditorGUILayout.EnumPopup("Mesh Type", m_profile.m_meshType);
|
||||
if (m_profile.m_waterMeshQuality == GaiaConstants.WaterMeshQuality.Custom)
|
||||
{
|
||||
if (m_profile.m_meshType == GaiaConstants.MeshType.Plane)
|
||||
{
|
||||
m_profile.m_customMeshQuality = m_editorUtils.IntSlider("CustomMeshQuality", m_profile.m_customMeshQuality, 1, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profile.m_customMeshQuality = m_editorUtils.IntSlider("CustomMeshQuality", m_profile.m_customMeshQuality, 1, 16);
|
||||
//m_profile.m_customMeshQuality = m_editorUtils.IntSlider("CustomMeshQuality", (int)m_profile.m_customMeshQuality * 2, 2, 256) / 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (m_profile.m_meshType == GaiaConstants.MeshType.Plane)
|
||||
{
|
||||
m_profile.m_xSize = m_editorUtils.IntField("WaterSize", m_profile.m_xSize);
|
||||
m_profile.m_zSize = m_profile.m_xSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profile.m_xSize = m_editorUtils.IntField("WaterSize", m_profile.m_xSize);
|
||||
m_profile.m_zSize = m_profile.m_xSize;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
m_editorUtils.Label("PolyCountGenerated");
|
||||
if (m_waterSystemPro == null)
|
||||
{
|
||||
m_waterSystemPro = FindObjectOfType<PWS_WaterSystem>();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_waterSystemPro.m_MeshType = m_profile.m_meshType;
|
||||
m_waterSystemPro.m_Size.x = m_profile.m_xSize;
|
||||
m_waterSystemPro.m_Size.z = m_profile.m_zSize;
|
||||
m_waterSystemPro.m_meshDensity.x = m_profile.m_customMeshQuality;
|
||||
m_waterSystemPro.m_meshDensity.y = m_profile.m_customMeshQuality;
|
||||
EditorGUILayout.LabelField(m_waterSystemPro.CalculatePolysRequired().ToString());
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (!m_profile.m_updateInRealtime)
|
||||
{
|
||||
if (m_editorUtils.Button("UpdateWaterMeshQuality"))
|
||||
{
|
||||
GaiaUtils.GetRuntimeSceneObject();
|
||||
if (GaiaGlobal.Instance != null)
|
||||
{
|
||||
GaiaWater.UpdateWaterMeshQuality(GaiaGlobal.Instance.SceneProfile, m_profile.m_waterPrefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UnderwaterSettingsEnabled(bool helpEnabled)
|
||||
{
|
||||
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.HighDefinition)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Underwater effects are not yet supported in HDRP.", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_editorUtils.Panel("CausticSettings", CausticSettingsEnabled);
|
||||
|
||||
m_profile.m_underwaterParticles = (GameObject)m_editorUtils.ObjectField("UnderwaterParticlesPrefab", m_profile.m_underwaterParticles, typeof(GameObject), false, GUILayout.Height(16f));
|
||||
if (m_profile.m_underwaterParticles == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Missing underwater particles prefab, please add one.", MessageType.Error);
|
||||
}
|
||||
m_profile.m_underwaterHorizonPrefab = (GameObject)m_editorUtils.ObjectField("UnderwaterHorizonPrefab", m_profile.m_underwaterHorizonPrefab, typeof(GameObject), false, GUILayout.Height(16f));
|
||||
if (m_profile.m_underwaterHorizonPrefab == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Missing a underwater horizon prefab, please add one.", MessageType.Error);
|
||||
}
|
||||
m_profile.m_supportUnderwaterEffects = m_editorUtils.ToggleLeft("SupportUnderwaterEffects", m_profile.m_supportUnderwaterEffects);
|
||||
if (m_profile.m_supportUnderwaterEffects)
|
||||
{
|
||||
m_profile.m_supportUnderwaterPostProcessing = m_editorUtils.ToggleLeft("SupportUnderwaterPostProcessing", m_profile.m_supportUnderwaterPostProcessing);
|
||||
|
||||
m_profile.m_supportUnderwaterFog = m_editorUtils.ToggleLeft("SupportUnderwaterFog", m_profile.m_supportUnderwaterFog);
|
||||
|
||||
m_profile.m_supportUnderwaterParticles = m_editorUtils.ToggleLeft("SupportUnderwaterParticles", m_profile.m_supportUnderwaterParticles);
|
||||
|
||||
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.Lightweight)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Underwater effects are in 'Experimental' These will change and be updated over time. LWRP does work but you may experience some artifacts.", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Underwater effects are in 'Experimental' These will change and be updated over time.", MessageType.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WaterProfileSettingsEnabled(bool helpEnabled)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if (m_gaiaOceanMat != null)
|
||||
{
|
||||
//Setup Profiles
|
||||
m_profileList.Clear();
|
||||
if (m_profile.m_waterProfiles.Count > 0)
|
||||
{
|
||||
foreach (GaiaWaterProfileValues profile in m_profile.m_waterProfiles)
|
||||
{
|
||||
m_profileList.Add(profile.m_typeOfWater);
|
||||
}
|
||||
}
|
||||
m_profileList.Add("None");
|
||||
|
||||
newProfileListIndex = m_profile.m_selectedWaterProfileValuesIndex;
|
||||
//Get Profile values
|
||||
if (newProfileListIndex > m_profileList.Count)
|
||||
{
|
||||
newProfileListIndex = 0;
|
||||
}
|
||||
|
||||
if (m_profileList[newProfileListIndex] == "None")
|
||||
{
|
||||
m_profile.m_selectedWaterProfileValuesIndex = EditorGUILayout.Popup("Water Profile", m_profile.m_selectedWaterProfileValuesIndex, m_profileList.ToArray());
|
||||
EditorGUILayout.HelpBox("No water profile selected", MessageType.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
m_profileValues = m_profile.m_waterProfiles[newProfileListIndex];
|
||||
|
||||
//Profile setup
|
||||
m_editorUtils.Heading("OceanSettings");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (m_profile.m_renamingProfile)
|
||||
{
|
||||
m_profileValues.m_profileRename = m_editorUtils.TextField("NewProfileName", m_profileValues.m_profileRename);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profile.m_selectedWaterProfileValuesIndex = EditorGUILayout.Popup("Water Profile", m_profile.m_selectedWaterProfileValuesIndex, m_profileList.ToArray());
|
||||
}
|
||||
if (m_profileValues.m_userCustomProfile)
|
||||
{
|
||||
if (m_profile.m_renamingProfile)
|
||||
{
|
||||
if (m_editorUtils.Button("Save", GUILayout.MaxWidth(55f)))
|
||||
{
|
||||
m_profileValues.m_typeOfWater = m_profileValues.m_profileRename;
|
||||
m_profile.m_selectedProfile = m_profileValues.m_profileRename;
|
||||
m_profile.m_renamingProfile = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_editorUtils.Button("Rename", GUILayout.MaxWidth(55f)))
|
||||
{
|
||||
m_profile.m_renamingProfile = true;
|
||||
m_profileValues.m_profileRename = m_profileValues.m_typeOfWater;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_editorUtils.Button("Remove", GUILayout.MaxWidth(30f)))
|
||||
{
|
||||
m_profile.m_renamingProfile = false;
|
||||
m_profile.m_waterProfiles.RemoveAt(m_profile.m_selectedWaterProfileValuesIndex);
|
||||
m_profile.m_selectedWaterProfileValuesIndex--;
|
||||
}
|
||||
}
|
||||
if (m_editorUtils.Button("MakeCopy", GUILayout.MaxWidth(30f)))
|
||||
{
|
||||
AddNewCustomProfile();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (m_profileList[newProfileListIndex] == "None")
|
||||
{
|
||||
EditorGUILayout.HelpBox("No water profile selected", MessageType.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_profileValues.m_userCustomProfile)
|
||||
{
|
||||
m_profile.m_renamingProfile = false;
|
||||
EditorGUILayout.HelpBox("This is one of the default Gaia water profiles. To create your own please press the '+' button to create a copy from the current selected profile.", MessageType.Info);
|
||||
GUI.enabled = false;
|
||||
}
|
||||
|
||||
if (m_profile.m_editSettings)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
m_editorUtils.Label("UnderwaterSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.BuiltIn)
|
||||
{
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
m_profileValues.PostProcessProfileBuiltIn = (PostProcessProfile)m_editorUtils.ObjectField("UnderwaterPostProcessingProfile", m_profileValues.PostProcessProfileBuiltIn, typeof(PostProcessProfile), false, helpEnabled);
|
||||
#endif
|
||||
}
|
||||
else if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
|
||||
{
|
||||
#if UPPipeline
|
||||
m_profileValues.PostProcessProfileURP = (VolumeProfile)m_editorUtils.ObjectField("UnderwaterPostProcessingProfile", m_profileValues.PostProcessProfileURP, typeof(VolumeProfile), false, helpEnabled);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if HDPipeline
|
||||
m_profileValues.PostProcessProfileHDRP = (VolumeProfile)m_editorUtils.ObjectField("UnderwaterPostProcessingProfile", m_profileValues.PostProcessProfileHDRP, typeof(VolumeProfile), false, helpEnabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_profileValues.m_underwaterFogGradient == null)
|
||||
{
|
||||
m_profileValues.m_underwaterFogGradient = new Gradient();
|
||||
}
|
||||
m_profileValues.m_underwaterFogGradient = EditorGUILayout.GradientField(new GUIContent(m_editorUtils.GetTextValue("UnderwaterFog"), m_editorUtils.GetTooltip("UnderwaterFog")), m_profileValues.m_underwaterFogGradient);
|
||||
m_editorUtils.InlineHelp("UnderwaterFog", helpEnabled);
|
||||
if (RenderSettings.fogMode == FogMode.Exponential || RenderSettings.fogMode == FogMode.ExponentialSquared)
|
||||
{
|
||||
m_profileValues.m_underwaterFogDensity = m_editorUtils.Slider("UnderwaterFogDensity", m_profileValues.m_underwaterFogDensity, 0f, 1f, helpEnabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profileValues.m_underwaterNearFogDistance = m_editorUtils.FloatField("UnderwaterFogStart", m_profileValues.m_underwaterNearFogDistance, helpEnabled);
|
||||
m_profileValues.m_underwaterFogDistance = m_editorUtils.FloatField("UnderwaterFogEnd", m_profileValues.m_underwaterFogDistance, helpEnabled);
|
||||
}
|
||||
m_editorUtils.Heading("UnderwaterPostFX");
|
||||
#if GAIA_PRO_PRESENT
|
||||
if (ProceduralWorldsGlobalWeather.Instance == null)
|
||||
{
|
||||
m_profileValues.m_constUnderwaterPostExposure = m_editorUtils.Slider("UnderwaterPostExposureFX", m_profileValues.m_constUnderwaterPostExposure, -5f, 5f, helpEnabled);
|
||||
m_profileValues.m_constUnderwaterColorFilter = m_editorUtils.ColorField("UnderwaterColorFilterFX", m_profileValues.m_constUnderwaterColorFilter, helpEnabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profileValues.m_gradientUnderwaterPostExposure = m_editorUtils.CurveField("UnderwaterPostExposureFX", m_profileValues.m_gradientUnderwaterPostExposure, helpEnabled);
|
||||
m_profileValues.m_gradientUnderwaterColorFilter = EditorGUILayout.GradientField(new GUIContent(m_editorUtils.GetTextValue("UnderwaterColorFilterFX"), m_editorUtils.GetTooltip("UnderwaterColorFilterFX")), m_profileValues.m_gradientUnderwaterColorFilter);
|
||||
m_editorUtils.InlineHelp("UnderwaterColorFilterFX", helpEnabled);
|
||||
}
|
||||
#else
|
||||
m_profileValues.m_gradientUnderwaterPostExposure = m_editorUtils.CurveField("UnderwaterPostExposureFX", m_profileValues.m_gradientUnderwaterPostExposure, helpEnabled);
|
||||
m_profileValues.m_gradientUnderwaterColorFilter = EditorGUILayout.GradientField(new GUIContent(m_editorUtils.GetTextValue("UnderwaterColorFilterFX"), m_editorUtils.GetTooltip("UnderwaterColorFilterFX")), m_profileValues.m_gradientUnderwaterColorFilter);
|
||||
m_editorUtils.InlineHelp("UnderwaterColorFilterFX", helpEnabled);
|
||||
#endif
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Label("LightingSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profileValues.m_metallic = m_editorUtils.Slider("Metallic", m_profileValues.m_metallic, 0f, 1f, helpEnabled);
|
||||
m_profileValues.m_smoothness = m_editorUtils.Slider("Smoothness", m_profileValues.m_smoothness, 0f, 1f, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Label("FadeSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profileValues.m_fadeStart = m_editorUtils.FloatField("FadeStart", m_profileValues.m_fadeStart, helpEnabled);
|
||||
m_profileValues.m_fadeDistance = m_editorUtils.FloatField("FadeDistance", m_profileValues.m_fadeDistance, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Label("TilingSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profileValues.m_foamTiling = m_editorUtils.IntField("FoamTiling", m_profileValues.m_foamTiling, helpEnabled);
|
||||
m_profileValues.m_waterTiling = m_editorUtils.IntField("WaterTiling", m_profileValues.m_waterTiling, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Label("ColorSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profileValues.m_refractionRenderResolution = (GaiaConstants.PW_RENDER_SIZE)m_editorUtils.EnumPopup("RefractionResolution", m_profileValues.m_refractionRenderResolution, helpEnabled);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
m_profileValues.m_colorDepthRamp = (Texture2D)m_editorUtils.ObjectField("BakedColorDepthRamp", m_profileValues.m_colorDepthRamp, typeof(Texture2D), false, helpEnabled, GUILayout.Height(16f));
|
||||
if (m_editorUtils.Button("ClearBaked", GUILayout.Width(90f)))
|
||||
{
|
||||
m_profileValues.m_colorDepthRamp = null;
|
||||
PWS_WaterSystem pWS_WaterSystem = GameObject.FindObjectOfType<PWS_WaterSystem>();
|
||||
if (pWS_WaterSystem != null)
|
||||
{
|
||||
pWS_WaterSystem.m_waterTexture = null;
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (m_profileValues.m_colorDepthRamp == null)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
m_profileValues.m_waterGradient = EditorGUILayout.GradientField(new GUIContent(m_editorUtils.GetTextValue("WaterGradientColor"), m_editorUtils.GetTooltip("WaterGradientColor")), m_profileValues.m_waterGradient);
|
||||
if (m_editorUtils.Button("RevertGradient", GUILayout.Width(90f)))
|
||||
{
|
||||
m_profileValues.m_waterGradient = CreateNewWaterSurfaceGradient(newProfileListIndex);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
m_editorUtils.InlineHelp("WaterGradientColor", helpEnabled);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
m_profileValues.m_gradientTextureResolution = Mathf.Clamp(EditorGUILayout.IntField(m_editorUtils.GetTextValue("TextureResolution"), m_profileValues.m_gradientTextureResolution), 1, 4096);
|
||||
if (m_editorUtils.Button("GenerateTexture", GUILayout.Width(90f)))
|
||||
{
|
||||
string path = EditorUtility.SaveFilePanel("Save Water Depth Ramp as PNG", Application.dataPath, "New Water Depth Ramp.png", "png");
|
||||
if (path.Length != 0)
|
||||
{
|
||||
GenerateGradientTexture(m_profileValues, path);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (m_profileValues.m_waterGradient == null)
|
||||
{
|
||||
m_profileValues.m_waterGradient = CreateNewWaterSurfaceGradient(0);
|
||||
}
|
||||
}
|
||||
m_profileValues.m_transparentDistance = m_editorUtils.Slider("TransparentDistance", m_profileValues.m_transparentDistance, 0f, 32f, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Label("NormalSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profileValues.m_normalLayer0 = (Texture2D)m_editorUtils.ObjectField("NormalLayer0", m_profileValues.m_normalLayer0, typeof(Texture2D), false, helpEnabled, GUILayout.Height(16f));
|
||||
m_profileValues.m_normalStrength0 = m_editorUtils.Slider("NormalStrength0", m_profileValues.m_normalStrength0, 0f, 3f, helpEnabled);
|
||||
m_profileValues.m_normalLayer1 = (Texture2D)m_editorUtils.ObjectField("NormalLayer1", m_profileValues.m_normalLayer1, typeof(Texture2D), false, helpEnabled, GUILayout.Height(16f));
|
||||
m_profileValues.m_normalStrength1 = m_editorUtils.Slider("NormalStrength1", m_profileValues.m_normalStrength1, 0f, 3f, helpEnabled);
|
||||
m_profileValues.m_fadeNormal = (Texture2D)m_editorUtils.ObjectField("FadeNormal", m_profileValues.m_fadeNormal, typeof(Texture2D), false, helpEnabled, GUILayout.Height(16f));
|
||||
m_profileValues.m_fadeNormalStrength = m_editorUtils.Slider("FadeNormalStrength", m_profileValues.m_fadeNormalStrength, 0f, 3f, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Label("FoamSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profileValues.m_foamAlphaRamp = (Texture2D)m_editorUtils.ObjectField("FoamAlphaRamp", m_profileValues.m_foamAlphaRamp, typeof(Texture2D), false, helpEnabled, GUILayout.Height(16f));
|
||||
m_profileValues.m_foamTexture = (Texture2D)m_editorUtils.ObjectField("FoamTexture", m_profileValues.m_foamTexture, typeof(Texture2D), false, helpEnabled, GUILayout.Height(16f));
|
||||
m_profileValues.m_foamDistance = m_editorUtils.Slider("FoamDistance", m_profileValues.m_foamDistance, 0f, 8f, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Label("ReflectionSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profileValues.m_specularColor = m_editorUtils.ColorField("SpecularColor", m_profileValues.m_specularColor, helpEnabled);
|
||||
m_profileValues.m_reflectionDistortion = m_editorUtils.Slider("ReflectionDistortion", m_profileValues.m_reflectionDistortion, 0f, 16f, helpEnabled);
|
||||
m_profileValues.m_reflectionStrength = m_editorUtils.Slider("ReflectionIntensity", m_profileValues.m_reflectionStrength, 0f, 1f, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_editorUtils.Label("WaveSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profileValues.m_shorelineMovement = m_editorUtils.Slider("ShorelineMovement", m_profileValues.m_shorelineMovement, 0f, 1f, helpEnabled);
|
||||
m_profileValues.m_waveCount = m_editorUtils.FloatField("WaveCount", m_profileValues.m_waveCount, helpEnabled);
|
||||
m_profileValues.m_waveSpeed = m_editorUtils.FloatField("WaveSpeed", m_profileValues.m_waveSpeed, helpEnabled);
|
||||
m_profileValues.m_waveSize = m_editorUtils.FloatField("WaveSize", m_profileValues.m_waveSize, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gaiaOceanMat = GaiaWater.GetGaiaOceanMaterial();
|
||||
EditorGUILayout.HelpBox("Gaia Ocean Material was not found. The system will keep trying to search for 'Gaia Ocean.mat'", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void CausticSettingsEnabled(bool helpEnabled)
|
||||
{
|
||||
m_profile.m_useCastics = m_editorUtils.ToggleLeft("UseCaustics", m_profile.m_useCastics, helpEnabled);
|
||||
if (m_profile.m_useCastics)
|
||||
{
|
||||
m_profile.m_mainCausticLight = (Light)m_editorUtils.ObjectField("MainCausticLight", m_profile.m_mainCausticLight, typeof(Light), true, helpEnabled, GUILayout.Height(16f));
|
||||
if (m_profile.m_mainCausticLight == null)
|
||||
{
|
||||
m_profile.m_mainCausticLight = GaiaUtils.GetMainDirectionalLight();
|
||||
}
|
||||
m_profile.m_causticFramePerSecond = m_editorUtils.IntSlider("CausticFPS", m_profile.m_causticFramePerSecond, 15, 120, helpEnabled);
|
||||
m_profile.m_causticSize = m_editorUtils.Slider("CausticSize", m_profile.m_causticSize, 0.1f, 100f, helpEnabled);
|
||||
|
||||
EditorGUILayout.HelpBox("Caustics setup is applied directly to the Directional Light using the cookie setup.", MessageType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new user profile
|
||||
/// </summary>
|
||||
private void AddNewCustomProfile()
|
||||
{
|
||||
GaiaWaterProfileValues selectdValues = m_profileValues;
|
||||
GaiaWaterProfileValues newProfile = new GaiaWaterProfileValues();
|
||||
GaiaUtils.CopyFields(selectdValues, newProfile);
|
||||
int count = m_profile.m_waterProfiles.Count + 1;
|
||||
newProfile.m_typeOfWater = "New User Profile " + count;
|
||||
newProfile.m_userCustomProfile = true;
|
||||
m_profile.m_waterProfiles.Add(newProfile);
|
||||
|
||||
m_profile.m_selectedWaterProfileValuesIndex = m_profile.m_waterProfiles.Count - 1;
|
||||
|
||||
if (m_profile.m_selectedWaterProfileValuesIndex != -99)
|
||||
{
|
||||
GaiaUtils.GetRuntimeSceneObject();
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(m_profile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handy layer mask interface
|
||||
/// </summary>
|
||||
/// <param name="label"></param>
|
||||
/// <param name="layerMask"></param>
|
||||
/// <returns></returns>
|
||||
private static LayerMask LayerMaskField(string label, EditorUtils editorUtils, LayerMask layerMask)
|
||||
{
|
||||
List<string> layers = new List<string>();
|
||||
List<int> layerNumbers = new List<int>();
|
||||
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
if (layerName != "")
|
||||
{
|
||||
layers.Add(layerName);
|
||||
layerNumbers.Add(i);
|
||||
}
|
||||
}
|
||||
int maskWithoutEmpty = 0;
|
||||
for (int i = 0; i < layerNumbers.Count; i++)
|
||||
{
|
||||
if (((1 << layerNumbers[i]) & layerMask.value) > 0)
|
||||
maskWithoutEmpty |= (1 << i);
|
||||
}
|
||||
|
||||
label = editorUtils.GetContent(label).text;
|
||||
maskWithoutEmpty = EditorGUILayout.MaskField(label, maskWithoutEmpty, layers.ToArray());
|
||||
int mask = 0;
|
||||
for (int i = 0; i < layerNumbers.Count; i++)
|
||||
{
|
||||
if ((maskWithoutEmpty & (1 << i)) > 0)
|
||||
mask |= (1 << layerNumbers[i]);
|
||||
}
|
||||
layerMask.value = mask;
|
||||
return layerMask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates the gradient texture then bakes it into a file
|
||||
/// </summary>
|
||||
/// <param name="m_waterProfileValues"></param>
|
||||
/// <param name="path"></param>
|
||||
private void GenerateGradientTexture(GaiaWaterProfileValues m_waterProfileValues, string path)
|
||||
{
|
||||
if (m_waterTexture == null || m_waterTexture.wrapMode != TextureWrapMode.Clamp)
|
||||
{
|
||||
m_waterTexture = new Texture2D(m_waterProfileValues.m_gradientTextureResolution,
|
||||
m_waterProfileValues.m_gradientTextureResolution) {wrapMode = TextureWrapMode.Clamp};
|
||||
}
|
||||
else if (m_waterProfileValues.m_gradientTextureResolution != m_waterTexture.width)
|
||||
{
|
||||
m_waterTexture = new Texture2D(m_waterProfileValues.m_gradientTextureResolution,
|
||||
m_waterProfileValues.m_gradientTextureResolution) {wrapMode = TextureWrapMode.Clamp};
|
||||
}
|
||||
if (m_waterTexture != null)
|
||||
{
|
||||
for (int x = 0; x < m_waterProfileValues.m_gradientTextureResolution; x++)
|
||||
{
|
||||
for (int y = 0; y < m_waterProfileValues.m_gradientTextureResolution; y++)
|
||||
{
|
||||
Color color = m_waterProfileValues.m_waterGradient.Evaluate((float)x / (float)m_waterProfileValues.m_gradientTextureResolution);
|
||||
m_waterTexture.SetPixel(x, y, color);
|
||||
}
|
||||
}
|
||||
m_waterTexture.Apply();
|
||||
|
||||
GenerateTexture(m_waterTexture, path);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a texture based of a Unity Gradient
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
/// <param name="path"></param>
|
||||
private void GenerateTexture(Texture2D texture, string path)
|
||||
{
|
||||
path = path.Replace(Application.dataPath, "Assets");
|
||||
|
||||
var pngData = texture.EncodeToPNG();
|
||||
if (pngData != null)
|
||||
{
|
||||
File.WriteAllBytes(path, pngData);
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(texture);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.ImportAsset(path);
|
||||
m_profileValues.m_colorDepthRamp = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
|
||||
m_profileValues.m_colorDepthRamp.wrapMode = TextureWrapMode.Clamp;
|
||||
|
||||
m_waterTexture = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a default gradient for water surface coloring
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Gradient CreateNewWaterSurfaceGradient(int profileIdx)
|
||||
{
|
||||
Gradient gradient = new Gradient();
|
||||
|
||||
GradientColorKey[] colorKeys = new GradientColorKey[8];
|
||||
GradientAlphaKey[] alphaKeys = new GradientAlphaKey[2];
|
||||
|
||||
if (profileIdx == 1)
|
||||
{
|
||||
colorKeys[0].color = GaiaUtils.GetColorFromHTML("E9E1D3");
|
||||
colorKeys[0].time = 0f;
|
||||
|
||||
colorKeys[1].color = GaiaUtils.GetColorFromHTML("D9E0D0");
|
||||
colorKeys[1].time = 0.15f;
|
||||
|
||||
colorKeys[2].color = GaiaUtils.GetColorFromHTML("B2DFD1");
|
||||
colorKeys[2].time = 0.3f;
|
||||
|
||||
colorKeys[3].color = GaiaUtils.GetColorFromHTML("9ADFD4");
|
||||
colorKeys[3].time = 0.45f;
|
||||
|
||||
colorKeys[4].color = GaiaUtils.GetColorFromHTML("7DBCB2");
|
||||
colorKeys[4].time = 0.6f;
|
||||
|
||||
colorKeys[5].color = GaiaUtils.GetColorFromHTML("7BBCB1");
|
||||
colorKeys[5].time = 0.75f;
|
||||
|
||||
colorKeys[6].color = GaiaUtils.GetColorFromHTML("629B91");
|
||||
colorKeys[6].time = 0.9f;
|
||||
|
||||
colorKeys[7].color = GaiaUtils.GetColorFromHTML("5D988E");
|
||||
colorKeys[7].time = 1f;
|
||||
}
|
||||
else if (profileIdx == 2)
|
||||
{
|
||||
colorKeys[0].color = GaiaUtils.GetColorFromHTML("C9E9DA");
|
||||
colorKeys[0].time = 0f;
|
||||
|
||||
colorKeys[1].color = GaiaUtils.GetColorFromHTML("D4D4D4");
|
||||
colorKeys[1].time = 0.15f;
|
||||
|
||||
colorKeys[2].color = GaiaUtils.GetColorFromHTML("A4A4A4");
|
||||
colorKeys[2].time = 0.3f;
|
||||
|
||||
colorKeys[3].color = GaiaUtils.GetColorFromHTML("909090");
|
||||
colorKeys[3].time = 0.45f;
|
||||
|
||||
colorKeys[4].color = GaiaUtils.GetColorFromHTML("808080");
|
||||
colorKeys[4].time = 0.6f;
|
||||
|
||||
colorKeys[5].color = GaiaUtils.GetColorFromHTML("636363");
|
||||
colorKeys[5].time = 0.75f;
|
||||
|
||||
colorKeys[6].color = GaiaUtils.GetColorFromHTML("295571");
|
||||
colorKeys[6].time = 0.9f;
|
||||
|
||||
colorKeys[7].color = GaiaUtils.GetColorFromHTML("142E48");
|
||||
colorKeys[7].time = 1f;
|
||||
}
|
||||
else if (profileIdx == 3)
|
||||
{
|
||||
colorKeys[0].color = GaiaUtils.GetColorFromHTML("C9E9DA");
|
||||
colorKeys[0].time = 0f;
|
||||
|
||||
colorKeys[1].color = GaiaUtils.GetColorFromHTML("D4D4D4");
|
||||
colorKeys[1].time = 0.15f;
|
||||
|
||||
colorKeys[2].color = GaiaUtils.GetColorFromHTML("A4A4A4");
|
||||
colorKeys[2].time = 0.3f;
|
||||
|
||||
colorKeys[3].color = GaiaUtils.GetColorFromHTML("909090");
|
||||
colorKeys[3].time = 0.45f;
|
||||
|
||||
colorKeys[4].color = GaiaUtils.GetColorFromHTML("808080");
|
||||
colorKeys[4].time = 0.6f;
|
||||
|
||||
colorKeys[5].color = GaiaUtils.GetColorFromHTML("636363");
|
||||
colorKeys[5].time = 0.75f;
|
||||
|
||||
colorKeys[6].color = GaiaUtils.GetColorFromHTML("296171");
|
||||
colorKeys[6].time = 0.9f;
|
||||
|
||||
colorKeys[7].color = GaiaUtils.GetColorFromHTML("143F48");
|
||||
colorKeys[7].time = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
colorKeys[0].color = GaiaUtils.GetColorFromHTML("FCFDFC");
|
||||
colorKeys[0].time = 0f;
|
||||
|
||||
colorKeys[1].color = GaiaUtils.GetColorFromHTML("B5CAB9");
|
||||
colorKeys[1].time = 0.15f;
|
||||
|
||||
colorKeys[2].color = GaiaUtils.GetColorFromHTML("739A7B");
|
||||
colorKeys[2].time = 0.3f;
|
||||
|
||||
colorKeys[3].color = GaiaUtils.GetColorFromHTML("2D614A");
|
||||
colorKeys[3].time = 0.45f;
|
||||
|
||||
colorKeys[4].color = GaiaUtils.GetColorFromHTML("24554A");
|
||||
colorKeys[4].time = 0.6f;
|
||||
|
||||
colorKeys[5].color = GaiaUtils.GetColorFromHTML("1B434A");
|
||||
colorKeys[5].time = 0.75f;
|
||||
|
||||
colorKeys[6].color = GaiaUtils.GetColorFromHTML("1A3B4A");
|
||||
colorKeys[6].time = 0.9f;
|
||||
|
||||
colorKeys[7].color = GaiaUtils.GetColorFromHTML("17314A");
|
||||
colorKeys[7].time = 1f;
|
||||
}
|
||||
|
||||
alphaKeys[0].alpha = 1f;
|
||||
alphaKeys[0].time = 0f;
|
||||
|
||||
alphaKeys[1].alpha = 1f;
|
||||
alphaKeys[1].time = 1f;
|
||||
|
||||
gradient.SetKeys(colorKeys, alphaKeys);
|
||||
|
||||
return gradient;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efd984ab8857a054d97cb1d318a893bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
|
||||
[CanEditMultipleObjects]
|
||||
public class PW_WaterUnderMaterialEditor : ShaderGUI
|
||||
{
|
||||
MaterialProperty underWaterColor;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void FindProperties ( MaterialProperty[] props )
|
||||
{
|
||||
underWaterColor = FindProperty ( "_UnderWaterColor", props );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
public override void OnGUI ( MaterialEditor i_materialEditor, MaterialProperty[] i_properties )
|
||||
{
|
||||
FindProperties ( i_properties );
|
||||
|
||||
i_materialEditor.ShaderProperty( underWaterColor, new GUIContent("Tint", "Tint of underwater side"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2ad42cf5dd49477aa7a546d09345f14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,398 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
|
||||
|
||||
[CanEditMultipleObjects]
|
||||
public class PW_Water_MaterialEditor : ShaderGUI
|
||||
{
|
||||
// bool propsLoaded = false;
|
||||
MaterialEditor materialEditor;
|
||||
Material targetMat;
|
||||
|
||||
MaterialProperty ambientColor;
|
||||
MaterialProperty mainLightDir;
|
||||
MaterialProperty mainLightColor;
|
||||
MaterialProperty mainLightSpecular;
|
||||
MaterialProperty metallic;
|
||||
MaterialProperty smoothness;
|
||||
MaterialProperty reflectionTex;
|
||||
MaterialProperty reflectionColor;
|
||||
// MaterialProperty reflectionDistortion;
|
||||
// MaterialProperty reflectionStrength;
|
||||
|
||||
MaterialProperty normalLayer0;
|
||||
MaterialProperty normalLayer0Scale;
|
||||
MaterialProperty normalLayer1;
|
||||
MaterialProperty normalLayer1Scale;
|
||||
MaterialProperty normalLayer2;
|
||||
MaterialProperty normalLayer2Scale;
|
||||
MaterialProperty normalTile;
|
||||
MaterialProperty normalFadeMap;
|
||||
MaterialProperty normalFadeStart;
|
||||
MaterialProperty normalFadeDist;
|
||||
|
||||
MaterialProperty foamTex;
|
||||
MaterialProperty foamTexTile;
|
||||
MaterialProperty foamDepth;
|
||||
MaterialProperty foamStrength;
|
||||
MaterialProperty waterDepthRamp;
|
||||
MaterialProperty transparentDepth;
|
||||
MaterialProperty transparentMin;
|
||||
|
||||
MaterialProperty waveLength;
|
||||
MaterialProperty waveSteepness;
|
||||
MaterialProperty waveSpeed;
|
||||
MaterialProperty waveDirection;
|
||||
MaterialProperty waveShoreClamp;
|
||||
MaterialProperty waveDirGlobal;
|
||||
MaterialProperty waveBackwashToggle;
|
||||
MaterialProperty wavePeakToggle;
|
||||
|
||||
MaterialProperty sssToggle;
|
||||
MaterialProperty sssPower;
|
||||
MaterialProperty sssDistortion;
|
||||
MaterialProperty sssTint;
|
||||
|
||||
MaterialProperty edgeWaterColor;
|
||||
MaterialProperty edgeWaterDist;
|
||||
|
||||
string _toolTip ="";
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void FindProperties ( MaterialProperty[] props )
|
||||
{
|
||||
ambientColor = FindProperty ( "_AmbientColor", props );
|
||||
mainLightDir = FindProperty ( "_PW_MainLightDir", props );
|
||||
mainLightColor = FindProperty ( "_PW_MainLightColor", props );
|
||||
mainLightSpecular = FindProperty ( "_PW_MainLightSpecular", props );
|
||||
|
||||
metallic = FindProperty ( "_Metallic", props );
|
||||
smoothness = FindProperty ( "_Smoothness", props );
|
||||
//reflectionTex = FindProperty ( "_ReflectionTex", props );
|
||||
reflectionColor = FindProperty ( "_ReflectionColor", props );
|
||||
// reflectionDistortion = FindProperty ( "_ReflectionDistortion", props );
|
||||
// reflectionStrength = FindProperty ( "_ReflectionStrength", props );
|
||||
|
||||
normalLayer0 = FindProperty ( "_NormalLayer0", props );
|
||||
normalLayer0Scale = FindProperty ( "_NormalLayer0Scale", props );
|
||||
normalLayer1 = FindProperty ( "_NormalLayer1", props );
|
||||
normalLayer1Scale = FindProperty ( "_NormalLayer1Scale", props );
|
||||
normalLayer2 = FindProperty ( "_NormalLayer2", props );
|
||||
normalLayer2Scale = FindProperty ( "_NormalLayer2Scale", props );
|
||||
normalTile = FindProperty ( "_NormalTile", props );
|
||||
normalFadeMap = FindProperty ( "_NormalFadeMap", props );
|
||||
normalFadeStart = FindProperty ( "_NormalFadeStart", props );
|
||||
normalFadeDist = FindProperty ( "_NormalFadeDistance", props );
|
||||
// normalMoveSpeed = FindProperty ( "_NormalMoveSpeed", props );
|
||||
|
||||
foamTex = FindProperty ( "_FoamTex", props );
|
||||
foamTexTile = FindProperty ( "_FoamTexTile", props );
|
||||
foamDepth = FindProperty ( "_FoamDepth", props );
|
||||
foamStrength = FindProperty ( "_FoamStrength", props );
|
||||
waterDepthRamp = FindProperty ( "_WaterDepthRamp", props );
|
||||
transparentDepth = FindProperty ( "_TransparentDepth", props );
|
||||
transparentMin = FindProperty ( "_TransparentMin", props );
|
||||
|
||||
waveDirGlobal = FindProperty ( "_WaveDirGlobal", props );
|
||||
waveBackwashToggle = FindProperty ( "_WaveBackwashToggle", props );
|
||||
wavePeakToggle = FindProperty ( "_WavePeakToggle", props );
|
||||
waveLength = FindProperty ( "_WaveLength", props );
|
||||
waveSteepness = FindProperty ( "_WaveSteepness", props );
|
||||
waveSpeed = FindProperty ( "_WaveSpeed", props );
|
||||
waveDirection = FindProperty ( "_WaveDirection", props );
|
||||
waveShoreClamp = FindProperty ( "_WaveShoreClamp", props );
|
||||
|
||||
sssToggle = FindProperty ( "_PW_SSS" , props );
|
||||
sssPower = FindProperty ( "_PW_SSSPower" , props );
|
||||
sssDistortion = FindProperty ( "_PW_SSSDistortion" , props );
|
||||
sssTint = FindProperty ( "_PW_SSSTint" , props );
|
||||
|
||||
edgeWaterColor = FindProperty ( "_EdgeWaterColor" , props );
|
||||
edgeWaterDist = FindProperty ( "_EdgeWaterDist" , props );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void Toggle ( MaterialProperty i_matProp, string i_name )
|
||||
{
|
||||
bool flag = false;
|
||||
|
||||
if ( i_matProp.floatValue > 0.0f )
|
||||
flag = true;
|
||||
|
||||
flag = EditorGUILayout.Toggle ( i_name, flag );
|
||||
|
||||
if ( flag )
|
||||
i_matProp.floatValue = 1;
|
||||
else
|
||||
i_matProp.floatValue = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private static void Line( int i_height = 1 )
|
||||
{
|
||||
Rect rect = EditorGUILayout.GetControlRect(false, i_height + 1);
|
||||
rect.height = i_height;
|
||||
EditorGUI.DrawRect(rect, new Color ( 0.5f,0.5f,0.5f, 1 ) );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private static void Header ( string i_name, bool i_first = false )
|
||||
{
|
||||
if (!i_first)
|
||||
EditorGUILayout.LabelField (" ");
|
||||
|
||||
EditorGUILayout.LabelField ( i_name );
|
||||
Line();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private static void SetShaderFeature ( Material i_mat, bool i_toggle, string i_keyword )
|
||||
{
|
||||
if ( i_toggle )
|
||||
i_mat.EnableKeyword ( i_keyword );
|
||||
else
|
||||
i_mat.DisableKeyword ( i_keyword );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void SetShaderKeywords()
|
||||
{
|
||||
SetShaderFeature ( targetMat, sssToggle.floatValue > 0.01f, "_PW_SF_SSS_ON" );
|
||||
SetShaderFeature ( targetMat, waveDirGlobal.floatValue > 0.01f, "_PW_SF_WAVEDIR_GLOBAL_ON" );
|
||||
SetShaderFeature ( targetMat, waveBackwashToggle.floatValue > 0.01f, "_PW_SF_WAVE_BACKWASH_ON" );
|
||||
SetShaderFeature ( targetMat, wavePeakToggle.floatValue > 0.01f, "_PW_SF_WAVE_PEAK_ON" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void LightingGUI()
|
||||
{
|
||||
Header ( "Main Directional Light:", true );
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
_toolTip = "Main light directional vector";
|
||||
materialEditor.ShaderProperty ( mainLightDir, new GUIContent( "Direction", _toolTip ) );
|
||||
EditorGUILayout.LabelField (" ");
|
||||
|
||||
_toolTip = "Light Color and intesity ";
|
||||
materialEditor.ShaderProperty ( mainLightColor, new GUIContent( "Color", _toolTip ) );
|
||||
|
||||
_toolTip = "Light Specular color";
|
||||
materialEditor.ShaderProperty ( mainLightSpecular, new GUIContent( "Specular", _toolTip ) );
|
||||
|
||||
_toolTip = "Ambient Light";
|
||||
materialEditor.ShaderProperty ( ambientColor, new GUIContent( "Ambient Light", _toolTip ) );
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void WaterSurfaceGUI()
|
||||
{
|
||||
Header ( "Water Surface:" );
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.TexturePropertySingleLine ( new GUIContent( "Layer 0", _toolTip ), normalLayer0, normalLayer0Scale );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.TexturePropertySingleLine ( new GUIContent( "Layer 1", _toolTip ), normalLayer1, normalLayer1Scale );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.TexturePropertySingleLine ( new GUIContent( "Layer Fade", _toolTip ), normalLayer2, normalLayer2Scale );
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.TexturePropertySingleLine ( new GUIContent( "Scale Map", _toolTip ), normalFadeMap );
|
||||
|
||||
// _toolTip = "Tooltip desc";
|
||||
// materialEditor.ShaderProperty ( normalMoveSpeed, new GUIContent( "Move Speed", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( normalTile, new GUIContent( "Tiling", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( normalFadeStart, new GUIContent( "Fade Start", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( normalFadeDist, new GUIContent( "Fade Distance", _toolTip ) );
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void WaterEdgeGUI()
|
||||
{
|
||||
Header ( "Water Edge:" );
|
||||
|
||||
_toolTip = "color of water edge near camera";
|
||||
materialEditor.ShaderProperty ( edgeWaterColor, new GUIContent( "Color", _toolTip ) );
|
||||
|
||||
_toolTip = "Distance From Camera";
|
||||
materialEditor.ShaderProperty ( edgeWaterDist, new GUIContent( "Distance", _toolTip ) );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void SSSGUI()
|
||||
{
|
||||
Header ( "Translucent:" );
|
||||
Toggle ( sssToggle, "enabled" );
|
||||
|
||||
if ( sssToggle.floatValue > 0.0f )
|
||||
{
|
||||
materialEditor.DefaultShaderProperty ( sssTint, "Tint" );
|
||||
materialEditor.DefaultShaderProperty ( sssPower, "Power" );
|
||||
materialEditor.DefaultShaderProperty ( sssDistortion, "Distortion" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void PBRGUI()
|
||||
{
|
||||
Header ( "PBR:" );
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( metallic, new GUIContent( "Metallic", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( smoothness, new GUIContent( "Smoothness", _toolTip ) );
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void ReflectionGUI()
|
||||
{
|
||||
Header ( "Reflection:" );
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( reflectionColor, new GUIContent( "Color", _toolTip ) );
|
||||
// _toolTip = "Tooltip desc";
|
||||
// materialEditor.ShaderProperty ( reflectionStrength, new GUIContent( "Strength", _toolTip ) );
|
||||
// _toolTip = "Tooltip desc";
|
||||
// materialEditor.ShaderProperty ( reflectionDistortion, new GUIContent( "Distortion", _toolTip ) );
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void WavesGUI()
|
||||
{
|
||||
Header ( "Waves:" );
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( waveLength, new GUIContent( "Wavelength", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( waveSteepness, new GUIContent( "Steepness", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( waveSpeed, new GUIContent( "Speed", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( waveShoreClamp, new GUIContent( "Shore Clamp", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
|
||||
// Toggle ( waveBackwashToggle, "Backwash Foam" );
|
||||
// Toggle ( wavePeakToggle, "Peak Foam" );
|
||||
|
||||
EditorGUILayout.LabelField (" ");
|
||||
Toggle ( waveDirGlobal, "System Direction" );
|
||||
|
||||
if (waveDirGlobal.floatValue < 0.9)
|
||||
{
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( waveDirection, new GUIContent( "Direction", _toolTip ) );
|
||||
}
|
||||
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void FoamGUI()
|
||||
{
|
||||
Header ( "Foam:" );
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.TexturePropertySingleLine ( new GUIContent( "Foam", _toolTip ), foamTex );
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( foamTexTile, new GUIContent( "Tiling", _toolTip ) );
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( foamDepth, new GUIContent( "Depth", _toolTip ) );
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( foamStrength, new GUIContent( "Strength", _toolTip ) );
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void DepthGUI()
|
||||
{
|
||||
Header ( "Water Depth:" );
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.TexturePropertySingleLine ( new GUIContent( "Depth Ramp", _toolTip ), waterDepthRamp );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( transparentDepth, new GUIContent( "Depth", _toolTip ) );
|
||||
materialEditor.ShaderProperty ( transparentMin, new GUIContent( "Minimum Alpha", _toolTip ) );
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
private void DataMapGUI()
|
||||
{
|
||||
Header ( "DataMap:" );
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.TexturePropertySingleLine ( new GUIContent( "Data Map", _toolTip ), dataMap );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( dataMapOffsetX, new GUIContent( "Offset X", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( dataMapOffsetZ, new GUIContent( "Offset Z", _toolTip ) );
|
||||
_toolTip = "Tooltip desc";
|
||||
materialEditor.ShaderProperty ( dataMapPointScale, new GUIContent( "Point Scale", _toolTip ) );
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
*/
|
||||
|
||||
//=====================================================================
|
||||
public override void OnGUI ( MaterialEditor i_materialEditor, MaterialProperty[] i_properties )
|
||||
{
|
||||
materialEditor = i_materialEditor;
|
||||
targetMat = i_materialEditor.target as Material;
|
||||
|
||||
FindProperties ( i_properties );
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
LightingGUI();
|
||||
PBRGUI();
|
||||
ReflectionGUI();
|
||||
SSSGUI();
|
||||
WaterSurfaceGUI();
|
||||
//WaterEdgeGUI();
|
||||
WavesGUI();
|
||||
FoamGUI();
|
||||
DepthGUI();
|
||||
//DataMapGUI();
|
||||
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
SetShaderKeywords();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7d09f386590c40ee9f190288adc325c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,76 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
public class FollowPlayerSystem : MonoBehaviour
|
||||
{
|
||||
[Header("Global Settings")]
|
||||
public bool m_followPlayer = true;
|
||||
public bool m_isWaterObject = false;
|
||||
public List<GameObject> m_particleObjects = new List<GameObject>();
|
||||
public Transform m_player;
|
||||
|
||||
public bool m_useOffset = false;
|
||||
public float m_xoffset = 1250f;
|
||||
public float m_zoffset = 300f;
|
||||
public float m_yOffset = 200f;
|
||||
|
||||
public bool m_useScale = false;
|
||||
public Vector3 m_scaleSize = new Vector3(1f, 1f, 1f);
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (m_player == null)
|
||||
{
|
||||
if (GaiaUtils.GetCamera() != null)
|
||||
{
|
||||
m_player = GaiaUtils.GetCamera().transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (m_followPlayer)
|
||||
{
|
||||
if (m_player)
|
||||
{
|
||||
if (m_particleObjects != null)
|
||||
{
|
||||
foreach (GameObject particleObject in m_particleObjects)
|
||||
{
|
||||
if (!m_useOffset)
|
||||
{
|
||||
particleObject.transform.position = m_player.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_isWaterObject)
|
||||
{
|
||||
if (m_player.position.y < 1f)
|
||||
{
|
||||
particleObject.transform.position = new Vector3(m_player.position.x + m_xoffset, m_player.position.y + 70f - m_yOffset, m_player.position.z - m_zoffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
particleObject.transform.position = new Vector3(m_player.position.x + m_xoffset, m_player.position.y + 10 - m_yOffset, m_player.position.z - m_zoffset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
particleObject.transform.position = new Vector3(m_player.position.x + m_xoffset, m_player.position.y - m_yOffset, m_player.position.z - m_zoffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_useScale)
|
||||
{
|
||||
gameObject.transform.localScale = m_scaleSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b047a543462fbfd49a02027ee92216e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e0e98e131e8a044da03df5ad372602c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,174 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using ProceduralWorlds.WaterSystem;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
public class GaiaWaterProfile : ScriptableObject
|
||||
{
|
||||
[HideInInspector]
|
||||
public bool m_reimportHDRPShader = false;
|
||||
[HideInInspector]
|
||||
public bool m_multiSceneLightingSupport = true;
|
||||
[HideInInspector]
|
||||
public bool m_renamingProfile = false;
|
||||
[HideInInspector]
|
||||
public bool m_updateInRealtime = false;
|
||||
[HideInInspector]
|
||||
public bool m_allowMSAA = false;
|
||||
[HideInInspector]
|
||||
public bool m_useHDR = false;
|
||||
[HideInInspector]
|
||||
public bool m_enableDisabeHeightFeature = true;
|
||||
[HideInInspector]
|
||||
public float m_disableHeight = 100f;
|
||||
[HideInInspector]
|
||||
public string m_selectedProfile = "Deep Blue Ocean";
|
||||
// [HideInInspector]
|
||||
// public GaiaConstants.RenderUpdateMode m_waterRenderUpdateMode = GaiaConstants.RenderUpdateMode.Update;
|
||||
[HideInInspector]
|
||||
public float m_interval = 0.25f;
|
||||
[HideInInspector]
|
||||
public bool m_useCustomRenderDistance = false;
|
||||
[HideInInspector]
|
||||
public bool m_enableLayerDistances = false;
|
||||
[HideInInspector]
|
||||
public float m_customRenderDistance = 500f;
|
||||
[HideInInspector]
|
||||
public float[] m_customRenderDistances = new float[32];
|
||||
[HideInInspector]
|
||||
public GaiaPlanarReflections.PlanarReflectionSettings m_reflectionSettingsData;
|
||||
[HideInInspector]
|
||||
public bool m_editSettings = false;
|
||||
[HideInInspector]
|
||||
public int m_selectedWaterProfileValuesIndex;
|
||||
|
||||
[HideInInspector]
|
||||
public bool m_useCastics = true;
|
||||
[HideInInspector]
|
||||
public Light m_mainCausticLight;
|
||||
[HideInInspector]
|
||||
public int m_causticFramePerSecond = 24;
|
||||
[HideInInspector]
|
||||
public float m_causticSize = 15f;
|
||||
|
||||
//[HideInInspector]
|
||||
//public Material m_masterWaterMaterial;
|
||||
[HideInInspector]
|
||||
public GameObject m_waterPrefab;
|
||||
[HideInInspector]
|
||||
public GameObject m_underwaterParticles;
|
||||
[HideInInspector]
|
||||
public GameObject m_underwaterHorizonPrefab;
|
||||
[HideInInspector]
|
||||
public GameObject m_hdPlanarReflections;
|
||||
[HideInInspector]
|
||||
public GameObject m_transitionFXPrefab;
|
||||
|
||||
public List<GaiaWaterProfileValues> m_waterProfiles = new List<GaiaWaterProfileValues>();
|
||||
[HideInInspector]
|
||||
public Material m_activeWaterMaterial;
|
||||
|
||||
[HideInInspector]
|
||||
public bool m_enableWaterMeshQuality = false;
|
||||
[HideInInspector]
|
||||
public GaiaConstants.WaterMeshQuality m_waterMeshQuality = GaiaConstants.WaterMeshQuality.Medium;
|
||||
[HideInInspector]
|
||||
public GaiaConstants.MeshType m_meshType = GaiaConstants.MeshType.Plane;
|
||||
[HideInInspector]
|
||||
public int m_zSize = 1000;
|
||||
[HideInInspector]
|
||||
public int m_xSize = 1000;
|
||||
[HideInInspector]
|
||||
public int m_customMeshQuality = 100;
|
||||
|
||||
[HideInInspector]
|
||||
public bool m_enableReflections = true;
|
||||
[HideInInspector]
|
||||
public bool m_disablePixelLights = true;
|
||||
[HideInInspector]
|
||||
public GaiaConstants.GaiaProWaterReflectionsQuality m_reflectionResolution = GaiaConstants.GaiaProWaterReflectionsQuality.Resolution512;
|
||||
[HideInInspector]
|
||||
public int m_textureResolution = 512;
|
||||
[HideInInspector]
|
||||
public float m_clipPlaneOffset = 40f;
|
||||
[HideInInspector]
|
||||
public LayerMask m_reflectedLayers = 1;
|
||||
[HideInInspector]
|
||||
public float m_hdrpReflectionIntensity = 1f;
|
||||
|
||||
[HideInInspector]
|
||||
public bool m_enableOceanFoam = true;
|
||||
[HideInInspector]
|
||||
public bool m_enableBeachFoam = true;
|
||||
[HideInInspector]
|
||||
public bool m_enableGPUInstancing = true;
|
||||
[HideInInspector]
|
||||
public bool m_autoWindControlOnWater = true;
|
||||
|
||||
[HideInInspector]
|
||||
public bool m_supportUnderwaterEffects = true;
|
||||
[HideInInspector]
|
||||
public bool m_supportUnderwaterPostProcessing = true;
|
||||
[HideInInspector]
|
||||
public bool m_supportUnderwaterFog = true;
|
||||
[HideInInspector]
|
||||
public bool m_supportUnderwaterParticles = true;
|
||||
|
||||
public void UpdateTextureResolution()
|
||||
{
|
||||
switch (m_reflectionResolution)
|
||||
{
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution8:
|
||||
m_textureResolution = 8;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution16:
|
||||
m_textureResolution = 16;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution32:
|
||||
m_textureResolution = 32;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution64:
|
||||
m_textureResolution = 64;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution128:
|
||||
m_textureResolution = 128;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution256:
|
||||
m_textureResolution = 256;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution512:
|
||||
m_textureResolution = 512;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution1024:
|
||||
m_textureResolution = 1024;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution2048:
|
||||
m_textureResolution = 2048;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution4096:
|
||||
m_textureResolution = 4096;
|
||||
break;
|
||||
case GaiaConstants.GaiaProWaterReflectionsQuality.Resolution8192:
|
||||
m_textureResolution = 8192;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create Gaia Lighting System Profile asset
|
||||
/// </summary>
|
||||
#if UNITY_EDITOR
|
||||
[MenuItem("Assets/Create/Procedural Worlds/Gaia/Water Profile")]
|
||||
public static void CreateSkyProfiles()
|
||||
{
|
||||
GaiaWaterProfile asset = ScriptableObject.CreateInstance<GaiaWaterProfile>();
|
||||
AssetDatabase.CreateAsset(asset, "Assets/Gaia Water System Profile.asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
EditorUtility.FocusProjectWindow();
|
||||
Selection.activeObject = asset;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0f227aa1d044cb419fe91f983e8ab3b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: dffcb73693a3ab445abdc7e1ad4b8bb3, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,176 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
#endif
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[System.Serializable]
|
||||
public class GaiaWaterProfileValues
|
||||
{
|
||||
[Header("Global Settings")]
|
||||
public string m_typeOfWater = "Deep Blue Ocean";
|
||||
public string m_profileRename;
|
||||
public bool m_userCustomProfile = false;
|
||||
|
||||
[Header("Post Processing Settings")]
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
[SerializeField]
|
||||
private PostProcessProfile m_postProcessProfileBuiltIn = null;
|
||||
public PostProcessProfile PostProcessProfileBuiltIn
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_postProcessProfileBuiltIn == null && m_postProcessingProfileGUIDBuiltIn !=null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
m_postProcessProfileBuiltIn = (PostProcessProfile)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_postProcessingProfileGUIDBuiltIn),typeof(PostProcessProfile));
|
||||
#endif
|
||||
}
|
||||
return m_postProcessProfileBuiltIn;
|
||||
}
|
||||
set
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
m_postProcessingProfileGUIDBuiltIn = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(value));
|
||||
m_postProcessProfileBuiltIn = value;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//need this serialized to remember the GUID even when PP is not installed in the project
|
||||
public string m_postProcessingProfileGUIDBuiltIn = "";
|
||||
public bool m_directToCamera = true;
|
||||
#if UPPipeline
|
||||
[Header("URP Post Processign Settings")]
|
||||
[SerializeField]
|
||||
private VolumeProfile m_postProcessProfileURP = null;
|
||||
public VolumeProfile PostProcessProfileURP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_postProcessProfileURP == null && m_postProcessingProfileGUIDURP !=null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
m_postProcessProfileURP = (VolumeProfile)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_postProcessingProfileGUIDURP),typeof(VolumeProfile));
|
||||
#endif
|
||||
}
|
||||
return m_postProcessProfileURP;
|
||||
}
|
||||
set
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
m_postProcessingProfileGUIDURP = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(value));
|
||||
m_postProcessProfileURP = value;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//need this serialized to remember the GUID even when PP is not installed in the project
|
||||
public string m_postProcessingProfileGUIDURP = "";
|
||||
|
||||
#if HDPipeline
|
||||
[Header("HDRP Post Processing Settings")]
|
||||
[SerializeField]
|
||||
private VolumeProfile m_postProcessProfileHDRP = null;
|
||||
public VolumeProfile PostProcessProfileHDRP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_postProcessProfileHDRP == null && m_postProcessingProfileGUIDHDRP !=null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
m_postProcessProfileHDRP = (VolumeProfile)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_postProcessingProfileGUIDHDRP),typeof(VolumeProfile));
|
||||
#endif
|
||||
}
|
||||
return m_postProcessProfileHDRP;
|
||||
}
|
||||
set
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
m_postProcessingProfileGUIDHDRP = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(value));
|
||||
m_postProcessProfileHDRP = value;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//need this serialized to remember the GUID even when PP is not installed in the project
|
||||
[SerializeField]
|
||||
public string m_postProcessingProfileGUIDHDRP = "";
|
||||
|
||||
[Header("Underwater Effects")]
|
||||
public Gradient m_underwaterFogGradient;
|
||||
public Color m_underwaterFogColor = Color.cyan;
|
||||
public float m_underwaterFogDepth = 100f;
|
||||
public float m_underwaterFogDistance = 45f;
|
||||
public float m_underwaterNearFogDistance = -4f;
|
||||
public float m_underwaterFogDensity = 0.045f;
|
||||
public float m_constUnderwaterPostExposure = 0f;
|
||||
public AnimationCurve m_gradientUnderwaterPostExposure = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 0f));
|
||||
public Color m_constUnderwaterColorFilter = Color.white;
|
||||
public Gradient m_gradientUnderwaterColorFilter = new Gradient();
|
||||
|
||||
[Header("Texture Settings")]
|
||||
public Texture2D m_colorDepthRamp;
|
||||
public Texture2D m_normalLayer0;
|
||||
public Texture2D m_normalLayer1;
|
||||
public Texture2D m_fadeNormal;
|
||||
public Texture2D m_foamTexture;
|
||||
public Texture2D m_foamAlphaRamp;
|
||||
public Texture2D m_renderTexture;
|
||||
public Texture2D m_foamBubbleTexture;
|
||||
|
||||
[Header("Water Setup")]
|
||||
public GaiaConstants.PW_RENDER_SIZE m_refractionRenderResolution = GaiaConstants.PW_RENDER_SIZE.HALF;
|
||||
public Gradient m_waterGradient;
|
||||
public int m_gradientTextureResolution = 128;
|
||||
public int m_foamTiling = 128;
|
||||
public int m_waterTiling = 256;
|
||||
public float m_shorelineMovement = 0.1f;
|
||||
public float m_waveCount = 0.2f;
|
||||
public float m_waveSpeed = 3f;
|
||||
public float m_waveSize = 0.26f;
|
||||
public float m_transparentDistance = 10f;
|
||||
public float m_foamDistance = 8f;
|
||||
public float m_reflectionDistortion = 0.7f;
|
||||
public float m_reflectionStrength = 0.5f;
|
||||
public Color m_specularColor = Color.white;
|
||||
public float m_metallic = 0.25f;
|
||||
public float m_smoothness = 0.9f;
|
||||
public float m_normalStrength0 = 0.4f;
|
||||
public float m_normalStrength1 = 0.8f;
|
||||
public float m_fadeNormalStrength = 1f;
|
||||
public float m_fadeStart = 32f;
|
||||
public float m_fadeDistance = 128f;
|
||||
public float m_foamBubbleScale = 0.2f;
|
||||
public int m_foamBubbleTiling = 1024;
|
||||
public float m_foamStrength = 4f;
|
||||
public float m_foamBubblesStrength = 1f;
|
||||
public float m_foamEdge = 1f;
|
||||
public float m_foamMoveSpeed = 0.3f;
|
||||
|
||||
private void RemoveWarnings()
|
||||
{
|
||||
if (m_postProcessingProfileGUIDBuiltIn.Length == 0)
|
||||
{
|
||||
m_postProcessingProfileGUIDBuiltIn = "";
|
||||
}
|
||||
|
||||
if (m_postProcessingProfileGUIDURP.Length == 0)
|
||||
{
|
||||
m_postProcessingProfileGUIDURP = "";
|
||||
}
|
||||
|
||||
if (m_postProcessingProfileGUIDHDRP.Length == 0)
|
||||
{
|
||||
m_postProcessingProfileGUIDHDRP = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4173812a377bd864b84fdcc869440da5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class PW_Camera_Depth : MonoBehaviour
|
||||
{
|
||||
//private RenderTexture _renTex;
|
||||
private Material _mat;
|
||||
private Mesh _mesh;
|
||||
public Light mainLight;
|
||||
public GameObject waterGO;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Camera.main.depthTextureMode = DepthTextureMode.Depth;
|
||||
Vector3 lightDir;
|
||||
|
||||
lightDir.x = -mainLight.transform.forward.x;
|
||||
lightDir.y = -mainLight.transform.forward.y;
|
||||
lightDir.z = -mainLight.transform.forward.z;
|
||||
|
||||
//_renTex = new RenderTexture(512,512,1);
|
||||
|
||||
if (waterGO!=null)
|
||||
_mat = waterGO.GetComponent<Renderer>().sharedMaterial;
|
||||
|
||||
if ( _mat!=null )
|
||||
{
|
||||
_mat.SetVector ("_PW_MainLightDir", -mainLight.transform.forward );
|
||||
_mat.SetVector ("_PW_MainLightColor", mainLight.color * mainLight.intensity );
|
||||
}
|
||||
|
||||
Shader.SetGlobalVector ("_PW_MainLightDir", -mainLight.transform.forward );
|
||||
Shader.SetGlobalVector ("_PW_MainLightColor", mainLight.color * mainLight.intensity );
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Matrix4x4 matx = Matrix4x4.TRS(waterGO.transform.position, waterGO.transform.rotation, new Vector3(512,1,512));
|
||||
Vector3 lightDir;
|
||||
|
||||
lightDir.x = -mainLight.transform.forward.x;
|
||||
lightDir.y = -mainLight.transform.forward.y;
|
||||
lightDir.z = -mainLight.transform.forward.z;
|
||||
|
||||
if (_mat!=null)
|
||||
{
|
||||
_mat.SetVector ("_PW_MainLightDir", -mainLight.transform.forward );
|
||||
_mat.SetVector ("_PW_MainLightColor", mainLight.color * mainLight.intensity );
|
||||
|
||||
}
|
||||
|
||||
Shader.SetGlobalVector ("_PW_MainLightDir", -mainLight.transform.forward );
|
||||
Shader.SetGlobalVector ("_PW_MainLightColor", mainLight.color * mainLight.intensity );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46672454030d248e09e5363c2b2e89bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class PW_Camera_Refraction : MonoBehaviour
|
||||
{
|
||||
private CameraEvent _cameraEvent = CameraEvent.AfterForwardOpaque;
|
||||
private CommandBuffer _cbuf;
|
||||
private string _cbufName = "Echo_Refaction";
|
||||
private int _grabID;
|
||||
private int _screenWidth = 0;
|
||||
private int _screenHeight = 0;
|
||||
private Camera _camera;
|
||||
|
||||
[System.Serializable]
|
||||
public enum PW_RENDER_SIZE
|
||||
{
|
||||
FULL = -1,
|
||||
HALF = -2,
|
||||
QUARTER = -3
|
||||
};
|
||||
|
||||
public PW_RENDER_SIZE renderSize = PW_RENDER_SIZE.HALF;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void CommandBufferDestroy( Camera i_cam )
|
||||
{
|
||||
if ( i_cam == null )
|
||||
return;
|
||||
|
||||
if ( _cbuf != null)
|
||||
{
|
||||
i_cam.RemoveCommandBuffer ( _cameraEvent, _cbuf );
|
||||
_cbuf.Clear();
|
||||
_cbuf.Dispose();
|
||||
_cbuf = null;
|
||||
}
|
||||
|
||||
CommandBuffer[] commandBuffers = i_cam.GetCommandBuffers ( _cameraEvent );
|
||||
|
||||
foreach ( CommandBuffer cbuf in commandBuffers )
|
||||
{
|
||||
if ( cbuf.name == _cbufName )
|
||||
{
|
||||
i_cam.RemoveCommandBuffer ( _cameraEvent, cbuf );
|
||||
cbuf.Clear();
|
||||
cbuf.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
private void CommandBufferCreate()
|
||||
{
|
||||
CommandBufferDestroy(_camera);
|
||||
|
||||
_cbuf = new CommandBuffer();
|
||||
_cbuf.name = _cbufName;
|
||||
_cbuf.Clear();
|
||||
|
||||
_cbuf.GetTemporaryRT ( _grabID, (int)renderSize, (int)renderSize, 0, FilterMode.Bilinear );
|
||||
_cbuf.Blit ( BuiltinRenderTextureType.CurrentActive, _grabID );
|
||||
_cbuf.SetGlobalTexture ( "_CameraOpaqueTexture", _grabID );
|
||||
|
||||
_camera.AddCommandBuffer ( _cameraEvent, _cbuf );
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
void OnPreRender()
|
||||
{
|
||||
if ( _screenHeight != _camera.pixelHeight || _screenWidth != _camera.pixelWidth)
|
||||
{
|
||||
_screenWidth = _camera.pixelWidth;
|
||||
_screenHeight = _camera.pixelHeight;
|
||||
|
||||
CommandBufferCreate();
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
void OnDisable()
|
||||
{
|
||||
CommandBufferDestroy(_camera);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
void OnEnable()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
|
||||
if ( _camera == null )
|
||||
_camera = Camera.main;
|
||||
|
||||
_screenWidth = _camera.pixelWidth;
|
||||
_screenHeight = _camera.pixelHeight;
|
||||
|
||||
CommandBufferCreate();
|
||||
|
||||
_grabID = Shader.PropertyToID ( "_EchoTemp" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47fa6b608bf8d4aa0a4f4c04b8ee8de3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9893f2a153b52b544ac10692f1ccc432
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05af7bf41f38afe409054c460ba51593
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[CustomEditor(typeof(GaiaPlanarReflections))]
|
||||
public class GaiaPlanarReflectionsEditor : Editor
|
||||
{
|
||||
private const string m_helpText = "Gaia Planar Reflections is the reflection system for SRP this system only work in URP/HDRP. This system uses the SRP camera commands to render reflections in realtime. This system also supports shadows, custom render distances and unity layers.";
|
||||
private GaiaPlanarReflections m_reflections;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (m_reflections == null)
|
||||
{
|
||||
m_reflections = (GaiaPlanarReflections) target;
|
||||
}
|
||||
//Initialization
|
||||
EditorGUILayout.HelpBox(m_helpText, MessageType.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb560212dad63024b9985a1d559addcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using PWCommon4;
|
||||
using Gaia.Internal;
|
||||
using Gaia;
|
||||
|
||||
namespace ProceduralWorlds.WaterSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor for the PWS_WaterReflections
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(PWS_WaterSystem))]
|
||||
public class PWS_WaterReflectionsEditor : PWEditor
|
||||
{
|
||||
private EditorUtils m_editorUtils;
|
||||
private PWS_WaterSystem WaterReflections;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
WaterReflections = (PWS_WaterSystem)target;
|
||||
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
m_editorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
}
|
||||
|
||||
#region Inspector Region
|
||||
|
||||
/// <summary>
|
||||
/// Custom editor for PWS_WaterReflections
|
||||
/// </summary
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
//Initialization
|
||||
m_editorUtils.Initialize(); // Do not remove this!
|
||||
|
||||
if (WaterReflections == null)
|
||||
{
|
||||
WaterReflections = (PWS_WaterSystem)target;
|
||||
}
|
||||
|
||||
m_editorUtils.Panel("GlobalSettings", GlobalSettings, true);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorUtility.SetDirty(WaterReflections);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Panel
|
||||
|
||||
/// <summary>
|
||||
/// Global Main Panel
|
||||
/// </summary>
|
||||
/// <param name="helpEnabled"></param>
|
||||
private void GlobalSettings(bool helpEnabled)
|
||||
{
|
||||
m_editorUtils.Heading("Setup");
|
||||
EditorGUI.indentLevel++;
|
||||
WaterReflections.SunLight = (Light)m_editorUtils.ObjectField("SunLight", WaterReflections.SunLight, typeof(Light), true, helpEnabled);
|
||||
WaterReflections.m_player = (Transform)m_editorUtils.ObjectField("Player", WaterReflections.m_player, typeof(Transform), true, helpEnabled);
|
||||
WaterReflections.SeaLevel = m_editorUtils.FloatField("SeaLevel", WaterReflections.SeaLevel, helpEnabled);
|
||||
WaterReflections.InfiniteMode = m_editorUtils.Toggle("InfiniteMode", WaterReflections.InfiniteMode, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
/*m_editorUtils.Heading("SurfaceSettings");
|
||||
EditorGUI.indentLevel++;
|
||||
WaterReflections.m_minSurfaceLight = m_editorUtils.FloatField("MinSurfaceLight", WaterReflections.m_minSurfaceLight, helpEnabled);
|
||||
if (WaterReflections.m_minSurfaceLight > WaterReflections.m_maxSurfaceLight)
|
||||
{
|
||||
WaterReflections.m_minSurfaceLight = WaterReflections.m_maxSurfaceLight - 0.1f;
|
||||
}
|
||||
|
||||
if (WaterReflections.m_minSurfaceLight < 0f)
|
||||
{
|
||||
WaterReflections.m_minSurfaceLight = 0f;
|
||||
}
|
||||
WaterReflections.m_maxSurfaceLight = m_editorUtils.FloatField("MaxSurfaceLight", WaterReflections.m_maxSurfaceLight, helpEnabled);
|
||||
if (WaterReflections.m_maxSurfaceLight < 0.1f)
|
||||
{
|
||||
WaterReflections.m_maxSurfaceLight = 0.1f;
|
||||
}
|
||||
EditorGUI.indentLevel--;*/
|
||||
|
||||
if (m_editorUtils.Button("EditReflectionSettings"))
|
||||
{
|
||||
GaiaUtils.FocusWaterProfile();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b83c234d2445d946be3b2aaa34e0ae2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Gaia.Internal;
|
||||
using PWCommon4;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[CustomEditor(typeof(ReflectionMasker))]
|
||||
public class ReflectionMaskerEditor : PWEditor
|
||||
{
|
||||
private EditorUtils m_editorUtils;
|
||||
private ReflectionMasker m_profile;
|
||||
private Color GUIBackground;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
m_editorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup on destroy
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (m_editorUtils != null)
|
||||
{
|
||||
m_editorUtils.Dispose();
|
||||
}
|
||||
}
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//Initialization
|
||||
m_editorUtils.Initialize(); // Do not remove this!
|
||||
if (m_profile == null)
|
||||
{
|
||||
m_profile = (ReflectionMasker) target;
|
||||
}
|
||||
|
||||
m_editorUtils.Panel("GlobalSettings", GlobalSettings, true);
|
||||
}
|
||||
|
||||
private void GlobalSettings(bool helpEnabled)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
GUIBackground = GUI.backgroundColor;
|
||||
m_profile.Player = (Transform)m_editorUtils.ObjectField("Player", m_profile.Player, typeof(Transform), true, helpEnabled, GUILayout.MaxHeight(16f));
|
||||
if (m_profile.Player == null)
|
||||
{
|
||||
m_profile.Player = m_profile.GetPlayer();
|
||||
}
|
||||
if (m_profile.ReflectionMaskerData.m_maskingTexture == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("The mask texture is null. This system needs a mask texture to function please provide one.", MessageType.Error);
|
||||
GUI.backgroundColor = Color.red;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_profile.ReflectionMaskerData.m_maskingTexture.isReadable)
|
||||
{
|
||||
EditorGUILayout.HelpBox("The mask texture " + m_profile.ReflectionMaskerData.m_maskingTexture.name + " is not Read/Write enabled please go to the texture import settings and enable this setting then click apply.", MessageType.Error);
|
||||
GUI.backgroundColor = Color.red;
|
||||
}
|
||||
}
|
||||
m_profile.ReflectionMaskerData.m_maskingTexture = (Texture2D)m_editorUtils.ObjectField("MaskTexture", m_profile.ReflectionMaskerData.m_maskingTexture, typeof(Texture2D), false, helpEnabled, GUILayout.MaxHeight(16f));
|
||||
GUI.backgroundColor = GUIBackground;
|
||||
EditorGUI.indentLevel++;
|
||||
m_profile.ReflectionMaskerData.m_channelSelection = (ReflectionMaskerChannelSelection)m_editorUtils.EnumPopup("ChannelSelection", m_profile.ReflectionMaskerData.m_channelSelection, helpEnabled);
|
||||
m_profile.ReflectionMaskerData.m_minValue = m_editorUtils.Slider("MinValue",m_profile.ReflectionMaskerData.m_minValue, 0f, m_profile.ReflectionMaskerData.m_maxValue - 0.01f, helpEnabled);
|
||||
m_profile.ReflectionMaskerData.m_maxValue = m_editorUtils.Slider("MaxValue",m_profile.ReflectionMaskerData.m_maxValue, m_profile.ReflectionMaskerData.m_minValue + 0.01f, 1f, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorUtility.SetDirty(m_profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77b936a1f8700f5418980af13502f681
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+424
@@ -0,0 +1,424 @@
|
||||
using System;
|
||||
using ProceduralWorlds.WaterSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
#if UPPipeline
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
#endif
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class GaiaPlanarReflections : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public class PlanarReflectionSettings
|
||||
{
|
||||
public bool m_disableSkyboxReflections = false;
|
||||
public bool m_enableReflections = true;
|
||||
public GaiaConstants.ResolutionMulltiplier m_ResolutionMultiplier = GaiaConstants.ResolutionMulltiplier.Half;
|
||||
public float m_ClipPlaneOffset = 0f;
|
||||
public LayerMask m_ReflectLayers = -1;
|
||||
public bool m_Shadows = false;
|
||||
public bool m_enableRenderDistance = false;
|
||||
public bool m_enableRenderDistances = false;
|
||||
public float m_customRenderDistance = 500f;
|
||||
public float[] m_customRenderDistances = new float[32];
|
||||
public int m_textureResolution = 512;
|
||||
}
|
||||
public class PlanarReflectionSettingData
|
||||
{
|
||||
private bool _fog;
|
||||
private int _maxLod;
|
||||
private float _lodBias;
|
||||
|
||||
public void Get()
|
||||
{
|
||||
_fog = RenderSettings.fog;
|
||||
_maxLod = QualitySettings.maximumLODLevel;
|
||||
_lodBias = QualitySettings.lodBias;
|
||||
}
|
||||
|
||||
public void Set()
|
||||
{
|
||||
GL.invertCulling = true;
|
||||
RenderSettings.fog = true; // disable fog for now as it's incorrect with projection
|
||||
QualitySettings.maximumLODLevel = 1;
|
||||
QualitySettings.lodBias = _lodBias * 0.5f;
|
||||
}
|
||||
|
||||
public void Restore()
|
||||
{
|
||||
GL.invertCulling = false;
|
||||
RenderSettings.fog = _fog;
|
||||
QualitySettings.maximumLODLevel = _maxLod;
|
||||
QualitySettings.lodBias = _lodBias;
|
||||
}
|
||||
}
|
||||
|
||||
public PlanarReflectionSettings m_settings = new PlanarReflectionSettings();
|
||||
public PlanarReflectionSettingData m_reflectionData = new PlanarReflectionSettingData();
|
||||
public static event Action<ScriptableRenderContext, Camera> BeginPlanarReflections;
|
||||
public Camera m_gameCamera;
|
||||
|
||||
[SerializeField]
|
||||
private static Camera m_reflectionCamera;
|
||||
[SerializeField]
|
||||
private RenderTexture m_reflectionTexture = null;
|
||||
[SerializeField]
|
||||
private float[] m_distances = new float[32];
|
||||
|
||||
#region Unity Functions
|
||||
|
||||
/// <summary>
|
||||
/// Load on enable
|
||||
/// </summary>
|
||||
private void OnEnable()
|
||||
{
|
||||
StartReflectionSystem();
|
||||
}
|
||||
/// <summary>
|
||||
/// Execute on disable
|
||||
/// </summary>
|
||||
private void OnDisable()
|
||||
{
|
||||
Cleanup();
|
||||
}
|
||||
/// <summary>
|
||||
/// Execute when the object is destroyed
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Planar Reflection Functions
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the matrix of the reflection plane view
|
||||
/// </summary>
|
||||
/// <param name="reflectionMat"></param>
|
||||
/// <param name="plane"></param>
|
||||
private static void CalculateReflectionMatrix(ref Matrix4x4 reflectionMat, Vector4 plane)
|
||||
{
|
||||
reflectionMat.m00 = (1f - 2f * plane[0] * plane[0]);
|
||||
reflectionMat.m01 = (-2f * plane[0] * plane[1]);
|
||||
reflectionMat.m02 = (-2f * plane[0] * plane[2]);
|
||||
reflectionMat.m03 = (-2f * plane[3] * plane[0]);
|
||||
|
||||
reflectionMat.m10 = (-2f * plane[1] * plane[0]);
|
||||
reflectionMat.m11 = (1f - 2f * plane[1] * plane[1]);
|
||||
reflectionMat.m12 = (-2f * plane[1] * plane[2]);
|
||||
reflectionMat.m13 = (-2f * plane[3] * plane[1]);
|
||||
|
||||
reflectionMat.m20 = (-2f * plane[2] * plane[0]);
|
||||
reflectionMat.m21 = (-2f * plane[2] * plane[1]);
|
||||
reflectionMat.m22 = (1f - 2f * plane[2] * plane[2]);
|
||||
reflectionMat.m23 = (-2f * plane[3] * plane[2]);
|
||||
|
||||
reflectionMat.m30 = 0f;
|
||||
reflectionMat.m31 = 0f;
|
||||
reflectionMat.m32 = 0f;
|
||||
reflectionMat.m33 = 1f;
|
||||
}
|
||||
/// <summary>
|
||||
/// Updates position
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
private static Vector3 ReflectPosition(Vector3 pos)
|
||||
{
|
||||
var newPos = new Vector3(pos.x, -pos.y, pos.z);
|
||||
return newPos;
|
||||
}
|
||||
/// <summary>
|
||||
/// Updates the camera planes based on it's current view
|
||||
/// </summary>
|
||||
/// <param name="cam"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <param name="normal"></param>
|
||||
/// <param name="sideSign"></param>
|
||||
/// <returns></returns>
|
||||
private Vector4 CameraSpacePlane(Camera cam, Vector3 pos, Vector3 normal, float sideSign)
|
||||
{
|
||||
var offsetPos = pos + normal * m_settings.m_ClipPlaneOffset;
|
||||
var m = cam.worldToCameraMatrix;
|
||||
var cameraPosition = m.MultiplyPoint(offsetPos);
|
||||
var cameraNormal = m.MultiplyVector(normal).normalized * sideSign;
|
||||
return new Vector4(cameraNormal.x, cameraNormal.y, cameraNormal.z, -Vector3.Dot(cameraPosition, cameraNormal));
|
||||
}
|
||||
/// <summary>
|
||||
/// Builds the reflection texture if null or new resolution has been set
|
||||
/// </summary>
|
||||
private void PlanarReflectionTexture()
|
||||
{
|
||||
if (m_reflectionTexture == null)
|
||||
{
|
||||
#if UPPipeline
|
||||
var res = ReflectionResolution(m_settings.m_textureResolution, UniversalRenderPipeline.asset.renderScale);
|
||||
const RenderTextureFormat hdrFormat = RenderTextureFormat.DefaultHDR;
|
||||
m_reflectionTexture = RenderTexture.GetTemporary(res.x, res.y, 24, GraphicsFormatUtility.GetGraphicsFormat(hdrFormat, true));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_reflectionTexture.width != m_settings.m_textureResolution)
|
||||
{
|
||||
#if UPPipeline
|
||||
//
|
||||
var res = ReflectionResolution(m_settings.m_textureResolution, UniversalRenderPipeline.asset.renderScale);
|
||||
const RenderTextureFormat hdrFormat = RenderTextureFormat.DefaultHDR;
|
||||
m_reflectionTexture = RenderTexture.GetTemporary(res.x, res.y, 24, GraphicsFormatUtility.GetGraphicsFormat(hdrFormat, true));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
m_reflectionCamera.targetTexture = m_reflectionTexture;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the reflection resolution
|
||||
/// </summary>
|
||||
/// <param name="textureSize"></param>
|
||||
/// <param name="scale"></param>
|
||||
/// <returns></returns>
|
||||
private Vector2Int ReflectionResolution(int textureSize, float scale)
|
||||
{
|
||||
var x = (int)(textureSize * scale * GetScaleValue());
|
||||
var y = (int)(textureSize * scale * GetScaleValue());
|
||||
return new Vector2Int(x, y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Executes the planar reflections functions
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="cam"></param>
|
||||
public void ExecutePlanarReflections(ScriptableRenderContext context, Camera cam)
|
||||
{
|
||||
if (m_settings.m_disableSkyboxReflections)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (cam.cameraType == CameraType.Reflection || cam.cameraType == CameraType.Preview)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateReflectionCamera(cam);
|
||||
PlanarReflectionTexture();
|
||||
|
||||
if (m_reflectionData == null)
|
||||
{
|
||||
m_reflectionData = new PlanarReflectionSettingData();
|
||||
}
|
||||
|
||||
m_reflectionData.Get();
|
||||
m_reflectionData.Set();
|
||||
BeginPlanarReflections?.Invoke(context, m_reflectionCamera);
|
||||
#if UPPipeline
|
||||
UniversalRenderPipeline.RenderSingleCamera(context, m_reflectionCamera);
|
||||
#endif
|
||||
PWS_WaterSystem.Instance.SetReflectionTexture(m_reflectionTexture);
|
||||
m_reflectionData.Restore();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Utils
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up planar reflections
|
||||
/// </summary>
|
||||
private void Cleanup()
|
||||
{
|
||||
RenderPipelineManager.beginCameraRendering -= ExecutePlanarReflections;
|
||||
|
||||
if (m_reflectionCamera != null)
|
||||
{
|
||||
m_reflectionCamera.targetTexture = null;
|
||||
SafeDestroy(m_reflectionCamera.gameObject);
|
||||
}
|
||||
if (m_reflectionTexture != null)
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(m_reflectionTexture);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartReflectionSystem()
|
||||
{
|
||||
RenderPipelineManager.beginCameraRendering += ExecutePlanarReflections;
|
||||
m_gameCamera = GaiaUtils.GetCamera();
|
||||
}
|
||||
|
||||
public void SetReflectionState(bool state)
|
||||
{
|
||||
m_settings.m_enableReflections = state;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates the reflection camera
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Camera CreateMirrorObjects()
|
||||
{
|
||||
var go = new GameObject("Gaia Planar Reflections Camera",typeof(Camera));
|
||||
#if UPPipeline
|
||||
var cameraData = go.AddComponent(typeof(UniversalAdditionalCameraData)) as UniversalAdditionalCameraData;
|
||||
|
||||
cameraData.requiresColorOption = CameraOverrideOption.Off;
|
||||
cameraData.requiresDepthOption = CameraOverrideOption.Off;
|
||||
cameraData.SetRenderer(0);
|
||||
#endif
|
||||
|
||||
var t = transform;
|
||||
var reflectionCamera = go.GetComponent<Camera>();
|
||||
reflectionCamera.transform.SetPositionAndRotation(t.position, t.rotation);
|
||||
reflectionCamera.depth = -10;
|
||||
reflectionCamera.enabled = false;
|
||||
go.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
return reflectionCamera;
|
||||
}
|
||||
/// <summary>
|
||||
/// Destory the object
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
private static void SafeDestroy(GameObject obj)
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
DestroyImmediate(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(obj);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Updates the reflection camera settings
|
||||
/// </summary>
|
||||
/// <param name="src"></param>
|
||||
/// <param name="dest"></param>
|
||||
private void UpdateCamera(Camera src, Camera dest)
|
||||
{
|
||||
if (dest == null) return;
|
||||
|
||||
dest.CopyFrom(src);
|
||||
dest.useOcclusionCulling = true;
|
||||
SetCameraBackgroundType(dest, CameraClearFlags.SolidColor);
|
||||
#if UPPipeline
|
||||
if (dest.gameObject.TryGetComponent(out UniversalAdditionalCameraData camData))
|
||||
{
|
||||
camData.SetRenderer(0);
|
||||
camData.renderShadows = m_settings.m_Shadows; // turn off shadows for the reflection camera
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="camera"></param>
|
||||
private void SetCameraBackgroundType(Camera camera, CameraClearFlags backgroundRenderMode)
|
||||
{
|
||||
if (camera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
camera.clearFlags = backgroundRenderMode;
|
||||
camera.backgroundColor = RenderSettings.fogColor;
|
||||
}
|
||||
/// <summary>
|
||||
/// Updates the reflection camera for rendering
|
||||
/// </summary>
|
||||
/// <param name="realCamera"></param>
|
||||
private void UpdateReflectionCamera(Camera realCamera)
|
||||
{
|
||||
if (m_reflectionCamera == null)
|
||||
{
|
||||
m_reflectionCamera = CreateMirrorObjects();
|
||||
}
|
||||
|
||||
Vector3 pos = Vector3.zero;
|
||||
Vector3 normal = Vector3.up;
|
||||
UpdateCamera(realCamera, m_reflectionCamera);
|
||||
|
||||
var d = Vector3.Dot(normal, pos) - m_settings.m_ClipPlaneOffset;
|
||||
var reflectionPlane = new Vector4(normal.x, normal.y, normal.z, d);
|
||||
var reflection = Matrix4x4.identity;
|
||||
reflection = Matrix4x4.Scale(new Vector3(1, 1, 1));
|
||||
CalculateReflectionMatrix(ref reflection, reflectionPlane);
|
||||
var oldPosition = realCamera.transform.position - new Vector3(0, pos.y, 0);
|
||||
var newPosition = ReflectPosition(oldPosition);
|
||||
m_reflectionCamera.transform.forward = Vector3.Scale(realCamera.transform.forward, new Vector3(1, 1, 1));
|
||||
m_reflectionCamera.worldToCameraMatrix = realCamera.worldToCameraMatrix * reflection;
|
||||
var clipPlane = CameraSpacePlane(m_reflectionCamera, pos - Vector3.up * 0.1f, normal, 1.0f);
|
||||
var projection = realCamera.CalculateObliqueMatrix(clipPlane);
|
||||
m_reflectionCamera.projectionMatrix = projection;
|
||||
if (m_settings.m_enableReflections)
|
||||
{
|
||||
m_reflectionCamera.cullingMask = ~(1 << 4) & m_settings.m_ReflectLayers;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_reflectionCamera.cullingMask = 0;
|
||||
}
|
||||
|
||||
if (m_distances.Length != 32)
|
||||
{
|
||||
m_distances = new float[32];
|
||||
}
|
||||
if (m_settings.m_enableRenderDistance)
|
||||
{
|
||||
if (m_settings.m_enableRenderDistances)
|
||||
{
|
||||
m_reflectionCamera.layerCullDistances = m_settings.m_customRenderDistances;
|
||||
m_reflectionCamera.layerCullSpherical = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int idx = 0; idx < m_distances.Length; idx++)
|
||||
{
|
||||
m_distances[idx] = m_settings.m_customRenderDistance;
|
||||
}
|
||||
m_reflectionCamera.layerCullDistances = m_distances;
|
||||
m_reflectionCamera.layerCullSpherical = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int idx = 0; idx < m_distances.Length; idx++)
|
||||
{
|
||||
m_distances[idx] = 0f;
|
||||
}
|
||||
m_reflectionCamera.layerCullDistances = m_distances;
|
||||
m_reflectionCamera.layerCullSpherical = true;
|
||||
}
|
||||
|
||||
m_reflectionCamera.transform.position = newPosition;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the multiplier scale
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private float GetScaleValue()
|
||||
{
|
||||
switch(m_settings.m_ResolutionMultiplier)
|
||||
{
|
||||
case GaiaConstants.ResolutionMulltiplier.Full:
|
||||
return 1f;
|
||||
case GaiaConstants.ResolutionMulltiplier.Half:
|
||||
return 0.5f;
|
||||
case GaiaConstants.ResolutionMulltiplier.Third:
|
||||
return 0.33f;
|
||||
case GaiaConstants.ResolutionMulltiplier.Quarter:
|
||||
return 0.25f;
|
||||
default:
|
||||
return 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5362db1f5573731479e71ccee9de582b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 121c7ad962667ca409c1cefbc44c67f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,288 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
public enum ReflectionMaskerChannelSelection { R, G, B, A, RGBA }
|
||||
|
||||
[Serializable]
|
||||
public class ReflectionMaskerData
|
||||
{
|
||||
public Texture2D m_maskingTexture;
|
||||
public ReflectionMaskerChannelSelection m_channelSelection = ReflectionMaskerChannelSelection.R;
|
||||
public float m_minValue = 0.15f;
|
||||
public float m_maxValue = 1f;
|
||||
|
||||
public bool m_enableReflections;
|
||||
public bool m_allowMSAA;
|
||||
public bool m_enableHDR;
|
||||
public bool m_enableHeightFeatures;
|
||||
public float m_disableHeightValue;
|
||||
public bool m_enableCustomDistance;
|
||||
public bool m_enableMultiLayerDistances;
|
||||
public float m_reflectionDistance;
|
||||
public float[] m_reflectionDistances;
|
||||
public GaiaPlanarReflections m_planarReflections;
|
||||
|
||||
public void Process(SceneProfile sceneProfile, bool state)
|
||||
{
|
||||
Get(sceneProfile);
|
||||
SetState(sceneProfile, state);
|
||||
}
|
||||
public void Get(SceneProfile profile)
|
||||
{
|
||||
if (profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_enableReflections = profile.m_enableReflections;
|
||||
m_allowMSAA = profile.m_allowMSAA;
|
||||
m_enableHDR = profile.m_useHDR;
|
||||
m_enableHeightFeatures = profile.m_enableDisabeHeightFeature;
|
||||
m_disableHeightValue = profile.m_disableHeight;
|
||||
m_enableCustomDistance = profile.m_useCustomRenderDistance;
|
||||
m_enableMultiLayerDistances = profile.m_enableLayerDistances;
|
||||
m_reflectionDistance = profile.m_customRenderDistance;
|
||||
m_reflectionDistances = profile.m_customRenderDistances;
|
||||
}
|
||||
public void Set(SceneProfile profile)
|
||||
{
|
||||
if (profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
profile.m_enableReflections = m_enableReflections;
|
||||
profile.m_allowMSAA = m_allowMSAA;
|
||||
profile.m_useHDR = m_enableHDR;
|
||||
profile.m_enableDisabeHeightFeature = m_enableHeightFeatures;
|
||||
profile.m_disableHeight = m_disableHeightValue;
|
||||
profile.m_useCustomRenderDistance = m_enableCustomDistance;
|
||||
profile.m_enableLayerDistances = m_enableMultiLayerDistances;
|
||||
profile.m_customRenderDistance = m_reflectionDistance;
|
||||
profile.m_customRenderDistances = m_reflectionDistances;
|
||||
}
|
||||
public void SetState(SceneProfile profile, bool state)
|
||||
{
|
||||
if (profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
profile.m_enableReflections = state;
|
||||
profile.m_enableDisabeHeightFeature = state;
|
||||
|
||||
#if UPPipeline
|
||||
|
||||
if (m_planarReflections != null)
|
||||
{
|
||||
m_planarReflections.SetReflectionState(state);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_planarReflections = GameObject.FindObjectOfType<GaiaPlanarReflections>();
|
||||
if (m_planarReflections != null)
|
||||
{
|
||||
m_planarReflections.SetReflectionState(state);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public class ReflectionMasker : MonoBehaviour
|
||||
{
|
||||
public Transform Player;
|
||||
public ReflectionMaskerData ReflectionMaskerData
|
||||
{
|
||||
get { return m_reflectionMaskerData; }
|
||||
set
|
||||
{
|
||||
if (m_reflectionMaskerData != value)
|
||||
{
|
||||
m_reflectionMaskerData = value;
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
if (GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[SerializeField]
|
||||
private ReflectionMaskerData m_reflectionMaskerData = new ReflectionMaskerData();
|
||||
|
||||
private bool m_needUpdating = false;
|
||||
[SerializeField]
|
||||
private Vector3 m_oldPosition;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Initilize();
|
||||
Execute();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (DoesNeedExecute())
|
||||
{
|
||||
Execute();
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (Player != null)
|
||||
{
|
||||
bool checkValue = CheckPoint(ReflectionMaskerData.m_maskingTexture, Player.position, ReflectionMaskerData.m_minValue, ReflectionMaskerData.m_maxValue);
|
||||
if (DoesNeedUpdating(checkValue))
|
||||
{
|
||||
m_needUpdating = checkValue;
|
||||
if (GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
ReflectionMaskerData.Process(GaiaGlobal.Instance.SceneProfile, checkValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool CheckPoint(Texture2D maskTexture, Vector3 position, float min, float max)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (maskTexture == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!maskTexture.isReadable)
|
||||
{
|
||||
Debug.LogError("Texture is not marked as readable. Please set is readable on the texture import settings on texture " + maskTexture.name);
|
||||
}
|
||||
|
||||
Terrain terrain = TerrainHelper.GetTerrain(position);
|
||||
if (terrain != null)
|
||||
{
|
||||
float scalerX = (float)(position.x - terrain.transform.position.x) / (float)terrain.terrainData.size.x;
|
||||
float scalerZ = (float)(position.z - terrain.transform.position.z) / (float)terrain.terrainData.size.z;
|
||||
|
||||
Color value = Color.white;
|
||||
value = maskTexture.GetPixel(Mathf.RoundToInt(scalerX * maskTexture.width), Mathf.RoundToInt(scalerZ * maskTexture.height));
|
||||
|
||||
switch (ReflectionMaskerData.m_channelSelection)
|
||||
{
|
||||
case ReflectionMaskerChannelSelection.R:
|
||||
if (value.r >= min && value.r <= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ReflectionMaskerChannelSelection.G:
|
||||
if (value.g >= min && value.g <= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ReflectionMaskerChannelSelection.B:
|
||||
if (value.b >= min && value.b <= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ReflectionMaskerChannelSelection.A:
|
||||
if (value.a >= min && value.a <= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ReflectionMaskerChannelSelection.RGBA:
|
||||
if (value.r >= min && value.r <= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (value.g >= min && value.g <= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (value.b >= min && value.b <= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (value.a >= min && value.a <= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError("Issues happened when trying to check the point " + e.Message + " Happened here " + e.StackTrace);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private bool DoesNeedUpdating(bool newValue)
|
||||
{
|
||||
if (m_needUpdating != newValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private bool DoesNeedExecute()
|
||||
{
|
||||
if (Player != null)
|
||||
{
|
||||
if (Player.position != m_oldPosition)
|
||||
{
|
||||
m_oldPosition = Player.position;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private void Initilize()
|
||||
{
|
||||
if (GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
m_needUpdating = GaiaGlobal.Instance.SceneProfile.m_enableReflections;
|
||||
}
|
||||
|
||||
if (Player == null)
|
||||
{
|
||||
Player = GetPlayer();
|
||||
}
|
||||
}
|
||||
public Transform GetPlayer()
|
||||
{
|
||||
Transform transform = null;
|
||||
if (GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
if (GaiaGlobal.Instance.m_mainCamera != null)
|
||||
{
|
||||
transform = GaiaGlobal.Instance.m_mainCamera.transform;
|
||||
}
|
||||
}
|
||||
|
||||
if (transform == null)
|
||||
{
|
||||
transform = GaiaUtils.GetPlayerTransform();
|
||||
}
|
||||
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01d1cbcea7cb01e458a6b08e7c1bf04e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user