Initial commit
This commit is contained in:
1 parent
ee9615239e
commit
16feac691f
4093 files changed
+1030491
No files matched your search
@@ -0,0 +1,220 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
public enum PW_RENDER_SIZE
|
||||
{
|
||||
FULL = -1,
|
||||
HALF = -2,
|
||||
QUARTER = -3
|
||||
};
|
||||
public static class CommandBufferManagerShaderID
|
||||
{
|
||||
public static readonly string _cbufName = "Echo_Refaction";
|
||||
public static readonly int _grabID = 0;
|
||||
public static readonly int m_cameraOpaqueTexture;
|
||||
|
||||
static CommandBufferManagerShaderID()
|
||||
{
|
||||
m_cameraOpaqueTexture = Shader.PropertyToID("_CameraOpaqueTexture");
|
||||
}
|
||||
}
|
||||
|
||||
[ExecuteAlways]
|
||||
public class CommandBufferManager : MonoBehaviour
|
||||
{
|
||||
#region Variables
|
||||
|
||||
#region Public
|
||||
|
||||
public bool m_allowHDR = true;
|
||||
public PW_RENDER_SIZE m_renderSize = PW_RENDER_SIZE.HALF;
|
||||
public CameraEvent m_cameraEventRefraction = CameraEvent.AfterImageEffectsOpaque;
|
||||
|
||||
#endregion
|
||||
#region Private
|
||||
|
||||
[SerializeField] private GaiaConstants.EnvironmentRenderer RenderPipeline = GaiaConstants.EnvironmentRenderer.BuiltIn;
|
||||
private const string m_bufferManagerObjectName = "Command Buffer Manager";
|
||||
#region Events
|
||||
|
||||
private Dictionary<Camera, CommandBuffer> m_camerasRefraction = new Dictionary<Camera, CommandBuffer>();
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region Unity Functions
|
||||
|
||||
/// <summary>
|
||||
/// Start on enable
|
||||
/// </summary>
|
||||
private void OnEnable()
|
||||
{
|
||||
RebuildBuffers();
|
||||
}
|
||||
/// <summary>
|
||||
/// OnDisable ClearData
|
||||
/// </summary>
|
||||
private void OnDisable()
|
||||
{
|
||||
RebuildBuffers();
|
||||
}
|
||||
/// <summary>
|
||||
/// OnDestroy ClearData
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearBuffers();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Function used to rebuild buffers
|
||||
/// </summary>
|
||||
public void RebuildBuffers(bool clear = true)
|
||||
{
|
||||
RenderPipeline = GaiaUtils.GetActivePipeline();
|
||||
if (clear)
|
||||
{
|
||||
ClearBuffers();
|
||||
}
|
||||
|
||||
StartBuffers();
|
||||
}
|
||||
/// <summary>
|
||||
/// Clears all the buffers
|
||||
/// </summary>
|
||||
public void ClearBuffers()
|
||||
{
|
||||
switch (RenderPipeline)
|
||||
{
|
||||
case GaiaConstants.EnvironmentRenderer.BuiltIn:
|
||||
Camera.onPreRender -= PreRender;
|
||||
break;
|
||||
default:
|
||||
RenderPipelineManager.beginCameraRendering -= PreRender;
|
||||
break;
|
||||
}
|
||||
|
||||
//Refraction
|
||||
foreach (var cam in m_camerasRefraction)
|
||||
{
|
||||
if (cam.Key)
|
||||
{
|
||||
cam.Key.RemoveCommandBuffer(m_cameraEventRefraction, cam.Value);
|
||||
}
|
||||
}
|
||||
m_camerasRefraction.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// Starts the buffer render process
|
||||
/// </summary>
|
||||
private void StartBuffers()
|
||||
{
|
||||
switch (RenderPipeline)
|
||||
{
|
||||
case GaiaConstants.EnvironmentRenderer.BuiltIn:
|
||||
Camera.onPreRender += PreRender;
|
||||
break;
|
||||
default:
|
||||
RenderPipelineManager.beginCameraRendering += PreRender;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Process function to generate the buffers
|
||||
/// </summary>
|
||||
/// <param name="i_cam"></param>
|
||||
private void PreRender(Camera i_cam)
|
||||
{
|
||||
if (gameObject.activeInHierarchy)
|
||||
{
|
||||
RenderBuffers(i_cam);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearBuffers();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Process function to generate the buffers
|
||||
/// </summary>
|
||||
/// <param name="i_cam"></param>
|
||||
private void PreRender(ScriptableRenderContext src, Camera i_cam)
|
||||
{
|
||||
if (gameObject.activeInHierarchy)
|
||||
{
|
||||
RenderBuffers(i_cam);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearBuffers();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Function used to build the buffer data
|
||||
/// </summary>
|
||||
/// <param name="i_cam"></param>
|
||||
private void RenderBuffers(Camera i_cam)
|
||||
{
|
||||
if (i_cam != null)
|
||||
{
|
||||
if (i_cam.name.Contains("Reflection Probe"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Refraction
|
||||
if (m_camerasRefraction.ContainsKey(i_cam))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CommandBuffer cameraOpaqueBuffer = new CommandBuffer {name = CommandBufferManagerShaderID._cbufName};
|
||||
m_camerasRefraction[i_cam] = cameraOpaqueBuffer;
|
||||
if (m_allowHDR)
|
||||
{
|
||||
cameraOpaqueBuffer.GetTemporaryRT(CommandBufferManagerShaderID._grabID, (int) m_renderSize, (int) m_renderSize, 0, FilterMode.Bilinear, RenderTextureFormat.DefaultHDR);
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraOpaqueBuffer.GetTemporaryRT(CommandBufferManagerShaderID._grabID, (int) m_renderSize, (int) m_renderSize, 0, FilterMode.Bilinear);
|
||||
}
|
||||
|
||||
cameraOpaqueBuffer.Blit(BuiltinRenderTextureType.CurrentActive, CommandBufferManagerShaderID._grabID);
|
||||
cameraOpaqueBuffer.SetGlobalTexture(CommandBufferManagerShaderID.m_cameraOpaqueTexture, CommandBufferManagerShaderID._grabID);
|
||||
cameraOpaqueBuffer.ReleaseTemporaryRT(CommandBufferManagerShaderID._grabID);
|
||||
i_cam.AddCommandBuffer(m_cameraEventRefraction, cameraOpaqueBuffer);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Static Methods
|
||||
|
||||
/// <summary>
|
||||
/// Creates the buffer manager in the scene
|
||||
/// </summary>
|
||||
public static void CreateBufferManager()
|
||||
{
|
||||
//Create Manager
|
||||
CommandBufferManager manager = FindObjectOfType<CommandBufferManager>();
|
||||
if (manager == null)
|
||||
{
|
||||
GameObject managerGameObject = new GameObject(m_bufferManagerObjectName);
|
||||
manager = managerGameObject.AddComponent<CommandBufferManager>();
|
||||
manager.RebuildBuffers();
|
||||
|
||||
//Parent
|
||||
manager.transform.SetParent(GaiaUtils.GetRuntimeSceneObject().transform);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4d4b66f058f7144b87029a88337e18b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ead4260e6d1b8943b7b4df5d30bd0f7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
using Gaia.Internal;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using PWCommon4;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[CustomEditor(typeof(CommandBufferManager))]
|
||||
public class CommandBufferManagerEditor : PWEditor
|
||||
{
|
||||
private EditorUtils m_editorUtils;
|
||||
private CommandBufferManager m_bufferManager;
|
||||
|
||||
//Variables
|
||||
private bool HDR;
|
||||
private PW_RENDER_SIZE RenderSize;
|
||||
private CameraEvent RefractionCameraEvent;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
m_editorUtils = PWApp.GetEditorUtils(this, null, null, null);
|
||||
}
|
||||
|
||||
m_bufferManager = (CommandBufferManager)target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
m_editorUtils.Initialize();
|
||||
if (m_bufferManager == null)
|
||||
{
|
||||
m_bufferManager = (CommandBufferManager)target;
|
||||
}
|
||||
|
||||
m_editorUtils.Panel("GlobalSettings", GlobalPanel, true);
|
||||
}
|
||||
|
||||
private void GlobalPanel(bool helpEnabled)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
m_editorUtils.Heading("GlobalSettings");
|
||||
HDR = m_bufferManager.m_allowHDR;
|
||||
HDR = m_editorUtils.Toggle("AllowHDR", HDR, helpEnabled);
|
||||
RenderSize = m_bufferManager.m_renderSize;
|
||||
RenderSize = (PW_RENDER_SIZE)m_editorUtils.EnumPopup("RenderResolution", RenderSize, helpEnabled);
|
||||
EditorGUILayout.Space();
|
||||
m_editorUtils.Heading("RefreactionSettings");
|
||||
RefractionCameraEvent = m_bufferManager.m_cameraEventRefraction;
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("CantBeChangedAtRunTime"), MessageType.Info);
|
||||
GUI.enabled = false;
|
||||
}
|
||||
RefractionCameraEvent = (CameraEvent)m_editorUtils.EnumPopup("RefractionCameraEvent", RefractionCameraEvent, helpEnabled);
|
||||
GUI.enabled = true;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (ChangesMade())
|
||||
{
|
||||
m_bufferManager.ClearBuffers();
|
||||
m_bufferManager.m_allowHDR = HDR;
|
||||
m_bufferManager.m_renderSize = RenderSize;
|
||||
m_bufferManager.m_cameraEventRefraction = RefractionCameraEvent;
|
||||
m_bufferManager.RebuildBuffers(false);
|
||||
EditorUtility.SetDirty(m_bufferManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Has one of the variables been changed?
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool ChangesMade()
|
||||
{
|
||||
if (HDR != m_bufferManager.m_allowHDR)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (RenderSize != m_bufferManager.m_renderSize)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (RefractionCameraEvent != m_bufferManager.m_cameraEventRefraction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2a6bb6a7f96e9641a4d40a21175f573
|
||||
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: 8d3749d9df6af1d4aa2885558e337f53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,539 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Gaia.Internal;
|
||||
using PWCommon4;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[CustomEditor(typeof(GaiaScenePlayer))]
|
||||
public class GaiaPlayerEditor : PWEditor
|
||||
{
|
||||
private EditorUtils m_editorUtils;
|
||||
private GaiaSettings m_gaiaSettings;
|
||||
private SceneProfile m_profile;
|
||||
private GaiaLightingProfileValues profile;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
//Get Gaia Lighting Profile object
|
||||
if (GaiaGlobal.Instance != null)
|
||||
{
|
||||
m_profile = GaiaGlobal.Instance.SceneProfile;
|
||||
}
|
||||
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
m_editorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
|
||||
if (m_gaiaSettings == null)
|
||||
{
|
||||
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//Initialization
|
||||
m_editorUtils.Initialize(); // Do not remove this!
|
||||
|
||||
if (m_profile != null)
|
||||
{
|
||||
//Monitor for changes
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if (m_gaiaSettings == null)
|
||||
{
|
||||
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
}
|
||||
|
||||
m_editorUtils.Panel("GlobalSettings", GlobalSettings, false, true, 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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GaiaGlobal.Instance != null)
|
||||
{
|
||||
m_profile = GaiaGlobal.Instance.SceneProfile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void GlobalSettings(bool helpEnabled)
|
||||
{
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_lightingProfiles.Count > 0)
|
||||
{
|
||||
if (m_profile.m_selectedLightingProfileValuesIndex != -99)
|
||||
{
|
||||
profile = GaiaGlobal.Instance.SceneProfile.m_lightingProfiles[m_profile.m_selectedLightingProfileValuesIndex];
|
||||
}
|
||||
}
|
||||
|
||||
if (m_gaiaSettings.m_currentRenderer == GaiaConstants.EnvironmentRenderer.BuiltIn)
|
||||
{
|
||||
bool postfx = m_profile.m_setupPostFX;
|
||||
m_profile.m_setupPostFX = m_editorUtils.Toggle("SetupPostFX", m_profile.m_setupPostFX, helpEnabled);
|
||||
if (postfx != m_profile.m_setupPostFX)
|
||||
{
|
||||
if (m_profile.m_setupPostFX)
|
||||
{
|
||||
if (profile != null)
|
||||
{
|
||||
GaiaLighting.SetupPostProcessing(profile, m_profile, GaiaUtils.GetActivePipeline(), true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GaiaLighting.RemoveAllPostProcessV2CameraLayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
m_profile.m_spawnPlayerAtCurrentLocation = m_editorUtils.Toggle("SpawnPlayerAtCurrentLocation", m_profile.m_spawnPlayerAtCurrentLocation, helpEnabled);
|
||||
|
||||
GaiaConstants.EnvironmentControllerType controller = m_profile.m_controllerType;
|
||||
controller = (GaiaConstants.EnvironmentControllerType)m_editorUtils.EnumPopup("ControllerType", controller, helpEnabled);
|
||||
if (controller != m_profile.m_controllerType)
|
||||
{
|
||||
m_gaiaSettings.m_currentController = controller;
|
||||
switch (controller)
|
||||
{
|
||||
case GaiaConstants.EnvironmentControllerType.FirstPerson:
|
||||
GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerFirstPersonName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
|
||||
break;
|
||||
case GaiaConstants.EnvironmentControllerType.FlyingCamera:
|
||||
GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerFlyCamName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
|
||||
break;
|
||||
case GaiaConstants.EnvironmentControllerType.ThirdPerson:
|
||||
GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerThirdPersonName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
|
||||
break;
|
||||
case GaiaConstants.EnvironmentControllerType.Car:
|
||||
GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.m_carPlayerPrefabName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
|
||||
break;
|
||||
case GaiaConstants.EnvironmentControllerType.XRController:
|
||||
#if GAIA_XR
|
||||
GaiaSceneManagement.CreatePlayer(m_gaiaSettings, "XRController", m_profile.m_spawnPlayerAtCurrentLocation);
|
||||
#else
|
||||
EditorUtility.DisplayDialog("XR Support not enabled", "The XR Controller is a default player for Virtual / Augmented Reality projects. Please open the Setup Panel in the Gaia Manager Standard Tab to enable XR Support in order to use the XR Player Controller. Please also make sure you have the Unity XR Interaction Toolkit package installed before doing so.", "OK");
|
||||
controller = GaiaConstants.EnvironmentControllerType.FlyingCamera;
|
||||
m_gaiaSettings.m_currentController = GaiaConstants.EnvironmentControllerType.FlyingCamera;
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
SetPostProcessing(profile);
|
||||
#if GAIA_PRO_PRESENT
|
||||
if (GaiaUtils.HasDynamicLoadedTerrains())
|
||||
{
|
||||
TerrainLoader tl = ((GaiaScenePlayer)target).GetComponentInChildren<TerrainLoader>();
|
||||
if (tl != null)
|
||||
{
|
||||
m_profile.UpdateTerrainLoaderFromProfile(ref tl);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
m_profile.m_controllerType = controller;
|
||||
}
|
||||
|
||||
if (controller == GaiaConstants.EnvironmentControllerType.Custom)
|
||||
{
|
||||
m_profile.m_customPlayer = (GameObject)m_editorUtils.ObjectField("MainPlayer", m_profile.m_customPlayer, typeof(GameObject), true, helpEnabled);
|
||||
m_profile.m_customCamera = (Camera)m_editorUtils.ObjectField("MainCamera", m_profile.m_customCamera, typeof(Camera), true, helpEnabled);
|
||||
|
||||
if (m_editorUtils.Button("ApplySetup"))
|
||||
{
|
||||
GaiaSceneManagement.CreatePlayer(m_gaiaSettings, "Custom", m_profile.m_spawnPlayerAtCurrentLocation, m_profile.m_customPlayer, m_profile.m_customCamera, true);
|
||||
SetPostProcessing(profile);
|
||||
#if GAIA_PRO_PRESENT
|
||||
if (GaiaUtils.HasDynamicLoadedTerrains())
|
||||
{
|
||||
TerrainLoader tl = ((GaiaScenePlayer)target).GetComponentInChildren<TerrainLoader>();
|
||||
if (tl != null)
|
||||
{
|
||||
m_profile.UpdateTerrainLoaderFromProfile(ref tl);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
if (m_editorUtils.Button("MoveCameraToPlayer"))
|
||||
{
|
||||
GaiaSceneManagement.MoveCameraToPlayer(m_gaiaSettings);
|
||||
}
|
||||
|
||||
if (m_editorUtils.Button("MovePlayerToCamera"))
|
||||
{
|
||||
GaiaSceneManagement.MovePlayerToCamera(m_gaiaSettings);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
m_editorUtils.Panel("AutoDepthOfFieldSettings", AutoDepthOfField);
|
||||
m_editorUtils.Panel("LocationManagerSettings", LocationManagerSettings);
|
||||
m_editorUtils.Panel("PlayerCameraCullingSettings", CameraCullingSettings);
|
||||
if (GaiaUtils.HasDynamicLoadedTerrains())
|
||||
{
|
||||
m_editorUtils.Panel("TerrainLoadingSettings", TerrainLoadingSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void TerrainLoadingSettings(bool helpEnabled)
|
||||
{
|
||||
#if GAIA_PRO_PRESENT
|
||||
EditorGUI.BeginChangeCheck();
|
||||
if (!TerrainLoaderManager.Instance.TerrainSceneStorage.m_terrainLoadingEnabled)
|
||||
{
|
||||
EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("AutoLoadTerrainsDisabled"), MessageType.Warning);
|
||||
GUI.enabled = false;
|
||||
}
|
||||
|
||||
if (TerrainLoaderManager.ColliderOnlyLoadingActive)
|
||||
{
|
||||
EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("ColliderOnlyLoadingWarning"), MessageType.Warning);
|
||||
}
|
||||
|
||||
m_profile.m_terrainLoaderLoadMode = (LoadMode)m_editorUtils.EnumPopup("LoadMode", m_profile.m_terrainLoaderLoadMode, helpEnabled);
|
||||
if (m_profile.m_terrainLoaderLoadMode == LoadMode.RuntimeAlways)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
m_editorUtils.InlineHelp("RefreshRates", helpEnabled);
|
||||
m_profile.m_terrainLoaderMinRefreshDistance = m_editorUtils.FloatField("MinRefreshDistance", m_profile.m_terrainLoaderMinRefreshDistance, helpEnabled);
|
||||
m_profile.m_terrainLoaderMaxRefreshDistance = m_editorUtils.FloatField("MaxRefreshDistance", m_profile.m_terrainLoaderMaxRefreshDistance, helpEnabled);
|
||||
m_profile.m_terrainLoaderMinRefreshMS = m_editorUtils.FloatField("MinRefreshMS", m_profile.m_terrainLoaderMinRefreshMS, helpEnabled);
|
||||
m_profile.m_terrainLoaderMaxRefreshMS = m_editorUtils.FloatField("MaxRefreshMS", m_profile.m_terrainLoaderMaxRefreshMS, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
m_editorUtils.Heading("LoadRange");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profile.m_terrainLoaderFollowTransform = m_editorUtils.Toggle("FollowTransform", m_profile.m_terrainLoaderFollowTransform, helpEnabled);
|
||||
if (TerrainLoaderManager.ColliderOnlyLoadingActive)
|
||||
{
|
||||
if (!m_profile.m_terrainLoaderFollowTransform)
|
||||
{
|
||||
m_profile.m_terrainLoaderLoadingBoundsCollider.center = m_editorUtils.Vector3Field("LoadingBoundsColliderCenter", m_profile.m_terrainLoaderLoadingBoundsCollider.center, helpEnabled);
|
||||
}
|
||||
m_profile.m_terrainLoaderLoadingBoundsCollider.extents = m_editorUtils.Vector3Field("LoadingBoundsColliderExtents", m_profile.m_terrainLoaderLoadingBoundsCollider.extents, helpEnabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
if (!m_profile.m_terrainLoaderFollowTransform)
|
||||
{
|
||||
m_profile.m_terrainLoaderLoadingBoundsRegular.center = m_editorUtils.Vector3Field("LoadingBoundsCenter", m_profile.m_terrainLoaderLoadingBoundsRegular.center, helpEnabled);
|
||||
}
|
||||
m_profile.m_terrainLoaderLoadingBoundsRegular.extents = m_editorUtils.Vector3Field("LoadingBoundsExtents", m_profile.m_terrainLoaderLoadingBoundsRegular.extents, helpEnabled);
|
||||
if (!m_profile.m_terrainLoaderFollowTransform)
|
||||
{
|
||||
m_profile.m_terrainLoaderLoadingBoundsImpostor.center = m_editorUtils.Vector3Field("LoadingBoundsImpostorCenter", m_profile.m_terrainLoaderLoadingBoundsImpostor.center, helpEnabled);
|
||||
}
|
||||
m_profile.m_terrainLoaderLoadingBoundsImpostor.extents = m_editorUtils.Vector3Field("LoadingBoundsImpostorExtents", m_profile.m_terrainLoaderLoadingBoundsImpostor.extents, helpEnabled);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
TerrainLoader tl = ((GaiaScenePlayer)target).GetComponentInChildren<TerrainLoader>();
|
||||
m_profile.UpdateTerrainLoaderFromProfile(ref tl);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void AutoDepthOfField(bool helpEnabled)
|
||||
{
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
if (GaiaUtils.GetActivePipeline() == GaiaConstants.EnvironmentRenderer.BuiltIn)
|
||||
{
|
||||
//Get Auto Focus object
|
||||
AutoDepthOfField autoFocus = GaiaSceneManagement.SetupAutoDepthOfField(m_profile);
|
||||
|
||||
//Monitor for changes
|
||||
EditorGUI.BeginChangeCheck();
|
||||
bool enableDOF = m_profile.m_enableAutoDOF;
|
||||
enableDOF = m_editorUtils.Toggle("EnableAutoDepthOfField", enableDOF, helpEnabled);
|
||||
if (m_profile.m_enableAutoDOF != enableDOF)
|
||||
{
|
||||
m_profile.m_enableAutoDOF = enableDOF;
|
||||
autoFocus = GaiaSceneManagement.SetupAutoDepthOfField(m_profile);
|
||||
}
|
||||
if (autoFocus != null && m_profile.m_enableAutoDOF)
|
||||
{
|
||||
if (enableDOF)
|
||||
{
|
||||
bool oldDebugValue = autoFocus.m_debug;
|
||||
autoFocus.m_debug = m_editorUtils.Toggle("ShowDebugInfo", autoFocus.m_debug);
|
||||
if (oldDebugValue != autoFocus.m_debug && !autoFocus.m_debug)
|
||||
{
|
||||
autoFocus.RemoveDebugSphere();
|
||||
}
|
||||
}
|
||||
|
||||
#if !UNITY_POST_PROCESSING_STACK_V2
|
||||
EditorGUILayout.HelpBox("Post Processing is not installed. Please install post processing from the package manager to use this feature. (Window/Package Manager)", MessageType.Warning);
|
||||
GUI.enabled = false;
|
||||
#endif
|
||||
m_editorUtils.Heading("AutoFocusDependencies");
|
||||
EditorGUI.indentLevel++;
|
||||
autoFocus.m_sourceCamera = (Camera)m_editorUtils.ObjectField("SourceCamera", autoFocus.m_sourceCamera, typeof(Camera), true, helpEnabled);
|
||||
if (autoFocus.m_sourceCamera == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Source Camera is missing. Either add it manually or it will be added on start of application if present", MessageType.Error);
|
||||
}
|
||||
autoFocus.m_targetObject = (GameObject)m_editorUtils.ObjectField("TargetObject", autoFocus.m_targetObject, typeof(GameObject), true, helpEnabled);
|
||||
if (autoFocus.m_targetObject == null && autoFocus.m_trackingType == GaiaConstants.DOFTrackingType.FollowTarget)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Target Object is missing. Add it to use target focus mode", MessageType.Error);
|
||||
}
|
||||
autoFocus.m_targetLayer = GaiaEditorUtils.LayerMaskField(new GUIContent(m_editorUtils.GetTextValue("TargetLayer"), m_editorUtils.GetTooltip("TargetLayer")), autoFocus.m_targetLayer);
|
||||
m_editorUtils.InlineHelp("TargetLayer", helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
m_editorUtils.Heading("AutoFocusConfiguration");
|
||||
EditorGUI.indentLevel++;
|
||||
autoFocus.m_interactWithPlayer = m_editorUtils.Toggle("InteractWithPlayer", autoFocus.m_interactWithPlayer, helpEnabled);
|
||||
autoFocus.m_trackingType = (GaiaConstants.DOFTrackingType)m_editorUtils.EnumPopup("TrackingMode", autoFocus.m_trackingType, helpEnabled);
|
||||
autoFocus.m_focusOffset = m_editorUtils.FloatField("FocusOffset", autoFocus.m_focusOffset, helpEnabled);
|
||||
autoFocus.m_maxFocusDistance = m_editorUtils.FloatField("MaxFocusDistance", autoFocus.m_maxFocusDistance, helpEnabled);
|
||||
autoFocus.m_dofAperture = m_editorUtils.Slider("Aperture", autoFocus.m_dofAperture, 0.1f, 32f, helpEnabled);
|
||||
autoFocus.m_dofFocalLength = m_editorUtils.Slider("FocalLength", autoFocus.m_dofFocalLength, 1f, 300f, helpEnabled);
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
EditorGUILayout.LabelField("Actual Focal Distance: " + autoFocus.m_actualFocusDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.LabelField("Actual Focal Distance: Will be updated at runtime");
|
||||
}
|
||||
m_editorUtils.InlineHelp("ActualFocalDistance", helpEnabled);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//Check for changes, make undo record, make changes and let editor know we are dirty
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (autoFocus != null)
|
||||
{
|
||||
Undo.RecordObject(autoFocus, "Made depth of field changes");
|
||||
EditorUtility.SetDirty(autoFocus);
|
||||
autoFocus.SetDOFMainSettings(autoFocus.m_dofAperture, autoFocus.m_dofFocalLength);
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(m_profile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profile.m_enableAutoDOF = false;
|
||||
GaiaSceneManagement.SetupAutoDepthOfField(m_profile);
|
||||
EditorGUILayout.HelpBox("Auto Depth Of Field is not yet supported for SRP this will be available in a near future update", MessageType.Info);
|
||||
}
|
||||
#else
|
||||
|
||||
EditorGUILayout.HelpBox("Post Processing V2 has not been isntalled. Please install Post Processing from the package manager to use auto depth of field.", MessageType.Info);
|
||||
|
||||
#endif
|
||||
}
|
||||
private void CameraCullingSettings(bool helpEnabled)
|
||||
{
|
||||
//Monitor for changes
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
GaiaSceneCullingProfile cullingProfile = m_profile.CullingProfile;
|
||||
m_editorUtils.Heading("TerrainCulling");
|
||||
EditorGUI.indentLevel++;
|
||||
m_profile.m_terrainCullingEnabled = m_editorUtils.Toggle("UseTerrainCulling", m_profile.m_terrainCullingEnabled, helpEnabled);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
m_editorUtils.Heading("CameraCulling");
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
bool cullingEnabled = m_profile.m_enableLayerCulling;
|
||||
cullingEnabled = m_editorUtils.Toggle("EnableLayerCulling", cullingEnabled, helpEnabled);
|
||||
if (m_profile.m_enableLayerCulling != cullingEnabled)
|
||||
{
|
||||
m_profile.m_enableLayerCulling = cullingEnabled;
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GaiaScenePlayer.UpdateCullingDistances();
|
||||
}
|
||||
else
|
||||
{
|
||||
GaiaScenePlayer.ApplySceneSetup(cullingEnabled);
|
||||
}
|
||||
}
|
||||
if (m_profile.m_enableLayerCulling)
|
||||
{
|
||||
m_editorUtils.LabelField("GeneralSettings", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
cullingProfile = (GaiaSceneCullingProfile)m_editorUtils.ObjectField("CullingProfile", cullingProfile, typeof(GaiaSceneCullingProfile), false);
|
||||
if (m_editorUtils.Button("NewProfile", GUILayout.MaxWidth(40f)))
|
||||
{
|
||||
GaiaSceneCullingProfile profile = GaiaSceneCullingProfile.CreateCullingProfile();
|
||||
cullingProfile = AssetDatabase.LoadAssetAtPath<GaiaSceneCullingProfile>(AssetDatabase.GetAssetPath(profile));
|
||||
m_profile.CullingProfile = cullingProfile;
|
||||
GUIUtility.ExitGUI();
|
||||
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
m_editorUtils.InlineHelp("CullingProfile", helpEnabled);
|
||||
if (cullingProfile != m_profile.CullingProfile)
|
||||
{
|
||||
m_profile.CullingProfile = cullingProfile;
|
||||
if (cullingProfile != null)
|
||||
{
|
||||
GaiaScenePlayer.ApplySceneSetup(cullingProfile.m_applyToEditorCamera);
|
||||
}
|
||||
}
|
||||
#if GAIA_PRO_PRESENT
|
||||
if (ProceduralWorldsGlobalWeather.Instance == null)
|
||||
{
|
||||
m_profile.m_sunLight = (Light)m_editorUtils.ObjectField("SunLight", m_profile.m_sunLight, typeof(Light), true, helpEnabled);
|
||||
if (m_profile.m_sunLight == null)
|
||||
{
|
||||
m_profile.m_sunLight = GaiaUtils.GetMainDirectionalLight();
|
||||
}
|
||||
}
|
||||
#else
|
||||
m_profile.m_sunLight = (Light)m_editorUtils.ObjectField("SunLight", m_profile.m_sunLight, typeof(Light), true, helpEnabled);
|
||||
if (m_profile.m_sunLight == null)
|
||||
{
|
||||
m_profile.m_sunLight = GaiaUtils.GetMainDirectionalLight();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_profile.CullingProfile != null)
|
||||
{
|
||||
m_profile.CullingProfile.m_applyToEditorCamera = m_editorUtils.Toggle("ApplyInEditor", m_profile.CullingProfile.m_applyToEditorCamera, helpEnabled);
|
||||
m_profile.CullingProfile.m_realtimeUpdate = m_editorUtils.Toggle("RealtimeUpdate", m_profile.CullingProfile.m_realtimeUpdate, helpEnabled);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
if (m_profile.CullingProfile != null)
|
||||
{
|
||||
//Objects
|
||||
EditorGUILayout.Space();
|
||||
m_editorUtils.LabelField("ObjectCullingSettings", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
m_editorUtils.InlineHelp("ObjectCullingSettings", helpEnabled);
|
||||
for (int i = 0; i < m_profile.CullingProfile.m_layerDistances.Length; i++)
|
||||
{
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
if (!string.IsNullOrEmpty(layerName))
|
||||
{
|
||||
m_profile.CullingProfile.m_layerDistances[i] = EditorGUILayout.FloatField(string.Format("[{0}] {1}", i, layerName), m_profile.CullingProfile.m_layerDistances[i]);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
if (m_editorUtils.Button("RevertCullingToDefaults"))
|
||||
{
|
||||
m_profile.CullingProfile.UpdateCulling(m_gaiaSettings);
|
||||
EditorUtility.SetDirty(m_profile.CullingProfile);
|
||||
}
|
||||
|
||||
//Shadows
|
||||
EditorGUILayout.Space();
|
||||
m_editorUtils.LabelField("ShadowCullingSettings", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
m_editorUtils.InlineHelp("ShadowCullingSettings", helpEnabled);
|
||||
for (int i = 0; i < m_profile.CullingProfile.m_shadowLayerDistances.Length; i++)
|
||||
{
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
if (!string.IsNullOrEmpty(layerName))
|
||||
{
|
||||
m_profile.CullingProfile.m_shadowLayerDistances[i] = EditorGUILayout.FloatField(string.Format("[{0}] {1}", i, layerName), m_profile.CullingProfile.m_shadowLayerDistances[i]);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
if (m_editorUtils.Button("RevertShadowToDefaults"))
|
||||
{
|
||||
m_profile.CullingProfile.UpdateShadow();
|
||||
EditorUtility.SetDirty(m_profile.CullingProfile);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//Check for changes, make undo record, make changes and let editor know we are dirty
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(m_profile, "Made camera culling changes");
|
||||
EditorUtility.SetDirty(m_profile);
|
||||
if (m_profile.CullingProfile != null)
|
||||
{
|
||||
EditorUtility.SetDirty(m_profile.CullingProfile);
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GaiaScenePlayer.UpdateCullingDistances();
|
||||
}
|
||||
else
|
||||
{
|
||||
GaiaScenePlayer.ApplySceneSetup(m_profile.CullingProfile.m_applyToEditorCamera);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LocationManagerSettings(bool helpEnabled)
|
||||
{
|
||||
if (m_gaiaSettings != null)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_gaiaSettings.m_enableLocationManager = m_editorUtils.Toggle("EnableLocationManager", m_gaiaSettings.m_enableLocationManager, helpEnabled);
|
||||
if (m_gaiaSettings.m_enableLocationManager)
|
||||
{
|
||||
m_editorUtils.Text("LocationManagerInfo");
|
||||
if (m_editorUtils.Button("OpenLocationManager"))
|
||||
{
|
||||
LocationManagerEditor.ShowLocationManager();
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (m_gaiaSettings.m_enableLocationManager)
|
||||
{
|
||||
LocationManagerEditor.AddLocationSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
LocationManagerEditor.RemoveLocationSystem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SetPostProcessing(GaiaLightingProfileValues profile)
|
||||
{
|
||||
if (m_gaiaSettings.m_currentRenderer == GaiaConstants.EnvironmentRenderer.BuiltIn)
|
||||
{
|
||||
if (m_profile.m_setupPostFX)
|
||||
{
|
||||
if (profile != null)
|
||||
{
|
||||
GaiaLighting.SetupPostProcessing(profile, m_profile, GaiaUtils.GetActivePipeline(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 146f066f60ffd0147b5c7cfdadf83956
|
||||
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: 5b6c26ae28d59c245b1b10649a2de217
|
||||
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: 3d8e0f2ed37c9e5408ec76c99bea3d2f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[CustomEditor(typeof(SceneProfile))]
|
||||
public class SceneProfileEditor : Editor
|
||||
{
|
||||
private SceneProfile m_profile;
|
||||
private GUIStyle m_helpBoxStyle;
|
||||
private const string m_sceneProfileContext1 = "Welcome to the Scene Profile. This profile contains all of your scene settings from lighting to water profile settings and setup. This file was saved from Scene: ";
|
||||
private const string m_sceneProfileContext2 = " To load this profile just go to Gaia Runtime and at the botton to Save And Load then load this profile to apply all the settings from this profile to your scene. Note that this will override any settings you may already have setup in your scene.";
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (m_profile == null)
|
||||
{
|
||||
m_profile = (SceneProfile) target;
|
||||
}
|
||||
|
||||
m_helpBoxStyle = SetupHelpBoxStyle();
|
||||
EditorGUILayout.LabelField(m_sceneProfileContext1 + "<b>" + m_profile.m_savedFromScene + "</b>" + m_sceneProfileContext2, m_helpBoxStyle);
|
||||
if (GUILayout.Button(new GUIContent("Open Source Scene", "This will open the scene where this profile was created from. The scene where this was saved from is shown in Bold in the text above.")))
|
||||
{
|
||||
string sceneToOpen = GaiaUtils.GetAssetPath(m_profile.m_savedFromScene + ".unity");
|
||||
if (!string.IsNullOrEmpty(sceneToOpen))
|
||||
{
|
||||
LoadSourceScene(sceneToOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GUIStyle SetupHelpBoxStyle()
|
||||
{
|
||||
GUIStyle style = GUI.skin.GetStyle("HelpBox");
|
||||
style.richText = true;
|
||||
style.fontSize = 13;
|
||||
return style;
|
||||
}
|
||||
|
||||
private void LoadSourceScene(string sceneToLoad, OpenSceneMode sceneMode = OpenSceneMode.Single)
|
||||
{
|
||||
if (EditorSceneManager.GetActiveScene().name == m_profile.m_savedFromScene)
|
||||
{
|
||||
Debug.Log("This scene is already open");
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorSceneManager.OpenScene(sceneToLoad, sceneMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce7bed647078013438dac883c68a5d86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a03e9604ee0545145921e9e3872312ba, type: 3}
|
||||
m_Name: Gaia Default Scene Culling Profile
|
||||
m_EditorClassIdentifier:
|
||||
m_applyToEditorCamera: 1
|
||||
m_realtimeUpdate: 1
|
||||
m_layerDistances:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 205
|
||||
- 512
|
||||
- 1024
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
m_layerNames:
|
||||
- Default
|
||||
- TransparentFX
|
||||
- Ignore Raycast
|
||||
-
|
||||
- Water
|
||||
- UI
|
||||
-
|
||||
-
|
||||
- PW_VFX
|
||||
- PW_Object_Small
|
||||
- PW_Object_Medium
|
||||
- PW_Object_Large
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
m_shadowLayerDistances:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 205
|
||||
- 512
|
||||
- 1024
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c832f088050d7034a98eadb4b979dfeb
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,133 @@
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
public class GaiaSceneCullingProfile : ScriptableObject
|
||||
{
|
||||
public enum ShadowCullingType
|
||||
{
|
||||
Small,
|
||||
Medium,
|
||||
Large
|
||||
}
|
||||
|
||||
[Header("Global Settings")]
|
||||
//public bool m_enableLayerCulling = true;
|
||||
public bool m_applyToEditorCamera = false;
|
||||
public bool m_realtimeUpdate = false;
|
||||
public float[] m_layerDistances = new float[32];
|
||||
public string[] m_layerNames = new string[32];
|
||||
public float[] m_shadowLayerDistances = new float[32];
|
||||
public void UpdateCulling(GaiaSettings gaiaSettings)
|
||||
{
|
||||
if (!GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (GaiaGlobal.Instance.m_mainCamera == null)
|
||||
{
|
||||
GaiaGlobal.Instance.m_mainCamera = GaiaUtils.GetCamera();
|
||||
}
|
||||
|
||||
float farClipPlane = 2000f;
|
||||
if (GaiaGlobal.Instance.m_mainCamera != null)
|
||||
{
|
||||
farClipPlane = GaiaGlobal.Instance.m_mainCamera.farClipPlane;
|
||||
}
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_sunLight == null)
|
||||
{
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight = GaiaUtils.GetMainDirectionalLight();
|
||||
}
|
||||
|
||||
Terrain terrain = TerrainHelper.GetActiveTerrain();
|
||||
|
||||
//Objects
|
||||
m_layerDistances = new float[32];
|
||||
for (int i = 0; i < m_layerDistances.Length; i++)
|
||||
{
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
switch (layerName)
|
||||
{
|
||||
case "Default":
|
||||
case "Water":
|
||||
case "PW_VFX":
|
||||
m_layerDistances[i] = 0f;
|
||||
break;
|
||||
case "PW_Object_Small":
|
||||
m_layerDistances[i] = GaiaUtils.CalculateCameraCullingLayerValue(terrain, gaiaSettings.m_currentEnvironment, 5f);
|
||||
break;
|
||||
case "PW_Object_Medium":
|
||||
m_layerDistances[i] = GaiaUtils.CalculateCameraCullingLayerValue(terrain, gaiaSettings.m_currentEnvironment, 3f);
|
||||
break;
|
||||
case "PW_Object_Large":
|
||||
m_layerDistances[i] = GaiaUtils.CalculateCameraCullingLayerValue(terrain, gaiaSettings.m_currentEnvironment);
|
||||
break;
|
||||
default:
|
||||
m_layerDistances[i] = 0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateShadow()
|
||||
{
|
||||
//Shadows
|
||||
m_shadowLayerDistances = new float[32];
|
||||
for (int i = 0; i < m_shadowLayerDistances.Length; i++)
|
||||
{
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
switch (layerName)
|
||||
{
|
||||
case "Default":
|
||||
case "Water":
|
||||
case "PW_VFX":
|
||||
m_shadowLayerDistances[i] = 0f;
|
||||
break;
|
||||
case "PW_Object_Small":
|
||||
m_shadowLayerDistances[i] = GaiaUtils.CalculateShadowCullingLayerValue(ShadowCullingType.Small, QualitySettings.shadowDistance, 0f, 0f, 5f);
|
||||
break;
|
||||
case "PW_Object_Medium":
|
||||
m_shadowLayerDistances[i] = GaiaUtils.CalculateShadowCullingLayerValue(ShadowCullingType.Medium, QualitySettings.shadowDistance, 0f, 3f, 0f);
|
||||
break;
|
||||
case "PW_Object_Large":
|
||||
m_shadowLayerDistances[i] = GaiaUtils.CalculateShadowCullingLayerValue(ShadowCullingType.Large, QualitySettings.shadowDistance, 1f, 0f, 0f);
|
||||
break;
|
||||
default:
|
||||
m_shadowLayerDistances[i] = 0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create Gaia Culling System Profile asset
|
||||
/// </summary>
|
||||
#if UNITY_EDITOR
|
||||
public static GaiaSceneCullingProfile CreateCullingProfile()
|
||||
{
|
||||
GaiaSceneCullingProfile asset = ScriptableObject.CreateInstance<GaiaSceneCullingProfile>();
|
||||
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
asset.UpdateCulling(gaiaSettings);
|
||||
asset.UpdateShadow();
|
||||
AssetDatabase.CreateAsset(asset, "Assets/Gaia Scene Culling Profile.asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
return asset;
|
||||
}
|
||||
[MenuItem("Assets/Create/Procedural Worlds/Gaia/Gaia Scene Culling Profile")]
|
||||
public static void CreateCullingProfileMenu()
|
||||
{
|
||||
GaiaSceneCullingProfile asset = ScriptableObject.CreateInstance<GaiaSceneCullingProfile>();
|
||||
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
asset.UpdateCulling(gaiaSettings);
|
||||
asset.UpdateShadow();
|
||||
AssetDatabase.CreateAsset(asset, "Assets/Gaia Scene Culling Profile.asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
EditorUtility.FocusProjectWindow();
|
||||
Selection.activeObject = asset;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a03e9604ee0545145921e9e3872312ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,376 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
#endif
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
public class GaiaSceneLighting : MonoBehaviour
|
||||
{
|
||||
public void SaveToGaiaDefault(GaiaLightingProfileValues profileValues)
|
||||
{
|
||||
if (profileValues == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GaiaLightingProfileValues newProfileValues = new GaiaLightingProfileValues();
|
||||
GaiaUtils.CopyFields(profileValues, newProfileValues);
|
||||
newProfileValues.m_userCustomProfile = false;
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
newProfileValues.PostProcessProfileBuiltIn = profileValues.PostProcessProfileBuiltIn;
|
||||
newProfileValues.m_postProcessingProfileGUIDBuiltIn = profileValues.m_postProcessingProfileGUIDBuiltIn;
|
||||
#endif
|
||||
#if UPPipeline
|
||||
newProfileValues.PostProcessProfileURP = profileValues.PostProcessProfileURP;
|
||||
newProfileValues.m_postProcessingProfileGUIDURP = profileValues.m_postProcessingProfileGUIDURP;
|
||||
#endif
|
||||
#if HDPipeline
|
||||
newProfileValues.PostProcessProfileHDRP = profileValues.PostProcessProfileHDRP;
|
||||
newProfileValues.m_postProcessingProfileGUIDHDRP = profileValues.m_postProcessingProfileGUIDHDRP;
|
||||
#endif
|
||||
|
||||
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
if (gaiaSettings != null)
|
||||
{
|
||||
GaiaLightingProfile lightingProfile = gaiaSettings.m_gaiaLightingProfile;
|
||||
if (lightingProfile != null)
|
||||
{
|
||||
bool addProfile = true;
|
||||
int indexForReplacement = 0;
|
||||
for (int i = 0; i < lightingProfile.m_lightingProfiles.Count; i++)
|
||||
{
|
||||
if (lightingProfile.m_lightingProfiles[i].m_typeOfLighting == newProfileValues.m_typeOfLighting)
|
||||
{
|
||||
addProfile = false;
|
||||
indexForReplacement = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (addProfile)
|
||||
{
|
||||
SaveColorAndCubemapFields(newProfileValues, profileValues);
|
||||
lightingProfile.m_lightingProfiles.Add(newProfileValues);
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.SetDirty(lightingProfile);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (EditorUtility.DisplayDialog("Profile Already Exists", "This profile " + newProfileValues.m_typeOfLighting + " already exists the the default Gaia lighting profile. Do you want to replace this profile?", "Yes", "No"))
|
||||
{
|
||||
GaiaUtils.CopyFields(newProfileValues, lightingProfile.m_lightingProfiles[indexForReplacement]);
|
||||
SaveColorAndCubemapFields( lightingProfile.m_lightingProfiles[indexForReplacement], profileValues);
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].PostProcessProfileBuiltIn = profileValues.PostProcessProfileBuiltIn;
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].m_postProcessingProfileGUIDBuiltIn = profileValues.m_postProcessingProfileGUIDBuiltIn;
|
||||
#endif
|
||||
#if UPPipeline
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].PostProcessProfileURP = profileValues.PostProcessProfileURP;
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].m_postProcessingProfileGUIDURP = profileValues.m_postProcessingProfileGUIDURP;
|
||||
#endif
|
||||
#if HDPipeline
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].PostProcessProfileHDRP = profileValues.PostProcessProfileHDRP;
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].m_postProcessingProfileGUIDHDRP = profileValues.m_postProcessingProfileGUIDHDRP;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.SetDirty(lightingProfile);
|
||||
#endif
|
||||
|
||||
Debug.Log("Profile successfully added to the Gaia Lighting Profile. Remember to save your project to save the changes");
|
||||
}
|
||||
}
|
||||
}
|
||||
#if GAIA_PRO_PRESENT
|
||||
public void SaveToGaiaDefault(GaiaLightingProfileValues profileValues, ProceduralWorldsGlobalWeather globalWeather)
|
||||
{
|
||||
if (profileValues == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GaiaLightingProfileValues newProfileValues = new GaiaLightingProfileValues();
|
||||
GaiaUtils.CopyFields(profileValues, newProfileValues);
|
||||
newProfileValues.m_userCustomProfile = false;
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
newProfileValues.PostProcessProfileBuiltIn = profileValues.PostProcessProfileBuiltIn;
|
||||
newProfileValues.m_postProcessingProfileGUIDBuiltIn = profileValues.m_postProcessingProfileGUIDBuiltIn;
|
||||
#endif
|
||||
#if UPPipeline
|
||||
newProfileValues.PostProcessProfileURP = profileValues.PostProcessProfileURP;
|
||||
newProfileValues.m_postProcessingProfileGUIDURP = profileValues.m_postProcessingProfileGUIDURP;
|
||||
#endif
|
||||
#if HDPipeline
|
||||
newProfileValues.PostProcessProfileHDRP = profileValues.PostProcessProfileHDRP;
|
||||
newProfileValues.m_postProcessingProfileGUIDHDRP = profileValues.m_postProcessingProfileGUIDHDRP;
|
||||
newProfileValues.EnvironmentProfileHDRP = profileValues.EnvironmentProfileHDRP;
|
||||
newProfileValues.m_environmentProfileGUIDHDRP = profileValues.m_environmentProfileGUIDHDRP;
|
||||
#endif
|
||||
|
||||
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
if (gaiaSettings != null)
|
||||
{
|
||||
GaiaLightingProfile lightingProfile = gaiaSettings.m_gaiaLightingProfile;
|
||||
if (lightingProfile != null)
|
||||
{
|
||||
bool addProfile = true;
|
||||
int indexForReplacement = 0;
|
||||
for (int i = 0; i < lightingProfile.m_lightingProfiles.Count; i++)
|
||||
{
|
||||
if (lightingProfile.m_lightingProfiles[i].m_typeOfLighting == newProfileValues.m_typeOfLighting)
|
||||
{
|
||||
addProfile = false;
|
||||
indexForReplacement = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (addProfile)
|
||||
{
|
||||
SavePWSkyAtmosphere(newProfileValues, globalWeather);
|
||||
SavePWSeason(newProfileValues, globalWeather);
|
||||
SavePWSkyCloud(newProfileValues, globalWeather);
|
||||
SavePWSkyWeather(newProfileValues, globalWeather);
|
||||
SavePWSkyWind(newProfileValues, globalWeather);
|
||||
SaveColorAndCubemapFields(newProfileValues, profileValues);
|
||||
lightingProfile.m_lightingProfiles.Add(newProfileValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (EditorUtility.DisplayDialog("Profile Already Exists", "This profile " + newProfileValues.m_typeOfLighting + " already exists the the default Gaia lighting profile. Do you want to replace this profile?", "Yes", "No"))
|
||||
{
|
||||
GaiaUtils.CopyFields(newProfileValues, lightingProfile.m_lightingProfiles[indexForReplacement]);
|
||||
SavePWSkyAtmosphere(lightingProfile.m_lightingProfiles[indexForReplacement], globalWeather);
|
||||
SavePWSeason(lightingProfile.m_lightingProfiles[indexForReplacement], globalWeather);
|
||||
SavePWSkyCloud(lightingProfile.m_lightingProfiles[indexForReplacement], globalWeather);
|
||||
SavePWSkyWeather(lightingProfile.m_lightingProfiles[indexForReplacement], globalWeather);
|
||||
SavePWSkyWind(lightingProfile.m_lightingProfiles[indexForReplacement], globalWeather);
|
||||
SaveColorAndCubemapFields( lightingProfile.m_lightingProfiles[indexForReplacement], profileValues);
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].PostProcessProfileBuiltIn = profileValues.PostProcessProfileBuiltIn;
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].m_postProcessingProfileGUIDBuiltIn = profileValues.m_postProcessingProfileGUIDBuiltIn;
|
||||
#endif
|
||||
#if UPPipeline
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].PostProcessProfileURP = profileValues.PostProcessProfileURP;
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].m_postProcessingProfileGUIDURP = profileValues.m_postProcessingProfileGUIDURP;
|
||||
#endif
|
||||
#if HDPipeline
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].PostProcessProfileHDRP = profileValues.PostProcessProfileHDRP;
|
||||
lightingProfile.m_lightingProfiles[indexForReplacement].m_postProcessingProfileGUIDHDRP = profileValues.m_postProcessingProfileGUIDHDRP;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.SetDirty(lightingProfile);
|
||||
#endif
|
||||
|
||||
Debug.Log("Profile successfully added to the Gaia Lighting Profile. Remember to save your project to save the changes");
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SavePWSkyAtmosphere(GaiaLightingProfileValues profileValues, ProceduralWorldsGlobalWeather globalWeather)
|
||||
{
|
||||
if (profileValues == null || globalWeather == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
profileValues.m_pwSkyAtmosphereData.TODSkyboxTint = globalWeather.TODSkyboxTint;
|
||||
profileValues.m_pwSkyAtmosphereData.TODSkyboxExposure = globalWeather.TODSkyboxExposure;
|
||||
profileValues.m_pwSkyAtmosphereData.TODSunColor = globalWeather.TODSunColor;
|
||||
profileValues.m_pwSkyAtmosphereData.TODFogColor = globalWeather.TODFogColor;
|
||||
profileValues.m_pwSkyAtmosphereData.TODAmbientSkyColor = globalWeather.TODAmbientSkyColor;
|
||||
profileValues.m_pwSkyAtmosphereData.TODAmbientEquatorColor = globalWeather.TODAmbientEquatorColor;
|
||||
profileValues.m_pwSkyAtmosphereData.TODAmbientGroundColor = globalWeather.TODAmbientGroundColor;
|
||||
profileValues.m_pwSkyAtmosphereData.TODSunIntensity = globalWeather.TODSunIntensity;
|
||||
profileValues.m_pwSkyAtmosphereData.TODSunShadowStrength = globalWeather.TODSunShadowStrength;
|
||||
profileValues.m_pwSkyAtmosphereData.TODCloudHeightLevelDensity = globalWeather.TODCloudHeightLevelDensity;
|
||||
profileValues.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness = globalWeather.TODCloudHeightLevelThickness;
|
||||
profileValues.m_pwSkyAtmosphereData.TODCloudHeightLevelSpeed = globalWeather.TODCloudHeightLevelSpeed;
|
||||
profileValues.m_pwSkyAtmosphereData.TODCloudOpacity = globalWeather.TODCloudOpacity;
|
||||
profileValues.m_pwSkyAtmosphereData.CloudDomeBrightness = globalWeather.CloudDomeBrightness;
|
||||
profileValues.m_pwSkyAtmosphereData.TODAmbientIntensity = globalWeather.TODAmbientIntensity;
|
||||
profileValues.m_pwSkyAtmosphereData.TODAtmosphereThickness = globalWeather.TODAtmosphereThickness;
|
||||
profileValues.m_pwSkyAtmosphereData.TODFogDensity = globalWeather.TODFogDensity;
|
||||
profileValues.m_pwSkyAtmosphereData.TODFogStartDistance = globalWeather.TODFogStartDistance;
|
||||
profileValues.m_pwSkyAtmosphereData.TODFogEndDistance = globalWeather.TODFogEndDistance;
|
||||
profileValues.m_pwSkyAtmosphereData.TODHDRPFogBaseHeight = globalWeather.TODHDRPFogBaseHeight;
|
||||
profileValues.m_pwSkyAtmosphereData.TODHDRPFogAnisotropy = globalWeather.TODHDRPFogAnisotropy;
|
||||
profileValues.m_pwSkyAtmosphereData.TODHDRPFogLightProbeDimmer = globalWeather.TODHDRPFogLightProbeDimmer;
|
||||
profileValues.m_pwSkyAtmosphereData.TODHDRPFogDepthExtent = globalWeather.TODHDRPFogDepthExtent;
|
||||
profileValues.m_pwSkyAtmosphereData.TODHDRPGroundTint = globalWeather.TODHDRPGroundTint;
|
||||
profileValues.m_pwSkyAtmosphereData.TODHDRPFogAlbedo = globalWeather.TODHDRPFogAlbedo;
|
||||
profileValues.m_pwSkyAtmosphereData.TODSunSize = globalWeather.TODSunSize;
|
||||
profileValues.m_pwSkyAtmosphereData.TODSunSizeConvergence = globalWeather.TODSunSizeConvergence;
|
||||
}
|
||||
private void SavePWSkyCloud(GaiaLightingProfileValues profileValues, ProceduralWorldsGlobalWeather globalWeather)
|
||||
{
|
||||
if (profileValues == null || globalWeather == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
profileValues.m_pwSkyCloudData.EnableClouds = globalWeather.EnableClouds;
|
||||
profileValues.m_pwSkyCloudData.CloudHeight = globalWeather.CloudHeight;
|
||||
profileValues.m_pwSkyCloudData.CloudAmbientColor = globalWeather.CloudAmbientColor;
|
||||
profileValues.m_pwSkyCloudData.CloudScale = globalWeather.CloudScale;
|
||||
profileValues.m_pwSkyCloudData.CloudOffset = globalWeather.CloudOffset;
|
||||
profileValues.m_pwSkyCloudData.CloudBrightness = globalWeather.CloudBrightness;
|
||||
profileValues.m_pwSkyCloudData.CloudFade = globalWeather.CloudFade;
|
||||
profileValues.m_pwSkyCloudData.CloudTilingAndWind = globalWeather.CloudTilingAndWind;
|
||||
profileValues.m_pwSkyCloudData.CloudOpacity = globalWeather.CloudOpacity;
|
||||
profileValues.m_pwSkyCloudData.CloudRotationSpeedLow = globalWeather.CloudRotationSpeedLow;
|
||||
profileValues.m_pwSkyCloudData.CloudRotationSpeedMiddle = globalWeather.CloudRotationSpeedMiddle;
|
||||
profileValues.m_pwSkyCloudData.CloudRotationSpeedFar = globalWeather.CloudRotationSpeedFar;
|
||||
}
|
||||
private void SavePWSeason(GaiaLightingProfileValues profileValues, ProceduralWorldsGlobalWeather globalWeather)
|
||||
{
|
||||
if (profileValues == null || globalWeather == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
profileValues.m_pwSkySeasonData.EnableSeasons = globalWeather.EnableSeasons;
|
||||
profileValues.m_pwSkySeasonData.SeasonMode = globalWeather.SeasonMode;
|
||||
profileValues.m_pwSkySeasonData.Season = globalWeather.Season;
|
||||
profileValues.m_pwSkySeasonData.SeasonWinterTint = globalWeather.SeasonWinterTint;
|
||||
profileValues.m_pwSkySeasonData.SeasonSpringTint = globalWeather.SeasonSpringTint;
|
||||
profileValues.m_pwSkySeasonData.SeasonSummerTint = globalWeather.SeasonSummerTint;
|
||||
profileValues.m_pwSkySeasonData.SeasonAutumnTint = globalWeather.SeasonAutumnTint;
|
||||
profileValues.m_pwSkySeasonData.m_seasonTransitionDuration = globalWeather.m_seasonTransitionDuration;
|
||||
}
|
||||
private void SavePWSkyWind(GaiaLightingProfileValues profileValues, ProceduralWorldsGlobalWeather globalWeather)
|
||||
{
|
||||
if (profileValues == null || globalWeather == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
profileValues.m_pwSkyWindData.WindSpeed = globalWeather.WindSpeed;
|
||||
profileValues.m_pwSkyWindData.WindTurbulence = globalWeather.WindTurbulence;
|
||||
profileValues.m_pwSkyWindData.WindFrequency = globalWeather.WindFrequency;
|
||||
profileValues.m_pwSkyWindData.WindDirection = globalWeather.WindDirection;
|
||||
profileValues.m_pwSkyWindData.WindMultiplier = globalWeather.WindMultiplier;
|
||||
}
|
||||
private void SavePWSkyWeather(GaiaLightingProfileValues profileValues, ProceduralWorldsGlobalWeather globalWeather)
|
||||
{
|
||||
if (profileValues == null || globalWeather == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
profileValues.m_pwSkyWeatherData.m_weatherFadeDuration = globalWeather.m_weatherFadeDuration;
|
||||
profileValues.m_pwSkyWeatherData.m_modifyFog = globalWeather.m_modifyFog;
|
||||
profileValues.m_pwSkyWeatherData.m_modifyWind = globalWeather.m_modifyWind;
|
||||
profileValues.m_pwSkyWeatherData.m_modifySkybox = globalWeather.m_modifySkybox;
|
||||
profileValues.m_pwSkyWeatherData.m_modifyPostProcessing = globalWeather.m_modifyPostProcessing;
|
||||
profileValues.m_pwSkyWeatherData.m_modifySun = globalWeather.m_modifySun;
|
||||
profileValues.m_pwSkyWeatherData.m_modifyAmbient = globalWeather.m_modifyAmbient;
|
||||
profileValues.m_pwSkyWeatherData.m_modifyClouds = globalWeather.m_modifyClouds;
|
||||
|
||||
profileValues.m_pwSkyWeatherData.m_rainSettings.EnableRain = globalWeather.EnableRain;
|
||||
profileValues.m_pwSkyWeatherData.m_rainSettings.RainIntensity = globalWeather.RainIntensity;
|
||||
profileValues.m_pwSkyWeatherData.m_rainSettings.m_rainMode = globalWeather.m_rainMode;
|
||||
profileValues.m_pwSkyWeatherData.m_rainSettings.m_rainHeight = globalWeather.m_rainHeight;
|
||||
profileValues.m_pwSkyWeatherData.m_rainSettings.m_rainStepSize = globalWeather.m_rainStepSize;
|
||||
GaiaUtils.CopyFields(globalWeather.m_rainWeatherSettings, profileValues.m_pwSkyWeatherData.m_rainSettings.m_rainWeatherSettings);
|
||||
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.EnableSnow = globalWeather.EnableSnow;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.SnowCoverAlwaysEnabled = globalWeather.SnowCoverAlwaysEnabled;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.SnowIntensity = globalWeather.SnowIntensity;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.SnowHeight = globalWeather.SnowHeight;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.PermanentSnowHeight = globalWeather.PermanentSnowHeight;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.SnowingHeight = globalWeather.SnowingHeight;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.SnowFadeHeight = globalWeather.SnowFadeHeight;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.m_snowStormChance = globalWeather.m_snowStormChance;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.m_snowStepSize = globalWeather.m_snowStepSize;
|
||||
profileValues.m_pwSkyWeatherData.m_snowSettings.m_snowMode = globalWeather.m_snowMode;
|
||||
GaiaUtils.CopyFields(globalWeather.m_snowWeatherSettings, profileValues.m_pwSkyWeatherData.m_snowSettings.m_snowWeatherSettings);
|
||||
|
||||
profileValues.m_pwSkyWeatherData.m_thunderSettings.m_enableThunder = globalWeather.m_enableThunder;
|
||||
profileValues.m_pwSkyWeatherData.m_thunderSettings.ThunderWaitDuration = globalWeather.ThunderWaitDuration;
|
||||
profileValues.m_pwSkyWeatherData.m_thunderSettings.m_thunderChance = globalWeather.m_thunderChance;
|
||||
profileValues.m_pwSkyWeatherData.m_thunderSettings.ThunderLightColor = globalWeather.ThunderLightColor;
|
||||
profileValues.m_pwSkyWeatherData.m_thunderSettings.ThunderLightIntensity = globalWeather.ThunderLightIntensity;
|
||||
profileValues.m_pwSkyWeatherData.m_thunderSettings.ThunderAudioSources = globalWeather.ThunderAudioSources;
|
||||
profileValues.m_pwSkyWeatherData.m_thunderSettings.ThunderLightRadius = globalWeather.ThunderLightRadius;
|
||||
}
|
||||
#endif
|
||||
private void SaveColorAndCubemapFields(GaiaLightingProfileValues newProfileValues, GaiaLightingProfileValues profileValues)
|
||||
{
|
||||
newProfileValues.m_sunColor = profileValues.m_sunColor;
|
||||
newProfileValues.m_lWSunColor = profileValues.m_lWSunColor;
|
||||
newProfileValues.m_hDSunColor = profileValues.m_hDSunColor;
|
||||
newProfileValues.m_skyboxTint = profileValues.m_skyboxTint;
|
||||
newProfileValues.m_hDGradientTopColor = profileValues.m_hDGradientTopColor;
|
||||
newProfileValues.m_hDGradientMiddleColor = profileValues.m_hDGradientMiddleColor;
|
||||
newProfileValues.m_hDGradientBottomColor = profileValues.m_hDGradientBottomColor;
|
||||
newProfileValues.m_hDHDRISkybox = profileValues.m_hDHDRISkybox;
|
||||
newProfileValues.m_hDProceduralSkyTint = profileValues.m_hDProceduralSkyTint;
|
||||
newProfileValues.m_hDProceduralGroundColor = profileValues.m_hDProceduralGroundColor;
|
||||
newProfileValues.m_hDPBSGroundAlbedoTexture = profileValues.m_hDPBSGroundAlbedoTexture;
|
||||
newProfileValues.m_hDPBSGroundEmissionTexture = profileValues.m_hDPBSGroundEmissionTexture;
|
||||
newProfileValues.m_hDPBSSpaceEmissionTexture = profileValues.m_hDPBSSpaceEmissionTexture;
|
||||
newProfileValues.m_hDPBSAirOpacity = profileValues.m_hDPBSAirOpacity;
|
||||
newProfileValues.m_hDPBSAirAlbedo = profileValues.m_hDPBSAirAlbedo;
|
||||
newProfileValues.m_hDPBSAirTint = profileValues.m_hDPBSAirTint;
|
||||
newProfileValues.m_hDPBSAerosolAlbedo = profileValues.m_hDPBSAerosolAlbedo;
|
||||
newProfileValues.m_hDPBSHorizonTint = profileValues.m_hDPBSHorizonTint;
|
||||
newProfileValues.m_hDPBSZenithTint = profileValues.m_hDPBSZenithTint;
|
||||
newProfileValues.m_skyAmbient = profileValues.m_skyAmbient;
|
||||
newProfileValues.m_equatorAmbient = profileValues.m_equatorAmbient;
|
||||
newProfileValues.m_groundAmbient = profileValues.m_groundAmbient;
|
||||
newProfileValues.m_fogColor = profileValues.m_fogColor;
|
||||
newProfileValues.m_hDVolumetricFogScatterColor = profileValues.m_hDVolumetricFogScatterColor;
|
||||
newProfileValues.m_profileType = profileValues.m_profileType;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds post processing fog layer to the camera
|
||||
/// </summary>
|
||||
/// <param name="camera"></param>
|
||||
/// <param name="enabled"></param>
|
||||
public static void AddReflectionFog(Camera camera, bool enabled)
|
||||
{
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
if (camera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
PostProcessLayer layer = camera.GetComponent<PostProcessLayer>();
|
||||
if (layer == null)
|
||||
{
|
||||
layer = camera.gameObject.AddComponent<PostProcessLayer>();
|
||||
layer.fog.enabled = true;
|
||||
layer.fog.excludeSkybox = true;
|
||||
layer.antialiasingMode = PostProcessLayer.Antialiasing.None;
|
||||
layer.volumeLayer = 2;
|
||||
layer.volumeTrigger = camera.transform;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PostProcessLayer layer = camera.GetComponent<PostProcessLayer>();
|
||||
if (layer != null)
|
||||
{
|
||||
DestroyImmediate(layer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb1f567dbec4e7745b9ee94c3cb29f66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,421 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System;
|
||||
using System.Linq;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class GaiaScenePlayer : MonoBehaviour
|
||||
{
|
||||
private Camera m_camera;
|
||||
private float m_cameraFOV;
|
||||
private Vector3 m_FOVCenter;
|
||||
private Bounds m_worldSpaceBounds = new Bounds();
|
||||
private Plane[] m_planes = new Plane[6];
|
||||
private Terrain[] m_allTerrains = new Terrain[0];
|
||||
private MeshRenderer[] m_allTerrainMeshRenderers = new MeshRenderer[0];
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (!GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_camera = GaiaGlobal.Instance.m_mainCamera;
|
||||
m_allTerrains = Terrain.activeTerrains;
|
||||
|
||||
//Collect all Mesh Terrains that are present at startup
|
||||
List<MeshRenderer> tempMeshRenderers = new List<MeshRenderer>();
|
||||
|
||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||
{
|
||||
Scene scene = SceneManager.GetSceneAt(i);
|
||||
foreach (GameObject go in scene.GetRootGameObjects())
|
||||
{
|
||||
AddTerrainMeshRenderer(go, tempMeshRenderers);
|
||||
}
|
||||
}
|
||||
m_allTerrainMeshRenderers = tempMeshRenderers.ToArray();
|
||||
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_terrainCullingEnabled)
|
||||
{
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
SceneManager.sceneUnloaded -= OnSceneUnLoaded;
|
||||
SceneManager.sceneUnloaded += OnSceneUnLoaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
SceneManager.sceneUnloaded -= OnSceneUnLoaded;
|
||||
}
|
||||
|
||||
UpdateCullingDistances();
|
||||
}
|
||||
|
||||
private void AddTerrainMeshRenderer(GameObject go, List<MeshRenderer> meshRenderers)
|
||||
{
|
||||
if (IsSingleMeshTerrain(go))
|
||||
{
|
||||
MeshRenderer mr = go.GetComponent<MeshRenderer>();
|
||||
if (mr != null)
|
||||
{
|
||||
if (!meshRenderers.Contains(mr) && !m_allTerrainMeshRenderers.Contains(mr))
|
||||
{
|
||||
meshRenderers.Add(mr);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsMeshLODTerrain(go))
|
||||
{
|
||||
LODGroup lg = go.GetComponent<LODGroup>();
|
||||
foreach (LOD lod in lg.GetLODs())
|
||||
{
|
||||
foreach (Renderer renderer in lod.renderers)
|
||||
{
|
||||
if (renderer != null && renderer.GetType() == typeof(MeshRenderer))
|
||||
{
|
||||
MeshRenderer mr = (MeshRenderer)renderer;
|
||||
|
||||
if (!meshRenderers.Contains(mr))
|
||||
{
|
||||
meshRenderers.Add((MeshRenderer)mr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsSingleMeshTerrain(GameObject go)
|
||||
{
|
||||
//Two possible things to find here: terrains that have been converted to a single mesh terrain or impostor terrains WITHOUT a LOD Group.
|
||||
string searchString = GaiaConstants.MeshTerrainName;
|
||||
string searchString2 = GaiaConstants.ImpostorTerrainName;
|
||||
if (go.name.StartsWith(searchString) || (go.name.StartsWith(searchString2) && go.GetComponent<LODGroup>() == null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsMeshLODTerrain(GameObject go)
|
||||
{
|
||||
//Two possible things to find here: terrains that have been converted to a mesh terrain with a LOD Group, or impostor terrains with a LOD Group.
|
||||
string searchString1 = GaiaConstants.MeshTerrainLODGroupPrefix;
|
||||
string searchString2 = GaiaConstants.ImpostorTerrainName;
|
||||
if (go.name.StartsWith(searchString1) || (go.name.StartsWith(searchString2) && go.GetComponent<LODGroup>()!=null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GaiaGlobal.Instance.SceneProfile.m_terrainCullingEnabled || m_camera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Vector3 cameraForward = m_camera.transform.forward;
|
||||
float cameraViewDistance = m_camera.farClipPlane;
|
||||
m_cameraFOV = m_camera.fieldOfView;
|
||||
|
||||
m_FOVCenter = new Vector3(cameraForward.x, cameraForward.z).normalized * cameraViewDistance;
|
||||
GeometryUtility.CalculateFrustumPlanes(m_camera, m_planes);
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_terrainCullingEnabled)
|
||||
{
|
||||
for (int i = 0; i < m_allTerrains.Length; i++)
|
||||
{
|
||||
Terrain terrain = m_allTerrains[i];
|
||||
if (terrain == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//Check needs to performed in world space, terrain bounds are in local space of the terrain
|
||||
m_worldSpaceBounds = terrain.terrainData.bounds;
|
||||
m_worldSpaceBounds.center = new Vector3(m_worldSpaceBounds.center.x + terrain.transform.position.x, m_worldSpaceBounds.center.y + terrain.transform.position.y, m_worldSpaceBounds.center.z + terrain.transform.position.z);
|
||||
|
||||
if (GeometryUtility.TestPlanesAABB(m_planes, m_worldSpaceBounds))
|
||||
{
|
||||
terrain.drawHeightmap = true;
|
||||
terrain.drawTreesAndFoliage = true;
|
||||
|
||||
//Deactivate terrain GO entirely
|
||||
//terrain.gameObject.SetActive(true);
|
||||
|
||||
//Activate object spawns
|
||||
//Transform spawnsTransform = terrain.gameObject.transform.Find(GaiaConstants.defaultGOSpawnTarget);
|
||||
//spawnsTransform.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
terrain.drawHeightmap = false;
|
||||
terrain.drawTreesAndFoliage = false;
|
||||
|
||||
//Deactivate terrain GO entirely
|
||||
//terrain.gameObject.SetActive(false);
|
||||
|
||||
//Deactivate object spawns
|
||||
//Transform spawnsTransform = terrain.gameObject.transform.Find(GaiaConstants.defaultGOSpawnTarget);
|
||||
//spawnsTransform.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_terrainCullingEnabled)
|
||||
{
|
||||
for (int i = 0; i < m_allTerrainMeshRenderers.Length; i++)
|
||||
{
|
||||
MeshRenderer mr = m_allTerrainMeshRenderers[i];
|
||||
if (mr != null)
|
||||
{
|
||||
if (GeometryUtility.TestPlanesAABB(m_planes, mr.bounds))
|
||||
{
|
||||
mr.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mr.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
SceneManager.sceneUnloaded -= OnSceneUnLoaded;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
UpdateCullingDistances();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GaiaGlobal.Instance.SceneProfile.CullingProfile != null)
|
||||
{
|
||||
ApplySceneSetup(GaiaGlobal.Instance.SceneProfile.CullingProfile.m_applyToEditorCamera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Terrain Culling
|
||||
private void OnSceneUnLoaded(Scene scene)
|
||||
{
|
||||
Invoke("UpdateTerrains", 0.5f);
|
||||
|
||||
m_allTerrainMeshRenderers = m_allTerrainMeshRenderers.Where(x => x != null).ToArray();
|
||||
|
||||
|
||||
|
||||
}
|
||||
private void OnSceneLoaded(Scene scene, LoadSceneMode arg1)
|
||||
{
|
||||
Invoke("UpdateTerrains", 0.5f);
|
||||
List<MeshRenderer> tempMeshRenderers = new List<MeshRenderer>();
|
||||
foreach (GameObject go in scene.GetRootGameObjects())
|
||||
{
|
||||
AddTerrainMeshRenderer(go, tempMeshRenderers);
|
||||
}
|
||||
m_allTerrainMeshRenderers = m_allTerrainMeshRenderers.Concat(tempMeshRenderers).ToArray();
|
||||
}
|
||||
private void UpdateTerrains()
|
||||
{
|
||||
m_allTerrains = Terrain.activeTerrains;
|
||||
}
|
||||
|
||||
//Camera Culling
|
||||
public static void UpdateCullingDistances()
|
||||
{
|
||||
if (!GaiaUtils.CheckIfSceneProfileExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.CullingProfile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if GAIA_PRO_PRESENT
|
||||
if (ProceduralWorldsGlobalWeather.Instance != null)
|
||||
{
|
||||
if (ProceduralWorldsGlobalWeather.Instance.CheckIsNight())
|
||||
{
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight = ProceduralWorldsGlobalWeather.Instance.m_moonLight;
|
||||
}
|
||||
else
|
||||
{
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight = ProceduralWorldsGlobalWeather.Instance.m_sunLight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_sunLight == null)
|
||||
{
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight = GaiaUtils.GetMainDirectionalLight();
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_sunLight == null)
|
||||
{
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight = GaiaUtils.GetMainDirectionalLight();
|
||||
}
|
||||
#endif
|
||||
|
||||
//Make sure we have distances
|
||||
if (GaiaGlobal.Instance.SceneProfile.CullingProfile.m_layerDistances == null || GaiaGlobal.Instance.SceneProfile.CullingProfile.m_layerDistances.Length != 32)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_enableLayerCulling)
|
||||
{
|
||||
//Apply to main camera
|
||||
GaiaGlobal.Instance.m_mainCamera.layerCullDistances = GaiaGlobal.Instance.SceneProfile.CullingProfile.m_layerDistances;
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_sunLight != null)
|
||||
{
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight.layerShadowCullDistances = GaiaGlobal.Instance.SceneProfile.CullingProfile.m_shadowLayerDistances;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float[] layerCulls = new float[32];
|
||||
for (int i = 0; i < layerCulls.Length; i++)
|
||||
{
|
||||
layerCulls[i] = 0f;
|
||||
}
|
||||
|
||||
//Apply to main camera
|
||||
GaiaGlobal.Instance.m_mainCamera.layerCullDistances = layerCulls;
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_sunLight != null)
|
||||
{
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight.layerShadowCullDistances = layerCulls;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void ApplySceneSetup(bool active)
|
||||
{
|
||||
//Apply to editor camera
|
||||
#if UNITY_EDITOR
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_enableLayerCulling)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
foreach (var sceneCamera in SceneView.GetAllSceneCameras())
|
||||
{
|
||||
sceneCamera.layerCullDistances = GaiaGlobal.Instance.SceneProfile.CullingProfile.m_layerDistances;
|
||||
}
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_sunLight != null)
|
||||
{
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight.layerShadowCullDistances = GaiaGlobal.Instance.SceneProfile.CullingProfile.m_shadowLayerDistances;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var sceneCamera in SceneView.GetAllSceneCameras())
|
||||
{
|
||||
float[] layers = new float[32];
|
||||
for (int i = 0; i < layers.Length; i++)
|
||||
{
|
||||
layers[i] = 0f;
|
||||
}
|
||||
|
||||
sceneCamera.layerCullDistances = layers;
|
||||
}
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_sunLight != null)
|
||||
{
|
||||
float[] layers = new float[32];
|
||||
for (int i = 0; i < layers.Length; i++)
|
||||
{
|
||||
layers[i] = 0f;
|
||||
}
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight.layerShadowCullDistances = layers;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var sceneCamera in SceneView.GetAllSceneCameras())
|
||||
{
|
||||
float[] layers = new float[32];
|
||||
for (int i = 0; i < layers.Length; i++)
|
||||
{
|
||||
layers[i] = 0f;
|
||||
}
|
||||
|
||||
sceneCamera.layerCullDistances = layers;
|
||||
}
|
||||
|
||||
if (GaiaGlobal.Instance.SceneProfile.m_sunLight != null)
|
||||
{
|
||||
float[] layers = new float[32];
|
||||
for (int i = 0; i < layers.Length; i++)
|
||||
{
|
||||
layers[i] = 0f;
|
||||
}
|
||||
GaiaGlobal.Instance.SceneProfile.m_sunLight.layerShadowCullDistances = layers;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//Controller Setup
|
||||
/// <summary>
|
||||
/// Sets the current controller type
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
public static void SetCurrentControllerType(GaiaConstants.EnvironmentControllerType type)
|
||||
{
|
||||
LocationSystem system = FindObjectOfType<LocationSystem>();
|
||||
if (system != null)
|
||||
{
|
||||
if (system.m_locationProfile != null)
|
||||
{
|
||||
system.m_locationProfile.m_currentControllerType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 397b8755dd13e9f4c906f334207c0dc0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
public class GaiaSceneWater : MonoBehaviour
|
||||
{
|
||||
public void SaveToGaiaDefault(GaiaWaterProfileValues profileValues)
|
||||
{
|
||||
if (profileValues == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GaiaWaterProfileValues newProfileValues = new GaiaWaterProfileValues();
|
||||
GaiaUtils.CopyFields(profileValues, newProfileValues);
|
||||
newProfileValues.m_userCustomProfile = false;
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
newProfileValues.PostProcessProfileBuiltIn = profileValues.PostProcessProfileBuiltIn;
|
||||
newProfileValues.m_postProcessingProfileGUIDBuiltIn = profileValues.m_postProcessingProfileGUIDBuiltIn;
|
||||
#endif
|
||||
#if UPPipeline
|
||||
newProfileValues.PostProcessProfileURP = profileValues.PostProcessProfileURP;
|
||||
newProfileValues.m_postProcessingProfileGUIDURP = profileValues.m_postProcessingProfileGUIDURP;
|
||||
#endif
|
||||
#if HDPipeline
|
||||
newProfileValues.PostProcessProfileHDRP = profileValues.PostProcessProfileHDRP;
|
||||
newProfileValues.m_postProcessingProfileGUIDHDRP = profileValues.m_postProcessingProfileGUIDHDRP;
|
||||
#endif
|
||||
|
||||
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
|
||||
if (gaiaSettings != null)
|
||||
{
|
||||
GaiaWaterProfile waterProfile = gaiaSettings.m_gaiaWaterProfile;
|
||||
if (waterProfile != null)
|
||||
{
|
||||
bool addProfile = true;
|
||||
int indexForReplacement = 0;
|
||||
for (int i = 0; i < waterProfile.m_waterProfiles.Count; i++)
|
||||
{
|
||||
if (waterProfile.m_waterProfiles[i].m_typeOfWater == newProfileValues.m_typeOfWater)
|
||||
{
|
||||
addProfile = false;
|
||||
indexForReplacement = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (addProfile)
|
||||
{
|
||||
SaveColorAndCubemapFields(newProfileValues, profileValues);
|
||||
waterProfile.m_waterProfiles.Add(newProfileValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (EditorUtility.DisplayDialog("Profile Already Exists", "This profile " + newProfileValues.m_typeOfWater + " already exists the the default Gaia water profile. Do you want to replace this profile?", "Yes", "No"))
|
||||
{
|
||||
GaiaUtils.CopyFields(newProfileValues, waterProfile.m_waterProfiles[indexForReplacement]);
|
||||
SaveColorAndCubemapFields(waterProfile.m_waterProfiles[indexForReplacement], profileValues);
|
||||
#if UNITY_POST_PROCESSING_STACK_V2
|
||||
waterProfile.m_waterProfiles[indexForReplacement].PostProcessProfileBuiltIn = profileValues.PostProcessProfileBuiltIn;
|
||||
waterProfile.m_waterProfiles[indexForReplacement].m_postProcessingProfileGUIDBuiltIn = profileValues.m_postProcessingProfileGUIDBuiltIn;
|
||||
#endif
|
||||
#if UPPipeline
|
||||
waterProfile.m_waterProfiles[indexForReplacement].PostProcessProfileURP = profileValues.PostProcessProfileURP;
|
||||
waterProfile.m_waterProfiles[indexForReplacement].m_postProcessingProfileGUIDURP = profileValues.m_postProcessingProfileGUIDURP;
|
||||
#endif
|
||||
#if HDPipeline
|
||||
waterProfile.m_waterProfiles[indexForReplacement].PostProcessProfileHDRP = profileValues.PostProcessProfileHDRP;
|
||||
waterProfile.m_waterProfiles[indexForReplacement].m_postProcessingProfileGUIDHDRP = profileValues.m_postProcessingProfileGUIDHDRP;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.SetDirty(waterProfile);
|
||||
#endif
|
||||
|
||||
Debug.Log("Profile successfully added to the Gaia Water Profile. Remember to save your project to save the changes");
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SaveColorAndCubemapFields(GaiaWaterProfileValues newProfileValues, GaiaWaterProfileValues profileValues)
|
||||
{
|
||||
newProfileValues.m_underwaterFogGradient = profileValues.m_underwaterFogGradient;
|
||||
newProfileValues.m_gradientUnderwaterPostExposure = profileValues.m_gradientUnderwaterPostExposure;
|
||||
newProfileValues.m_gradientUnderwaterColorFilter = profileValues.m_gradientUnderwaterColorFilter;
|
||||
newProfileValues.m_colorDepthRamp = profileValues.m_colorDepthRamp;
|
||||
newProfileValues.m_normalLayer0 = profileValues.m_normalLayer0;
|
||||
newProfileValues.m_normalLayer1 = profileValues.m_normalLayer1;
|
||||
newProfileValues.m_fadeNormal = profileValues.m_fadeNormal;
|
||||
newProfileValues.m_foamTexture = profileValues.m_foamTexture;
|
||||
newProfileValues.m_foamAlphaRamp = profileValues.m_foamAlphaRamp;
|
||||
newProfileValues.m_renderTexture = profileValues.m_renderTexture;
|
||||
newProfileValues.m_foamBubbleTexture = profileValues.m_foamBubbleTexture;
|
||||
newProfileValues.m_refractionRenderResolution = profileValues.m_refractionRenderResolution;
|
||||
newProfileValues.m_underwaterFogColor = profileValues.m_underwaterFogColor;
|
||||
newProfileValues.m_constUnderwaterColorFilter = profileValues.m_constUnderwaterColorFilter;
|
||||
newProfileValues.m_specularColor = profileValues.m_specularColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9aa5b69fd603c4c449abee1322720797
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,377 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
[System.Serializable]
|
||||
public class ReflectionProbeData
|
||||
{
|
||||
[Header("Reflection Probe Settings")]
|
||||
public ReflectionProbeMode reflectionProbeMode = ReflectionProbeMode.Realtime;
|
||||
public GaiaConstants.ReflectionProbeRefreshModePW reflectionProbeRefresh = GaiaConstants.ReflectionProbeRefreshModePW.OnAwake;
|
||||
public ReflectionCubemapCompression reflectionCubemapCompression = ReflectionCubemapCompression.Auto;
|
||||
public ReflectionProbeTimeSlicingMode reflectionProbeTimeSlicingMode = ReflectionProbeTimeSlicingMode.IndividualFaces;
|
||||
public int reflectionProbesPerRow = 5;
|
||||
public float reflectionProbeOffset = 1.8f;
|
||||
public float reflectionProbeClipPlaneDistance = 1000f;
|
||||
public float reflectionProbeBlendDistance = 5f;
|
||||
public LayerMask reflectionprobeCullingMask = 1;
|
||||
public float reflectionProbeShadowDistance = 100f;
|
||||
public GaiaConstants.ReflectionProbeResolution reflectionProbeResolution = GaiaConstants.ReflectionProbeResolution.Resolution64;
|
||||
public int lightProbesPerRow = 50;
|
||||
public int lightProbeSpawnRadius = 25;
|
||||
public float seaLevel = 50f;
|
||||
#if UNITY_EDITOR
|
||||
#if !UNITY_2020_1_OR_NEWER
|
||||
public LightmapEditorSettings.FilterMode filterMode = LightmapEditorSettings.FilterMode.Auto;
|
||||
#else
|
||||
public LightingSettings.FilterMode filterMode = LightingSettings.FilterMode.Auto;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
public class SceneProfile : ScriptableObject
|
||||
{
|
||||
public string ProfileVersion = "None";
|
||||
|
||||
#region Global
|
||||
|
||||
//Global
|
||||
public bool m_reimportHDRPShader = false;
|
||||
public string m_savedFromScene;
|
||||
public GaiaTimeOfDay m_gaiaTimeOfDay = new GaiaTimeOfDay();
|
||||
public GaiaWeather m_gaiaWeather = new GaiaWeather();
|
||||
public float m_lodBias = 2f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lighting
|
||||
|
||||
//Lighting
|
||||
public Texture2D m_kelvinTexture;
|
||||
public GaiaConstants.GlobalSystemMode m_lightSystemMode = GaiaConstants.GlobalSystemMode.Gaia;
|
||||
public GameObject m_thirdPartyLightObject;
|
||||
public bool DefaultLightingSet = false;
|
||||
public bool m_lightingMultiSceneLightingSupport = true;
|
||||
public bool m_lightingUpdateInRealtime = false;
|
||||
public int m_selectedLightingProfileValuesIndex = 0;
|
||||
public GaiaConstants.GaiaLightingProfileType m_profileType = GaiaConstants.GaiaLightingProfileType.HDRI;
|
||||
public bool m_renamingProfile = false;
|
||||
public bool m_lightingEditSettings = false;
|
||||
public GaiaConstants.BakeMode m_lightingBakeMode = GaiaConstants.BakeMode.Realtime;
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
public LightingSettings.Lightmapper m_lightmappingMode = LightingSettings.Lightmapper.ProgressiveGPU;
|
||||
#else
|
||||
public LightmapEditorSettings.Lightmapper m_lightmappingMode = LightmapEditorSettings.Lightmapper.ProgressiveGPU;
|
||||
#endif
|
||||
#endif
|
||||
public Material m_masterSkyboxMaterial;
|
||||
public List<GaiaLightingProfileValues> m_lightingProfiles = new List<GaiaLightingProfileValues>();
|
||||
public bool m_parentObjects = true;
|
||||
public bool m_hideProcessVolume = true;
|
||||
public bool m_enablePostProcessing = true;
|
||||
public bool m_enableAmbientAudio = true;
|
||||
public bool m_enableFog = true;
|
||||
public GaiaConstants.GaiaProAntiAliasingMode m_antiAliasingMode = GaiaConstants.GaiaProAntiAliasingMode.TAA;
|
||||
public float m_AAJitterSpread = 0.55f;
|
||||
public float m_AAStationaryBlending = 0.95f;
|
||||
public float m_AAMotionBlending = 0.9f;
|
||||
public float m_AASharpness = 0.25f;
|
||||
public float m_antiAliasingTAAStrength = 0.7f;
|
||||
public bool m_cameraDithering = true;
|
||||
public float m_cameraAperture = 16f;
|
||||
public bool m_usePhysicalCamera = false;
|
||||
public Vector2 m_cameraSensorSize = new Vector2(70.41f, 52.63f);
|
||||
public float m_cameraFocalLength = 50f;
|
||||
public bool m_globalReflectionProbe = true;
|
||||
public bool m_isUserProfileSet = false;
|
||||
|
||||
//Auto DOF
|
||||
public bool m_enableAutoDOF = true;
|
||||
public LayerMask m_dofLayerDetection = 1;
|
||||
public float m_depthOfFieldFocusDistance = 50f;
|
||||
|
||||
//Light Probes
|
||||
public ReflectionProbeData m_reflectionProbeData = new ReflectionProbeData();
|
||||
|
||||
#endregion
|
||||
|
||||
#region SRP Lighting & Post FX
|
||||
|
||||
#if UPPipeline
|
||||
public VolumeProfile m_universalPostFXProfile;
|
||||
#endif
|
||||
|
||||
#if HDPipeline
|
||||
public VolumeProfile m_highDefinitionLightingProfile;
|
||||
public VolumeProfile m_highDefinitionPostFXProfile;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
#region Water
|
||||
|
||||
//Water
|
||||
public GaiaConstants.GlobalSystemMode m_waterSystemMode = GaiaConstants.GlobalSystemMode.Gaia;
|
||||
public GameObject m_thirdPartyWaterObject;
|
||||
public bool DefaultWaterSet = false;
|
||||
public bool m_waterMultiSceneLightingSupport = true;
|
||||
public bool m_waterRenamingProfile = false;
|
||||
public bool m_waterUpdateInRealtime = false;
|
||||
public bool m_allowMSAA = false;
|
||||
public bool m_useHDR = false;
|
||||
public bool m_enableDisabeHeightFeature = true;
|
||||
public float m_disableHeight = 100f;
|
||||
public string m_selectedProfile = "Deep Blue Ocean";
|
||||
public float m_interval = 0.25f;
|
||||
public bool m_useCustomRenderDistance = false;
|
||||
public bool m_enableLayerDistances = false;
|
||||
public float m_customRenderDistance = 500f;
|
||||
public float[] m_customRenderDistances = new float[32];
|
||||
public GaiaPlanarReflections.PlanarReflectionSettings m_reflectionSettingsData;
|
||||
public bool m_waterEditSettings = false;
|
||||
public int m_selectedWaterProfileValuesIndex;
|
||||
public bool m_autoRefresh = true;
|
||||
public bool m_ignoreSceneConditions = true;
|
||||
public float m_refreshRate = 0.5f;
|
||||
public GaiaConstants.WaterAutoUpdateMode m_autoUpdateMode = GaiaConstants.WaterAutoUpdateMode.Interval;
|
||||
|
||||
public bool m_useCastics = true;
|
||||
public Light m_mainCausticLight;
|
||||
public int m_causticFramePerSecond = 24;
|
||||
public float m_causticSize = 15f;
|
||||
|
||||
public bool InfiniteMode = true;
|
||||
public GameObject m_waterPrefab;
|
||||
public GameObject m_underwaterParticles;
|
||||
public GameObject m_underwaterHorizonPrefab;
|
||||
public GameObject m_hdPlanarReflections;
|
||||
public GameObject m_transitionFXPrefab;
|
||||
public List<GaiaWaterProfileValues> m_waterProfiles = new List<GaiaWaterProfileValues>();
|
||||
public Material m_activeWaterMaterial;
|
||||
|
||||
public bool m_enableWaterMeshQuality = false;
|
||||
public GaiaConstants.WaterMeshQuality m_waterMeshQuality = GaiaConstants.WaterMeshQuality.Medium;
|
||||
public GaiaConstants.MeshType m_meshType = GaiaConstants.MeshType.Plane;
|
||||
public int m_zSize = 1000;
|
||||
public int m_xSize = 1000;
|
||||
public int m_customMeshQuality = 100;
|
||||
|
||||
public bool m_enableReflections = true;
|
||||
public bool m_disaleSkyboxReflection = false;
|
||||
public bool m_disablePixelLights = true;
|
||||
public GaiaConstants.GaiaProWaterReflectionsQuality m_reflectionResolution = GaiaConstants.GaiaProWaterReflectionsQuality.Resolution512;
|
||||
public bool m_verifiedHDRPReflections = false;
|
||||
public int m_textureResolution = 512;
|
||||
public float m_clipPlaneOffset = 40f;
|
||||
public LayerMask m_reflectedLayers = 1;
|
||||
public float m_hdrpReflectionIntensity = 1f;
|
||||
|
||||
public bool m_enableOceanFoam = true;
|
||||
public bool m_enableBeachFoam = true;
|
||||
public bool m_enableGPUInstancing = true;
|
||||
public bool m_autoWindControlOnWater = true;
|
||||
|
||||
public bool m_supportUnderwaterEffects = true;
|
||||
public bool m_supportUnderwaterPostProcessing = true;
|
||||
public bool m_supportUnderwaterFog = true;
|
||||
public bool m_supportUnderwaterParticles = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Player
|
||||
|
||||
public GaiaConstants.EnvironmentControllerType m_controllerType = GaiaConstants.EnvironmentControllerType.FlyingCamera;
|
||||
public bool m_setupPostFX = true;
|
||||
public bool m_spawnPlayerAtCurrentLocation = true;
|
||||
public GameObject m_customPlayer;
|
||||
public Camera m_customCamera;
|
||||
|
||||
//Auto DOF
|
||||
|
||||
//Camera Culling
|
||||
public bool m_enableLayerCulling = true;
|
||||
[SerializeField]
|
||||
private GaiaSceneCullingProfile m_cullingProfile;
|
||||
public GaiaSceneCullingProfile CullingProfile {
|
||||
get
|
||||
{
|
||||
return m_cullingProfile;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_cullingProfile = value;
|
||||
RefreshCullingProfileLayers();
|
||||
}
|
||||
}
|
||||
|
||||
public Light m_sunLight;
|
||||
|
||||
//Terrain Culling
|
||||
public bool m_terrainCullingEnabled = true;
|
||||
|
||||
//Terrain Loading
|
||||
#if GAIA_PRO_PRESENT
|
||||
public LoadMode m_terrainLoaderLoadMode;
|
||||
public float m_terrainLoaderMinRefreshDistance;
|
||||
public float m_terrainLoaderMaxRefreshDistance;
|
||||
public float m_terrainLoaderMinRefreshMS;
|
||||
public float m_terrainLoaderMaxRefreshMS;
|
||||
public bool m_terrainLoaderFollowTransform;
|
||||
public BoundsDouble m_terrainLoaderLoadingBoundsRegular;
|
||||
public BoundsDouble m_terrainLoaderLoadingBoundsImpostor;
|
||||
public BoundsDouble m_terrainLoaderLoadingBoundsCollider;
|
||||
public bool m_terrainLoaderDataInitialized;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
#region Utils
|
||||
|
||||
private void RefreshCullingProfileLayers()
|
||||
{
|
||||
if (m_cullingProfile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool madeChanges = false;
|
||||
|
||||
float[] correctedDistances = new float[32];
|
||||
for (int i = 0; i < correctedDistances.Length; i++)
|
||||
{
|
||||
correctedDistances[i] = 0;
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
for (int targetIndex = 0; targetIndex < m_cullingProfile.m_layerNames.Length; targetIndex++)
|
||||
{
|
||||
if (m_cullingProfile.m_layerNames[targetIndex] == layerName)
|
||||
{
|
||||
correctedDistances[i] = m_cullingProfile.m_layerDistances[targetIndex];
|
||||
if (i != targetIndex)
|
||||
{
|
||||
madeChanges = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//only assign the corrected distance if there is an actual difference
|
||||
if (madeChanges)
|
||||
{
|
||||
m_cullingProfile.m_layerDistances = correctedDistances;
|
||||
}
|
||||
|
||||
bool madeShadowChanges = false;
|
||||
|
||||
float[] correctedShadowDistances = new float[32];
|
||||
for (int i = 0; i < correctedShadowDistances.Length; i++)
|
||||
{
|
||||
correctedShadowDistances[i] = 0;
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
for (int targetIndex = 0; targetIndex < m_cullingProfile.m_layerNames.Length; targetIndex++)
|
||||
{
|
||||
if (m_cullingProfile.m_layerNames[targetIndex] == layerName)
|
||||
{
|
||||
correctedShadowDistances[i] = m_cullingProfile.m_shadowLayerDistances[targetIndex];
|
||||
if (i != targetIndex)
|
||||
{
|
||||
madeShadowChanges = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//only assign the corrected shadow distance if there is an actual difference
|
||||
if (madeShadowChanges)
|
||||
{
|
||||
m_cullingProfile.m_shadowLayerDistances = correctedShadowDistances;
|
||||
}
|
||||
|
||||
bool madeLayerNameChanges = false;
|
||||
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
if (m_cullingProfile.m_layerNames[i] != LayerMask.LayerToName(i))
|
||||
{
|
||||
m_cullingProfile.m_layerNames[i] = LayerMask.LayerToName(i);
|
||||
madeLayerNameChanges = true;
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
if (madeChanges || madeShadowChanges || madeLayerNameChanges)
|
||||
{
|
||||
EditorUtility.SetDirty(m_cullingProfile);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if GAIA_PRO_PRESENT
|
||||
public void UpdateTerrainLoaderFromProfile(ref TerrainLoader tl)
|
||||
{
|
||||
if (GaiaUtils.HasDynamicLoadedTerrains())
|
||||
{
|
||||
if (tl != null)
|
||||
{
|
||||
tl.LoadMode = m_terrainLoaderLoadMode;
|
||||
tl.m_minRefreshDistance = m_terrainLoaderMinRefreshDistance;
|
||||
tl.m_maxRefreshDistance = m_terrainLoaderMaxRefreshDistance;
|
||||
tl.m_minRefreshMS = m_terrainLoaderMinRefreshMS;
|
||||
tl.m_maxRefreshMS = m_terrainLoaderMaxRefreshMS;
|
||||
tl.m_followTransform = m_terrainLoaderFollowTransform;
|
||||
tl.m_loadingBoundsRegular = m_terrainLoaderLoadingBoundsRegular;
|
||||
tl.m_loadingBoundsImpostor = m_terrainLoaderLoadingBoundsImpostor;
|
||||
tl.m_loadingBoundsCollider = m_terrainLoaderLoadingBoundsCollider;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61587e20dbbff7b4f8b950ee8040aea4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 0d9969fbfa47c174d91e2b1158223852, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user