Initial commit

This commit is contained in:
gunnbr committed 2021-01-11 22:20:43 -08:00
1 parent ee9615239e
commit 16feac691f
4093 files changed
+1030491

No files matched your search

@@ -0,0 +1,412 @@
using UnityEngine;
#if UNITY_POST_PROCESSING_STACK_V2
using UnityEngine.Rendering.PostProcessing;
using System;
#endif
#if HDPipeline
using UnityEngine.Rendering.HighDefinition;
#endif
using UnityEngine.Rendering;
namespace Gaia
{
/// <summary>
/// A script to handle auto focus for Gaia
/// </summary
public class AutoDepthOfField : MonoBehaviour
{
#region Variables
public bool m_interactWithPlayer = true;
public GaiaConstants.EnvironmentRenderer m_renderPipeLine = GaiaConstants.EnvironmentRenderer.BuiltIn;
public GaiaConstants.DOFTrackingType m_trackingType = GaiaConstants.DOFTrackingType.FollowScreen;
public float m_focusOffset = 0f;
public Camera m_sourceCamera;
public GameObject m_targetObject;
public LayerMask m_targetLayer = 3585;
public float m_maxFocusDistance = 100f;
public float m_actualFocusDistance = 1f;
public float m_dofAperture = 7.5f;
public float m_dofFocalLength = 30f;
public bool m_debug = false;
private bool m_maxDistanceExceeded = false;
private GameObject m_debugSphere;
#if UNITY_POST_PROCESSING_STACK_V2
private UnityEngine.Rendering.PostProcessing.DepthOfField m_dof;
#endif
/// <summary>
/// Our last hit point
/// </summary>
private Vector3 m_dofTrackingPoint = Vector3.negativeInfinity;
#endregion
#region Unity Function
/// <summary>
/// Get the main camera if it doesnt exist
/// </summary>
private void Start()
{
SetupAutoFocus();
GetCurrentDepthOfFieldSettings();
}
/// <summary>
/// Apply on disable
/// </summary>
private void OnDisable()
{
if (GaiaUtils.CheckIfSceneProfileExists())
{
GaiaGlobal.Instance.SceneProfile.m_depthOfFieldFocusDistance = m_actualFocusDistance;
}
SetEditorDepthOfFieldSettings();
}
private void OnDestroy()
{
SetEditorDepthOfFieldSettings();
SetDOFStatus(false);
}
/// <summary>
/// Process DOF update
/// </summary>
private void Update()
{
if (m_renderPipeLine != GaiaConstants.EnvironmentRenderer.BuiltIn)
{
return;
}
#if UNITY_POST_PROCESSING_STACK_V2
if (m_sourceCamera == null || m_dof == null)
{
return;
}
#endif
//Update the focus target
UpdateDofTrackingPoint();
}
#endregion
#region Depth Of Field Functions
public void SetDOFMainSettings(float aperture, float focalLength)
{
#if UNITY_POST_PROCESSING_STACK_V2
if (m_dof == null)
{
GetDepthOfFieldComponent();
}
m_dof.aperture.value = aperture;
m_dof.focalLength.value = focalLength;
#endif
}
/// <summary>
/// Do a raycast to update the focus target
/// </summary>
private void UpdateDofTrackingPoint()
{
switch (m_trackingType)
{
case GaiaConstants.DOFTrackingType.LeftMouseClick:
{
if (Input.GetMouseButton(0))
{
Ray ray = m_sourceCamera.ScreenPointToRay(Input.mousePosition);
FocusOnRayCast(ray);
}
break;
}
case GaiaConstants.DOFTrackingType.RightMouseClick:
{
if (Input.GetMouseButton(1))
{
Ray ray = m_sourceCamera.ScreenPointToRay(Input.mousePosition);
FocusOnRayCast(ray);
}
break;
}
case GaiaConstants.DOFTrackingType.FollowScreen:
{
Ray ray = new Ray(m_sourceCamera.transform.position, m_sourceCamera.transform.forward);
FocusOnRayCast(ray);
break;
}
case GaiaConstants.DOFTrackingType.FollowTarget:
{
m_dofTrackingPoint = m_targetObject.transform.position;
break;
}
case GaiaConstants.DOFTrackingType.FixedOffset:
{
if (m_debug)
{
m_debug = false;
Debug.Log("Debug mode is not available in Fixed Offset Tracking Mode. We have turned off Debug Mode for you.");
}
#if UNITY_POST_PROCESSING_STACK_V2
m_dof.focusDistance.value = m_focusOffset;
#endif
break;
}
}
if (m_debug)
{
if (!Vector3.Equals(m_dofTrackingPoint,Vector3.negativeInfinity) && (m_debugSphere == null || m_debugSphere.transform.position != m_dofTrackingPoint))
{
if (m_debugSphere != null)
{
Destroy(m_debugSphere);
}
m_debugSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
Destroy(m_debugSphere.GetComponent<Collider>());
m_debugSphere.transform.position = m_dofTrackingPoint;
m_debugSphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
}
}
#if UNITY_POST_PROCESSING_STACK_V2
if (m_trackingType != GaiaConstants.DOFTrackingType.FixedOffset)
{
SetNewDOFValue(m_dof.focusDistance.value);
}
m_actualFocusDistance = m_dof.focusDistance.value;
#endif
if (GaiaUtils.CheckIfSceneProfileExists())
{
GaiaGlobal.Instance.SceneProfile.m_depthOfFieldFocusDistance = m_actualFocusDistance;
}
}
private void FocusOnRayCast(Ray ray)
{
if (Physics.Raycast(ray, out var hit, m_maxFocusDistance, m_targetLayer))
{
if (m_debug)
{
Debug.Log("Auto DOF Ray collided with: " + hit.collider.name);
}
if (m_interactWithPlayer)
{
if (hit.transform.gameObject.tag != "Player")
{
m_maxDistanceExceeded = false;
m_dofTrackingPoint = hit.point;
}
else
{
m_maxDistanceExceeded = true;
}
}
else
{
m_maxDistanceExceeded = false;
m_dofTrackingPoint = hit.point;
}
}
else
{
m_maxDistanceExceeded = true;
}
}
public void RemoveDebugSphere()
{
if (m_debugSphere != null)
{
DestroyImmediate(m_debugSphere);
}
}
private void SetNewDOFValue(float startValue, float timeMultiplier = 3.5f)
{
if (m_sourceCamera == null)
{
return;
}
#if UNITY_POST_PROCESSING_STACK_V2
if (m_dof == null)
{
GetDepthOfFieldComponent();
}
else
{
if (m_maxDistanceExceeded)
{
m_dof.focusDistance.value = m_maxFocusDistance;
}
else
{
m_dof.focusDistance.value = Mathf.Lerp(startValue, Vector3.Distance(m_sourceCamera.transform.position ,m_dofTrackingPoint) + m_focusOffset, Time.deltaTime * timeMultiplier);
}
}
#endif
}
/// <summary>
/// Setup autofocus object
/// </summary>
public void SetupAutoFocus()
{
m_renderPipeLine = GaiaUtils.GetActivePipeline();
if (m_dofTrackingPoint.x > 0)
{
//Removes warning
}
if (m_maxDistanceExceeded)
{
//Removes warning
}
//Set up main camera
if (m_sourceCamera == null)
{
m_sourceCamera = GaiaUtils.GetCamera();
if (m_sourceCamera == null)
{
Debug.Log("DOF Autofocus exiting, unable to find main camera!");
enabled = false;
return;
}
}
//Determine tracking type
if (m_trackingType == GaiaConstants.DOFTrackingType.FollowTarget && m_targetObject == null)
{
Debug.Log("Tracking target is missing, falling back to follow screen!");
m_trackingType = GaiaConstants.DOFTrackingType.FollowScreen;
}
#if UNITY_POST_PROCESSING_STACK_V2
//Gets DOF component
if (m_dof == null)
{
GetDepthOfFieldComponent();
}
if (m_dof != null)
{
m_dof.focusDistance.value = m_maxFocusDistance;
}
#endif
}
private void GetDepthOfFieldComponent()
{
if (m_renderPipeLine != GaiaConstants.EnvironmentRenderer.BuiltIn)
{
return;
}
#if UNITY_POST_PROCESSING_STACK_V2
//Find our DOF component
if (m_dof == null)
{
GameObject ppObj = GameObject.Find("Global Post Processing");
if (ppObj == null)
{
Debug.Log("DOF Autofocus exiting, unable to global post processing object!");
enabled = false;
return;
}
PostProcessVolume ppVolume = ppObj.GetComponent<PostProcessVolume>();
{
if (ppVolume == null)
{
Debug.Log("DOF Autofocus exiting, unable to global post processing volume!");
enabled = false;
return;
}
}
PostProcessProfile ppProfile = ppVolume.sharedProfile;
if (ppProfile == null)
{
Debug.Log("DOF Autofocus exiting, unable to global post processing profile!");
enabled = false;
return;
}
if (!ppProfile.HasSettings<UnityEngine.Rendering.PostProcessing.DepthOfField>())
{
Debug.Log("DOF Autofocus exiting, unable to find dof settings!");
enabled = false;
return;
}
if (!ppProfile.TryGetSettings<UnityEngine.Rendering.PostProcessing.DepthOfField>(out m_dof))
{
Debug.Log("DOF Autofocus exiting, unable to find dof settings!");
m_dof = null;
enabled = false;
}
}
if (m_dof != null)
{
m_dof.active = true;
m_dof.enabled.value = true;
m_dof.focusDistance.overrideState = true;
m_maxDistanceExceeded = true;
}
#endif
}
/// <summary>
/// Sets the focus distance on the DOF component based on camera distance divided by 4
/// </summary>
/// <param name="enabled"></param>
public void SetDOFStatus(bool enabled)
{
if (!enabled)
{
#if UNITY_POST_PROCESSING_STACK_V2
if (m_dof != null && m_sourceCamera != null)
{
m_dof.focusDistance.value = m_sourceCamera.farClipPlane / 4f;
}
#endif
}
}
/// <summary>
/// Grabs the DOF aperture and focal length and updates the systems values to use these
/// </summary>
public void GetCurrentDepthOfFieldSettings()
{
#if UNITY_POST_PROCESSING_STACK_V2
if (m_dof != null)
{
m_dofAperture = m_dof.aperture.value;
m_dofFocalLength = m_dof.focalLength.value;
}
#endif
}
/// <summary>
/// Sets the depth of field focus distance to 100 if it's less than 20
/// This should remove a blury game view when not in play mode
/// </summary>
private void SetEditorDepthOfFieldSettings()
{
#if UNITY_POST_PROCESSING_STACK_V2
if (m_dof == null)
{
return;
}
if (m_dof.focusDistance.value < 20f)
{
m_dof.focusDistance.value = 100f;
}
#endif
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ded16ed81af5a3c46a67ce93019ada2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5510c63647361324da3cfbb09ec81dc7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
using UnityEditor;
namespace Gaia
{
[CustomEditor(typeof(AutoDepthOfField))]
public class AutoDepthOfFieldEditor : Editor
{
public override void OnInspectorGUI()
{
if (GaiaUtils.GetActivePipeline() == GaiaConstants.EnvironmentRenderer.BuiltIn)
{
EditorGUILayout.HelpBox("This is the auto depth of field system for Gaia. To edit or remove please go to Gaia Player under Gaia Runtime", MessageType.Info);
}
else
{
EditorGUILayout.HelpBox("Auto Depth Of Field is not yet supported for SRP this will be available in a near future update", MessageType.Info);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 69c4fa61a8f625f4c8fafbb2fe2e663a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,446 @@
using UnityEngine;
using UnityEditor;
using Gaia.Internal;
using PWCommon4;
using System.Collections.Generic;
using UnityEditor.SceneManagement;
namespace Gaia
{
public class LoadUpSceneSettings
{
public static void UpdateSceneSettingsFromProfile()
{
GaiaSettings GaiaSettings = GaiaUtils.GetGaiaSettings();
if (GaiaSettings != null)
{
LoadWaterAndLighting(GaiaSettings);
}
}
private static void LoadWaterAndLighting(GaiaSettings settings, bool showDebug = false)
{
if (settings == null)
{
Debug.LogError("Gaia settings was not found.");
return;
}
if (settings.m_gaiaWaterProfile == null)
{
Debug.LogError("Water Profile was not found!");
return;
}
else
{
Material waterMat = GaiaWater.GetGaiaOceanMaterial();
if (waterMat != null)
{
GameObject waterObject = GameObject.Find(GaiaConstants.waterSurfaceObject);
if (waterObject != null)
{
GaiaUtils.GetRuntimeSceneObject();
if (GaiaGlobal.Instance != null)
{
GaiaWater.GetProfile(GaiaGlobal.Instance.SceneProfile.m_selectedWaterProfileValuesIndex, waterMat, GaiaGlobal.Instance.SceneProfile, true, false);
}
}
}
}
if (settings.m_gaiaLightingProfile == null)
{
Debug.LogError("Lighting Profile was not found!");
return;
}
else
{
GameObject lightObject = GameObject.Find(GaiaConstants.gaiaLightingObject);
if (lightObject != null)
{
if (GaiaGlobal.Instance != null)
{
GaiaUtils.GetRuntimeSceneObject();
GaiaLighting.GetProfile(GaiaGlobal.Instance.SceneProfile, settings.m_pipelineProfile, settings.m_pipelineProfile.m_activePipelineInstalled);
}
}
}
if (showDebug)
{
Debug.Log("Loading up profile settings successfully");
}
}
}
[CustomEditor(typeof(GaiaGlobal))]
public class GaiaGlobalEditor : PWEditor
{
private EditorUtils m_editorUtils;
private GaiaSettings m_gaiaSettings;
private GaiaGlobal m_profile;
private GUIStyle dropdownGUIStyle;
private void OnEnable()
{
//Get Gaia Lighting Profile object
m_profile = (GaiaGlobal)target;
if (m_editorUtils == null)
{
// Get editor utils for this
m_editorUtils = PWApp.GetEditorUtils(this);
}
if (m_gaiaSettings == null)
{
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
}
if (m_profile.SceneProfile == null)
{
m_profile.SceneProfile = ScriptableObject.CreateInstance<SceneProfile>();
}
if (m_profile.SceneProfile.m_selectedLightingProfileValuesIndex > m_profile.SceneProfile.m_lightingProfiles.Count - 1)
{
m_profile.SceneProfile.m_selectedLightingProfileValuesIndex = 1;
}
if (m_profile.SceneProfile.m_selectedWaterProfileValuesIndex > m_profile.SceneProfile.m_waterProfiles.Count - 1)
{
m_profile.SceneProfile.m_selectedWaterProfileValuesIndex = 1;
}
m_profile.SceneProfile.ProfileVersion = PWApp.CONF.Version;
#if GAIA_PRO_PRESENT
if (ProceduralWorldsGlobalWeather.Instance != null)
{
LoadSettings();
}
#endif
if (dropdownGUIStyle == null)
{
dropdownGUIStyle = new GUIStyle(EditorStyles.popup)
{
fixedHeight = 16f, margin = new RectOffset(0, 0, 4, 0)
};
}
if (m_profile.SceneProfile.m_lightingProfiles.Count > 0)
{
if (m_profile.SceneProfile.m_selectedLightingProfileValuesIndex != -99)
{
GaiaLightingProfileValues profileValues = m_profile.SceneProfile.m_lightingProfiles[m_profile.SceneProfile.m_selectedLightingProfileValuesIndex];
GaiaSceneManagement.FetchSceneSettigns(m_profile.SceneProfile, profileValues);
}
}
}
/// <summary>
/// Setup on destroy
/// </summary>
private void OnDestroy()
{
if (m_editorUtils != null)
{
m_editorUtils.Dispose();
}
}
public override void OnInspectorGUI()
{
if (dropdownGUIStyle == null)
{
dropdownGUIStyle = new GUIStyle(EditorStyles.popup)
{
fixedHeight = 16f, margin = new RectOffset(0, 0, 4, 0)
};
}
if (m_profile != null)
{
Transform transform = m_profile.gameObject.transform;
transform.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable;
if (m_profile.m_mainCamera == null)
{
m_profile.m_mainCamera = GaiaUtils.GetCamera();
}
}
//Initialization
m_editorUtils.Initialize(); // Do not remove this!
if (m_gaiaSettings == null)
{
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
}
m_editorUtils.Panel("GlobalSettings", GlobalSettingsPanel, false, true, true);
}
private void GlobalSettingsPanel(bool helpEnabled)
{
if (Application.isPlaying)
{
LoadFromApplicationPlaying();
}
m_editorUtils.Text("GaiaRuntimeInfo");
EditorGUILayout.Space();
m_profile.m_mainCamera = (Camera)m_editorUtils.ObjectField("MainCamera", m_profile.m_mainCamera, typeof(Camera), true, helpEnabled);
if (m_profile.SceneProfile != null)
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
m_profile.SceneProfile.m_lightSystemMode = (GaiaConstants.GlobalSystemMode)m_editorUtils.EnumPopup("LightingSystemMode", m_profile.SceneProfile.m_lightSystemMode);
if (m_profile.SceneProfile.m_lightSystemMode == GaiaConstants.GlobalSystemMode.Gaia)
{
if (m_profile.SceneProfile.m_lightingProfiles.Count > 0)
{
if (m_editorUtils.Button("AdvancedLightingSettings", GUILayout.MaxWidth(170f)))
{
GaiaLighting.FocusGaiaLightingProfile();
}
}
}
else if (m_profile.SceneProfile.m_lightSystemMode == GaiaConstants.GlobalSystemMode.ThirdParty)
{
if (m_editorUtils.Button("AdvancedLightingSettings", GUILayout.MaxWidth(170f)))
{
GaiaLighting.FocusGaiaLightingProfile();
}
/*if (m_profile.SceneProfile.m_thirdPartyLightObject != null)
{
if (m_editorUtils.Button("EditThirdParty", GUILayout.MaxWidth(170f)))
{
Selection.activeObject = m_profile.SceneProfile.m_thirdPartyLightObject;
}
}
else
{
if (m_editorUtils.Button("AdvancedLightingSettings", GUILayout.MaxWidth(170f)))
{
GaiaLighting.FocusGaiaLightingProfile();
}
}*/
}
EditorGUILayout.EndHorizontal();
m_editorUtils.InlineHelp("LightingSystemMode", helpEnabled);
if (m_profile.SceneProfile.m_lightSystemMode == GaiaConstants.GlobalSystemMode.Gaia)
{
if (m_profile.SceneProfile.m_lightingProfiles.Count < 1)
{
EditorGUILayout.HelpBox("No lighting data has been set you can go to Gaia Manager and click step 2 to create skies and water or you can go to Save and Load and click Revert To Defaults to load the skies and water data.", MessageType.Info);
}
}
else if (m_profile.SceneProfile.m_lightSystemMode == GaiaConstants.GlobalSystemMode.ThirdParty)
{
if (m_profile.SceneProfile.m_thirdPartyLightObject == null)
{
EditorGUILayout.HelpBox("No Lighting System has been set, open 'Advanced Lighting Settings' to setup", MessageType.Info);
}
}
else
{
EditorGUILayout.HelpBox("Lighting System Mode is set to 'None' to use light set the mode to 'Gaia or ThirdParty'", MessageType.Info);
}
EditorGUILayout.BeginHorizontal();
m_profile.SceneProfile.m_waterSystemMode = (GaiaConstants.GlobalSystemMode)m_editorUtils.EnumPopup("WaterSystemMode", m_profile.SceneProfile.m_waterSystemMode);
if (m_profile.SceneProfile.m_waterSystemMode == GaiaConstants.GlobalSystemMode.Gaia)
{
if (m_profile.SceneProfile.m_waterProfiles.Count > 0)
{
if (m_editorUtils.Button("AdvancedWaterSettings", GUILayout.MaxWidth(170f)))
{
GaiaUtils.FocusWaterProfile();
}
}
}
else if (m_profile.SceneProfile.m_waterSystemMode == GaiaConstants.GlobalSystemMode.ThirdParty)
{
if (m_editorUtils.Button("AdvancedWaterSettings", GUILayout.MaxWidth(170f)))
{
GaiaUtils.FocusWaterProfile();
}
/*if (m_profile.SceneProfile.m_thirdPartyWaterObject != null)
{
if (m_editorUtils.Button("EditThirdParty", GUILayout.MaxWidth(170f)))
{
Selection.activeObject = m_profile.SceneProfile.m_thirdPartyLightObject;
}
}
else
{
if (m_editorUtils.Button("AdvancedWaterSettings", GUILayout.MaxWidth(170f)))
{
GaiaUtils.FocusWaterProfile();
}
}*/
}
EditorGUILayout.EndHorizontal();
m_editorUtils.InlineHelp("WaterSystemMode", helpEnabled);
if (m_profile.SceneProfile.m_waterSystemMode == GaiaConstants.GlobalSystemMode.Gaia)
{
if (m_profile.SceneProfile.m_lightingProfiles.Count < 1)
{
EditorGUILayout.HelpBox("No lighting data has been set you can go to Gaia Manager and click step 2 to create skies and water or you can go to Save and Load and click Revert To Defaults to load the skies and water data.", MessageType.Info);
}
}
else if (m_profile.SceneProfile.m_waterSystemMode == GaiaConstants.GlobalSystemMode.ThirdParty)
{
if (m_profile.SceneProfile.m_thirdPartyWaterObject == null)
{
EditorGUILayout.HelpBox("No Water System has been set, open 'Advanced Water Settings' to setup", MessageType.Info);
}
}
else
{
EditorGUILayout.HelpBox("Water System Mode is set to 'None' to use light set the mode to 'Gaia or ThirdParty'", MessageType.Info);
}
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(m_profile);
Undo.RecordObject(m_profile, "Changes Made");
m_profile.UpdateGaiaTimeOfDay(false);
m_profile.UpdateGaiaWeather();
}
m_editorUtils.Panel("SaveAndLoad", SaveAndLoad);
}
}
private void SaveAndLoad(bool helpEnabled)
{
EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("SaveAndLoadHelpText"), MessageType.Info);
if (m_profile.SceneProfile == null)
{
m_profile.SceneProfile = ScriptableObject.CreateInstance<SceneProfile>();
}
bool canBeSaved = true;
if (!m_profile.SceneProfile.DefaultLightingSet)
{
EditorGUILayout.HelpBox("No lighting profile settings have been saved. Please use gaia default lighting profile to save them here.", MessageType.Warning);
canBeSaved = false;
}
else
{
//EditorGUILayout.HelpBox("Lighting profile has been saved", MessageType.Info);
}
if (!m_profile.SceneProfile.DefaultWaterSet)
{
EditorGUILayout.HelpBox("No water profile settings have been saved. Please use gaia default water profile to save them here.", MessageType.Warning);
canBeSaved = false;
}
else
{
//EditorGUILayout.HelpBox("Water profile has been saved", MessageType.Info);
}
EditorGUILayout.BeginHorizontal();
if (!canBeSaved)
{
GUI.enabled = false;
}
//string path = Application.dataPath + "/Assets";
string path = "";
if (m_editorUtils.Button("Save"))
{
string sceneName = EditorSceneManager.GetActiveScene().name;
if (string.IsNullOrEmpty(sceneName))
{
Debug.LogWarning("Unable to save file as scene has not been saved. Please save your scene then try again.");
}
path = EditorUtility.SaveFilePanelInProject("Save Location", sceneName + " Profile", "asset" , "Save new profile asset");
GaiaSceneManagement.SaveFile(m_profile.SceneProfile, path);
EditorGUIUtility.ExitGUI();
}
GUI.enabled = true;
if (m_editorUtils.Button("Load"))
{
path = EditorUtility.OpenFilePanel("Load Profile", Application.dataPath + "/Assets", "asset");
GaiaSceneManagement.LoadFile(path);
EditorGUIUtility.ExitGUI();
}
if (m_editorUtils.Button("Revert"))
{
GaiaSceneManagement.Revert(m_profile.SceneProfile);
EditorGUIUtility.ExitGUI();
}
EditorGUILayout.EndHorizontal();
}
private void LoadSettings()
{
#if GAIA_PRO_PRESENT
if (ProceduralWorldsGlobalWeather.Instance != null)
{
//Weather
m_profile.SceneProfile.m_gaiaWeather.m_season = ProceduralWorldsGlobalWeather.Instance.Season;
m_profile.SceneProfile.m_gaiaWeather.m_windDirection = ProceduralWorldsGlobalWeather.Instance.WindDirection;
}
#endif
}
private void LoadFromApplicationPlaying()
{
#if GAIA_PRO_PRESENT
if (ProceduralWorldsGlobalWeather.Instance != null)
{
//Weather
m_profile.SceneProfile.m_gaiaWeather.m_season = ProceduralWorldsGlobalWeather.Instance.Season;
m_profile.SceneProfile.m_gaiaWeather.m_windDirection = ProceduralWorldsGlobalWeather.Instance.WindDirection;
}
#endif
}
private void UpdateLighting(bool process, bool applyProfile = false)
{
if (process)
{
if (GaiaGlobal.Instance != null)
{
GaiaUtils.GetRuntimeSceneObject();
GaiaLighting.GetProfile(GaiaGlobal.Instance.SceneProfile, m_gaiaSettings.m_pipelineProfile, m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled, applyProfile);
}
EditorUtility.SetDirty(m_profile.SceneProfile);
}
}
private void UpdateWater(bool process)
{
if (process)
{
if (m_profile.WaterMaterial == null)
{
m_profile.WaterMaterial = GaiaWater.GetGaiaOceanMaterial();
}
GaiaUtils.GetRuntimeSceneObject();
if (GaiaGlobal.Instance != null)
{
GaiaWater.GetProfile(m_profile.SceneProfile.m_selectedWaterProfileValuesIndex, m_profile.WaterMaterial, GaiaGlobal.Instance.SceneProfile, true, false);
}
EditorUtility.SetDirty(m_profile.SceneProfile);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c7e5bb095c1a412438ff794a4b44b73b
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: bf6cf8541d291e04a9c8a4b3fe7f427c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,703 @@
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
using Gaia.Internal;
using PWCommon4;
using System.Linq;
using System.Collections.Generic;
#if UNITY_POST_PROCESSING_STACK_V2
using UnityEngine.Rendering.PostProcessing;
#endif
namespace Gaia
{
[CustomEditor(typeof(GaiaLightingProfile))]
public class GaiaLightingProfileEditor : PWEditor
{
private EditorUtils m_editorUtils;
private string m_version;
private Color defaultBackground;
private GaiaSettings m_gaiaSettings;
private GaiaLightingProfile m_profile;
private GaiaLightingProfileValues m_profileValues;
private GaiaConstants.EnvironmentRenderer m_renderPipeline;
private bool enableEditMode;
public void OnEnable()
{
//Get Gaia Lighting Profile object
m_profile = (GaiaLightingProfile)target;
if (m_editorUtils == null)
{
// Get editor utils for this
m_editorUtils = PWApp.GetEditorUtils(this);
}
if (m_gaiaSettings == null)
{
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
}
m_renderPipeline = m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled;
m_version = PWApp.CONF.Version;
if (m_profile != null)
{
m_profileValues = m_profile.m_lightingProfiles[m_profile.m_selectedLightingProfileValuesIndex];
}
enableEditMode = System.IO.Directory.Exists(GaiaUtils.GetAssetPath("Dev Utilities"));
}
public override void OnInspectorGUI()
{
//Initialization
m_editorUtils.Initialize(); // Do not remove this!
//Monitor for changes
EditorGUI.BeginChangeCheck();
defaultBackground = GUI.backgroundColor;
if (m_gaiaSettings == null)
{
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
}
if (m_renderPipeline != m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled)
{
m_renderPipeline = m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled;
}
if (m_profile.m_selectedLightingProfileValuesIndex > m_profile.m_lightingProfiles.Count - 1)
{
m_profile.m_selectedLightingProfileValuesIndex = 0;
}
EditorGUILayout.LabelField("Profile Version: " + m_version);
if (enableEditMode)
{
m_profile.m_editSettings = EditorGUILayout.ToggleLeft("Use Procedural Worlds Editor Settings", m_profile.m_editSettings);
}
else
{
m_profile.m_editSettings = false;
}
if (m_profile.m_editSettings)
{
m_editorUtils.Panel("UpdateSettings", RealtimeUpdateEnabled);
m_editorUtils.Panel("GlobalSettings", GlobalSettingsEnabled);
m_editorUtils.Panel("LightingProfileSettings", LightingProfileSettingsEnabled);
DrawDefaultInspector();
}
//Check for changes, make undo record, make changes and let editor know we are dirty
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(m_profile, "Made changes");
EditorUtility.SetDirty(m_profile);
if (m_profile.m_updateInRealtime)
{
if (m_profile.m_selectedLightingProfileValuesIndex != -99)
{
GaiaUtils.GetRuntimeSceneObject();
if (GaiaGlobal.Instance != null)
{
//GaiaLighting.GetProfile(m_profile, m_gaiaSettings.m_pipelineProfile, m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled);
}
}
EditorUtility.SetDirty(m_profile);
}
}
}
private void RealtimeUpdateEnabled(bool helpEnabled)
{
m_profile.m_updateInRealtime = m_editorUtils.ToggleLeft("UpdateChangesInRealtime", m_profile.m_updateInRealtime, helpEnabled);
if (m_profile.m_updateInRealtime)
{
EditorGUILayout.HelpBox("Update In Realtime is enabled this will allow profiles to be endited inside the editor and automatically apply changes every frame. This feature can be expensive and should not be left enabled in testing and builds", MessageType.Warning);
}
else
{
if (m_editorUtils.Button("UpdateToScene"))
{
if (m_profile.m_selectedLightingProfileValuesIndex != -99)
{
GaiaUtils.GetRuntimeSceneObject();
if (GaiaGlobal.Instance != null)
{
//GaiaLighting.GetProfile(m_profile, m_gaiaSettings.m_pipelineProfile, m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled);
EditorUtility.SetDirty(m_profile);
}
}
}
m_editorUtils.InlineHelp("UpdateToScene", helpEnabled);
if (m_editorUtils.Button("UpdateDynamicGI"))
{
GaiaLighting.UpdateAmbientEnvironment();
}
m_editorUtils.InlineHelp("UpdateDynamicGI", helpEnabled);
}
}
private void GlobalSettingsEnabled(bool helpEnabled)
{
if (PlayerSettings.colorSpace != ColorSpace.Linear)
{
GUI.backgroundColor = Color.yellow;
EditorGUILayout.HelpBox("Gaia lighting looks best in Linear Color Space. Go to Gaia standard tab and press Set Linear Deferred", MessageType.Warning);
}
GUI.backgroundColor = defaultBackground;
m_editorUtils.Heading("SetupSettings");
m_profile.m_multiSceneLightingSupport = m_editorUtils.Toggle("MultiSceneSupport", m_profile.m_multiSceneLightingSupport, helpEnabled);
if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition)
{
m_profile.m_masterSkyboxMaterial = (Material)m_editorUtils.ObjectField("MasterSkyboxMaterial", m_profile.m_masterSkyboxMaterial, typeof(Material), false, GUILayout.Height(16f));
}
EditorGUILayout.Space();
m_editorUtils.Heading("LightmappingSettings");
m_profile.m_lightingBakeMode = (GaiaConstants.BakeMode)m_editorUtils.EnumPopup("LightmappingBakeMode", m_profile.m_lightingBakeMode, helpEnabled);
#if UNITY_2020_1_OR_NEWER
m_profile.m_lightmappingMode = (LightingSettings.Lightmapper)EditorGUILayout.EnumPopup("Lightmapping Mode", m_profile.m_lightmappingMode);
#else
m_profile.m_lightmappingMode = (LightmapEditorSettings.Lightmapper)EditorGUILayout.EnumPopup("Lightmapping Mode", m_profile.m_lightmappingMode);
#endif
EditorGUILayout.Space();
m_editorUtils.Heading("PostProcessingSettings");
m_profile.m_enablePostProcessing = m_editorUtils.ToggleLeft("EnablePostProcessing", m_profile.m_enablePostProcessing);
if (m_profile.m_enablePostProcessing)
{
m_profile.m_hideProcessVolume = m_editorUtils.ToggleLeft("HidePostProcessingVolumesInScene", m_profile.m_hideProcessVolume);
m_profile.m_antiAliasingMode = (GaiaConstants.GaiaProAntiAliasingMode)EditorGUILayout.EnumPopup("Anti-Aliasing Mode", m_profile.m_antiAliasingMode);
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.BuiltIn)
{
if (m_profile.m_antiAliasingMode == GaiaConstants.GaiaProAntiAliasingMode.TAA)
{
m_profile.m_AAJitterSpread = m_editorUtils.Slider("AAJitterSpread", m_profile.m_AAJitterSpread, 0f, 1f, helpEnabled);
m_profile.m_AAStationaryBlending = m_editorUtils.Slider("AAStationaryBlending", m_profile.m_AAStationaryBlending, 0f, 1f, helpEnabled);
m_profile.m_AAMotionBlending = m_editorUtils.Slider("AAMotionBlending", m_profile.m_AAMotionBlending, 0f, 1f, helpEnabled);
m_profile.m_AASharpness = m_editorUtils.Slider("AASharpness", m_profile.m_AASharpness, 0f, 1f, helpEnabled);
}
}
}
EditorGUILayout.Space();
m_editorUtils.Heading("CameraSettings");
m_profile.m_enableAutoDOF = m_editorUtils.Toggle("UseAutoDOF", m_profile.m_enableAutoDOF, helpEnabled);
if (m_profile.m_enableAutoDOF)
{
m_profile.m_dofLayerDetection = GaiaEditorUtils.LayerMaskField(new GUIContent(m_editorUtils.GetTextValue("DOFLayerDetection"), m_editorUtils.GetTooltip("DOFLayerDetection")), m_profile.m_dofLayerDetection);
}
EditorGUILayout.Space();
m_profile.m_usePhysicalCamera = m_editorUtils.Toggle("UsePhysicalCamera", m_profile.m_usePhysicalCamera, helpEnabled);
if (m_profile.m_usePhysicalCamera)
{
m_profile.m_cameraFocalLength = m_editorUtils.FloatField("CameraFocalLength", m_profile.m_cameraFocalLength, helpEnabled);
m_profile.m_cameraSensorSize = m_editorUtils.Vector2Field("CameraSensorSize", m_profile.m_cameraSensorSize, helpEnabled);
}
EditorGUILayout.Space();
m_editorUtils.Heading("MiscellaneousSettings");
m_profile.m_globalReflectionProbe = m_editorUtils.ToggleLeft("GlobalReflectionProbe", m_profile.m_globalReflectionProbe);
m_profile.m_parentObjects = m_editorUtils.ToggleLeft("ParentObjectsToGaia", m_profile.m_parentObjects);
m_profile.m_enableAmbientAudio = m_editorUtils.ToggleLeft("EnableAmbientAudio", m_profile.m_enableAmbientAudio);
if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition)
{
m_profile.m_enableFog = m_editorUtils.ToggleLeft("EnableFog", m_profile.m_enableFog);
}
else
{
#if UNITY_2019_3_OR_NEWER
EditorGUILayout.Space();
m_editorUtils.Heading("HDRPSettings");
if (m_profile.m_antiAliasingMode == GaiaConstants.GaiaProAntiAliasingMode.TAA)
{
m_profile.m_antiAliasingTAAStrength = m_editorUtils.Slider("TAAStrength", m_profile.m_antiAliasingTAAStrength, 0f, 2f, helpEnabled);
}
m_profile.m_cameraDithering = m_editorUtils.Toggle("CameraDithering", m_profile.m_cameraDithering, helpEnabled);
m_profile.m_cameraAperture = m_editorUtils.Slider("CameraAperture", m_profile.m_cameraAperture, 1f, 32f, helpEnabled);
#endif
}
}
private void LightingProfileSettingsEnabled(bool helpEnabled)
{
//Building up a value array of incrementing ints of the size of the lighting profile values array, this array will then match the displayed string selection in the popup
int[] lightingProfileValuesIndices = Enumerable
.Repeat(0, (int)((m_profile.m_lightingProfiles.Count - 1) / 1) + 1)
.Select((tr, ti) => tr + (1 * ti))
.ToArray();
string[] profileNames = m_profile.m_lightingProfiles.Select(x => x.m_typeOfLighting).ToArray();
//Injecting the "None" option
lightingProfileValuesIndices = GaiaUtils.AddElementToArray(lightingProfileValuesIndices, -99);
profileNames = GaiaUtils.AddElementToArray(profileNames, "None");
EditorGUILayout.BeginHorizontal();
if (m_profile.m_renamingProfile)
{
m_profileValues.m_profileRename = m_editorUtils.TextField("NewProfileName", m_profileValues.m_profileRename);
}
else
{
m_profile.m_selectedLightingProfileValuesIndex = EditorGUILayout.IntPopup("Lighting Profile", m_profile.m_selectedLightingProfileValuesIndex, profileNames, lightingProfileValuesIndices);
}
#if !GAIA_PRO_PRESENT
bool currentGUIState = GUI.enabled;
if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
GUI.enabled = false;
}
#endif
if (m_profile.m_selectedLightingProfileValuesIndex != -99)
{
m_profileValues = m_profile.m_lightingProfiles[m_profile.m_selectedLightingProfileValuesIndex];
m_profileValues.m_ambientMode = RenderSettings.ambientMode;
}
if (m_profileValues.m_userCustomProfile)
{
if (m_profile.m_renamingProfile)
{
if (m_editorUtils.Button("Save", GUILayout.MaxWidth(55f)))
{
m_profileValues.m_typeOfLighting = m_profileValues.m_profileRename;
m_profile.m_renamingProfile = false;
}
}
else
{
if (m_editorUtils.Button("Rename", GUILayout.MaxWidth(55f)))
{
m_profile.m_renamingProfile = true;
m_profileValues.m_profileRename = m_profileValues.m_typeOfLighting;
}
}
if (m_editorUtils.Button("Remove", GUILayout.MaxWidth(30f)))
{
m_profile.m_renamingProfile = false;
m_profile.m_lightingProfiles.RemoveAt(m_profile.m_selectedLightingProfileValuesIndex);
m_profile.m_selectedLightingProfileValuesIndex--;
}
}
if (m_editorUtils.Button("MakeCopy", GUILayout.MaxWidth(30f)))
{
AddNewCustomProfile();
}
EditorGUILayout.EndHorizontal();
if (m_profile.m_selectedLightingProfileValuesIndex == -99)
{
EditorGUILayout.HelpBox("No Profile selected. Select another profile that is not 'None' to view settings to edit", MessageType.Info);
}
else
{
if (!m_profileValues.m_userCustomProfile)
{
m_profile.m_renamingProfile = false;
EditorGUILayout.HelpBox("This is one of the default Gaia lighting profiles. To create your own please press the '+' button to create a copy from the current selected profile.", MessageType.Info);
GUI.enabled = false;
}
if (m_profile.m_editSettings)
{
GUI.enabled = true;
}
if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition)
{
if (m_profile.m_enablePostProcessing)
{
m_editorUtils.Heading("PostProcessingSettings");
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
#if UPPipeline
m_profileValues.PostProcessProfileURP = (VolumeProfile)m_editorUtils.ObjectField("PostProcessingProfile", m_profileValues.PostProcessProfileURP, typeof(VolumeProfile), false);
#endif
}
else
{
#if UNITY_POST_PROCESSING_STACK_V2
m_profileValues.PostProcessProfileBuiltIn = (PostProcessProfile)m_editorUtils.ObjectField("PostProcessingProfile", m_profileValues.PostProcessProfileBuiltIn, typeof(PostProcessProfile), false);
m_profileValues.m_directToCamera = m_editorUtils.Toggle("DirectToCamera", m_profileValues.m_directToCamera);
#else
EditorGUILayout.HelpBox("Post Processing is not installed. Install it from the package manager to use the post processing setup features.", MessageType.Info);
#endif
}
GUILayout.Space(20f);
}
if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
//m_profileValues.m_sunRotation = m_editorUtils.Slider("SunRotation", m_profileValues.m_sunRotation, 0f, 90f);
}
if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
m_editorUtils.Heading("SunSettings");
m_profileValues.m_sunRotation = m_editorUtils.Slider("SunRotation", m_profileValues.m_sunRotation, 0f, 360f);
m_profileValues.m_sunPitch = m_editorUtils.Slider("SunPitch", m_profileValues.m_sunPitch, 0f, 360f);
if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.BuiltIn)
{
m_profileValues.m_sunColor = m_editorUtils.ColorField("SunColor", m_profileValues.m_sunColor);
m_profileValues.m_sunIntensity = m_editorUtils.FloatField("SunIntensity", m_profileValues.m_sunIntensity);
}
else
{
m_profileValues.m_lWSunColor = m_editorUtils.ColorField("SunColor", m_profileValues.m_lWSunColor);
m_profileValues.m_lWSunIntensity = m_editorUtils.FloatField("SunIntensity", m_profileValues.m_lWSunIntensity);
}
GUILayout.Space(20f);
}
m_editorUtils.Heading("ShadowSettings");
m_profileValues.m_shadowCastingMode = (LightShadows)EditorGUILayout.EnumPopup("Sun Shadow Casting Mode", m_profileValues.m_shadowCastingMode);
if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
m_profileValues.m_shadowStrength = m_editorUtils.Slider("SunShadowStrength", m_profileValues.m_shadowStrength, 0f, 1f, helpEnabled);
}
m_profileValues.m_shadowDistance = m_editorUtils.Slider("ShadowDistance", m_profileValues.m_shadowDistance, 0f, 10000f, helpEnabled);
m_profileValues.m_sunShadowResolution = (LightShadowResolution)EditorGUILayout.EnumPopup("Sun Shadow Resolution", m_profileValues.m_sunShadowResolution);
GUILayout.Space(20f);
m_editorUtils.Heading("SkyboxSettings");
#if !GAIA_PRO_PRESENT
if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky && m_profileValues.m_userCustomProfile)
{
GUI.enabled = true;
}
#endif
m_profileValues.m_profileType = (GaiaConstants.GaiaLightingProfileType)m_editorUtils.EnumPopup("SkyboxType", m_profileValues.m_profileType, helpEnabled);
#if !GAIA_PRO_PRESENT
if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
GUI.enabled = true;
EditorGUILayout.HelpBox("The 'Procedural Worlds Sky' profile sky type is available in Gaia Pro only, please choose a different profile type.", MessageType.Info);
GUI.enabled = false;
}
#endif
if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.Procedural)
{
m_profileValues.m_sunSize = m_editorUtils.Slider("SunSize", m_profileValues.m_sunSize, 0f, 1f);
m_profileValues.m_sunConvergence = m_editorUtils.Slider("SunConvergence", m_profileValues.m_sunConvergence, 0f, 10f);
m_profileValues.m_atmosphereThickness = m_editorUtils.Slider("AtmosphereThickness", m_profileValues.m_atmosphereThickness, 0f, 5f);
m_profileValues.m_skyboxExposure = m_editorUtils.Slider("SkyboxExposure", m_profileValues.m_skyboxExposure, 0f, 8f);
m_profileValues.m_skyboxTint = m_editorUtils.ColorField("SkyboxTint", m_profileValues.m_skyboxTint);
m_profileValues.m_groundColor = m_editorUtils.ColorField("GroundColor", m_profileValues.m_groundColor);
}
else if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.HDRI)
{
m_profileValues.m_skyboxHDRI = (Cubemap)m_editorUtils.ObjectField("HDRISkybox", m_profileValues.m_skyboxHDRI, typeof(Cubemap), false, GUILayout.Height(16f));
m_profileValues.m_skyboxTint = m_editorUtils.ColorField("SkyboxTint", m_profileValues.m_skyboxTint);
m_profileValues.m_skyboxExposure = m_editorUtils.Slider("SkyboxExposure", m_profileValues.m_skyboxExposure, 0f, 8f);
}
GUILayout.Space(20f);
//m_profileValues.m_ambientMode = (AmbientMode)EditorGUILayout.EnumPopup("Ambient Mode", m_profileValues.m_ambientMode);
if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
m_editorUtils.Heading("AmbientSettings");
m_profileValues.m_ambientMode = (AmbientMode)m_editorUtils.EnumPopup("AmbientMode", m_profileValues.m_ambientMode, helpEnabled);
if (RenderSettings.ambientMode == AmbientMode.Skybox)
{
m_profileValues.m_ambientIntensity = m_editorUtils.Slider("AmbientIntensity", m_profileValues.m_ambientIntensity, 0f, 10f);
}
else if (RenderSettings.ambientMode == AmbientMode.Flat)
{
m_profileValues.m_skyAmbient = m_editorUtils.ColorField("SkyAmbient", m_profileValues.m_skyAmbient);
}
else if (RenderSettings.ambientMode == AmbientMode.Trilight)
{
m_profileValues.m_skyAmbient = m_editorUtils.ColorField("SkyAmbient", m_profileValues.m_skyAmbient);
m_profileValues.m_equatorAmbient = m_editorUtils.ColorField("EquatorAmbient", m_profileValues.m_equatorAmbient);
m_profileValues.m_groundAmbient = m_editorUtils.ColorField("GroundAmbient", m_profileValues.m_groundAmbient);
}
GUILayout.Space(20f);
}
if (m_profile.m_enableFog)
{
m_editorUtils.Heading("FogSettings");
m_profileValues.m_fogMode = (FogMode)EditorGUILayout.EnumPopup("Fog Mode", m_profileValues.m_fogMode);
if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
if (m_profileValues.m_fogMode == FogMode.Linear)
{
m_profileValues.m_fogColor = m_editorUtils.ColorField("FogColor", m_profileValues.m_fogColor);
m_profileValues.m_fogStartDistance = m_editorUtils.FloatField("FogStartDistance", m_profileValues.m_fogStartDistance);
m_profileValues.m_fogEndDistance = m_editorUtils.FloatField("FogEndDistance", m_profileValues.m_fogEndDistance);
}
else
{
m_profileValues.m_fogColor = m_editorUtils.ColorField("FogColor", m_profileValues.m_fogColor);
m_profileValues.m_fogDensity = m_editorUtils.Slider("FogDensity", m_profileValues.m_fogDensity, 0f, 1f);
}
}
}
}
else
{
m_profileValues.m_profileType = (GaiaConstants.GaiaLightingProfileType)m_editorUtils.EnumPopup("SkyboxType", m_profileValues.m_profileType, helpEnabled);
if (m_profile.m_enablePostProcessing)
{
m_editorUtils.Heading("PostProcessingSettings");
EditorGUI.indentLevel++;
#if HDPipeline
m_profileValues.PostProcessProfileHDRP = (VolumeProfile)m_editorUtils.ObjectField("PostProcessingProfile", m_profileValues.PostProcessProfileHDRP, typeof(VolumeProfile), false);
#endif
EditorGUI.indentLevel--;
GUILayout.Space(20f);
}
#if GAIA_PRO_PRESENT
if (m_profile.m_enableAmbientAudio)
{
m_editorUtils.Heading("AmbientAudioSettings");
EditorGUI.indentLevel++;
m_profileValues.m_ambientVolume = m_editorUtils.Slider("AmbientAudioVolume", m_profileValues.m_ambientVolume, 0f, 1f, helpEnabled);
m_profileValues.m_ambientAudio = (AudioClip)m_editorUtils.ObjectField("AmbientAudioClip", m_profileValues.m_ambientAudio, typeof(AudioClip), false, helpEnabled);
EditorGUI.indentLevel--;
GUILayout.Space(20f);
}
#endif
if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
m_editorUtils.Heading("SunSettings");
EditorGUI.indentLevel++;
m_profileValues.m_sunRotation = m_editorUtils.Slider("SunRotation", m_profileValues.m_sunRotation, 0f, 360f);
m_profileValues.m_sunPitch = m_editorUtils.Slider("SunPitch", m_profileValues.m_sunPitch, 0f, 360f);
m_profileValues.m_hDSunColor = m_editorUtils.ColorField("SunColor", m_profileValues.m_hDSunColor);
m_profileValues.m_hDSunIntensity = m_editorUtils.FloatField("SunIntensity", m_profileValues.m_hDSunIntensity);
EditorGUI.indentLevel--;
GUILayout.Space(20f);
}
m_editorUtils.Heading("ShadowSettings");
EditorGUI.indentLevel++;
m_profileValues.m_hDShadowDistance = m_editorUtils.Slider("ShadowDistance", m_profileValues.m_hDShadowDistance, 0f, 10000f);
m_profileValues.m_hDShadowResolution = (GaiaConstants.HDShadowResolution)m_editorUtils.EnumPopup("HDShadowResolution", m_profileValues.m_hDShadowResolution);
m_profileValues.m_hDContactShadows = m_editorUtils.Toggle("ContactShadows", m_profileValues.m_hDContactShadows);
if (m_profileValues.m_hDContactShadows)
{
EditorGUI.indentLevel++;
m_profileValues.m_hDContactShadowsDistance = m_editorUtils.Slider("ContactShadowsDistance", m_profileValues.m_hDContactShadowsDistance, 1f, 2000f);
m_profileValues.m_hDContactShadowQuality = (GaiaConstants.ContactShadowsQuality)m_editorUtils.EnumPopup("ContactShadowsQuality", m_profileValues.m_hDContactShadowQuality);
if (m_profileValues.m_hDContactShadowQuality == GaiaConstants.ContactShadowsQuality.Custom)
{
EditorGUI.indentLevel++;
m_profileValues.m_hDContactShadowCustomQuality = m_editorUtils.IntSlider("ContactShadowsSampleCount", m_profileValues.m_hDContactShadowCustomQuality, 4, 64);
EditorGUI.indentLevel--;
}
m_profileValues.m_hDContactShadowOpacity = m_editorUtils.Slider("ContactShadowOpacity", m_profileValues.m_hDContactShadowOpacity, 0f, 1f);
EditorGUI.indentLevel--;
}
m_profileValues.m_hDMicroShadows = m_editorUtils.Toggle("MicroShadows", m_profileValues.m_hDMicroShadows);
if (m_profileValues.m_hDMicroShadows)
{
EditorGUI.indentLevel++;
m_profileValues.m_hDMicroShadowOpacity = m_editorUtils.Slider("MicroShadowOpacity", m_profileValues.m_hDMicroShadowOpacity, 0f, 1f);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
GUILayout.Space(20f);
if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
m_editorUtils.Heading("SkyboxSettings");
EditorGUI.indentLevel++;
m_profileValues.m_hDSkyType = (GaiaConstants.HDSkyType)EditorGUILayout.EnumPopup("Sky Type", m_profileValues.m_hDSkyType);
if (m_profileValues.m_hDSkyType == GaiaConstants.HDSkyType.HDRI)
{
m_profileValues.m_hDHDRISkybox = (Cubemap)m_editorUtils.ObjectField("HDRISkybox", m_profileValues.m_hDHDRISkybox, typeof(Cubemap), false, GUILayout.Height(16f));
m_profileValues.m_hDHDRIExposure = m_editorUtils.FloatField("SkyboxExposure", m_profileValues.m_hDHDRIExposure);
m_profileValues.m_hDHDRIMultiplier = m_editorUtils.FloatField("SkyboxMultiplier", m_profileValues.m_hDHDRIMultiplier);
}
else if (m_profileValues.m_hDSkyType == GaiaConstants.HDSkyType.Procedural)
{
EditorGUILayout.Space();
m_editorUtils.LabelField("GeometrySettings", EditorStyles.boldLabel);
m_profileValues.m_hDPBSPlanetaryRadius = m_editorUtils.FloatField("PBSPlanetaryRadius", m_profileValues.m_hDPBSPlanetaryRadius, helpEnabled);
m_profileValues.m_hDPBSPlantetCenterPosition = m_editorUtils.Vector3Field("PBSPlanetCenterPosition", m_profileValues.m_hDPBSPlantetCenterPosition, helpEnabled);
EditorGUILayout.Space();
m_editorUtils.LabelField("AirSettings", EditorStyles.boldLabel);
m_profileValues.m_hDPBSAirOpacity = m_editorUtils.ColorField("PBSAirOpacity", m_profileValues.m_hDPBSAirOpacity, helpEnabled);
m_profileValues.m_hDPBSAirAlbedo = m_editorUtils.ColorField("PBSAirAlbedo", m_profileValues.m_hDPBSAirAlbedo, helpEnabled);
m_profileValues.m_hDPBSAirMaximumAltitude = m_editorUtils.FloatField("PBSAirMaximumAltitude", m_profileValues.m_hDPBSAirMaximumAltitude, helpEnabled);
EditorGUILayout.Space();
m_editorUtils.LabelField("AerosolsSettings", EditorStyles.boldLabel);
m_profileValues.m_hDPBSAerosolDensity = m_editorUtils.Slider("PBSAerosolOpacity", m_profileValues.m_hDPBSAerosolDensity, -1f, 1f, helpEnabled);
m_profileValues.m_hDPBSAerosolAlbedo = m_editorUtils.ColorField("PBSAerosolAlbedo", m_profileValues.m_hDPBSAerosolAlbedo, helpEnabled);
m_profileValues.m_hDPBSAerosolMaximumAltitude = m_editorUtils.FloatField("PBSAerosolMaximumAltitude", m_profileValues.m_hDPBSAerosolMaximumAltitude, helpEnabled);
m_profileValues.m_hDPBSAerosolAnisotropy = m_editorUtils.Slider("PBSAerosolAnisotropy", m_profileValues.m_hDPBSAerosolAnisotropy, -1f, 1f, helpEnabled);
EditorGUILayout.Space();
m_editorUtils.LabelField("PlanetSettings", EditorStyles.boldLabel);
m_profileValues.m_hDPBSPlanetRotation = m_editorUtils.Vector3Field("PBSPlanetRotation", m_profileValues.m_hDPBSPlanetRotation, helpEnabled);
m_profileValues.m_hDPBSGroundTint = m_editorUtils.ColorField("PBSGroundColor", m_profileValues.m_hDPBSGroundTint);
m_profileValues.m_hDPBSGroundAlbedoTexture = (Cubemap)m_editorUtils.ObjectField("PBSGroundAlbedoTexture", m_profileValues.m_hDPBSGroundAlbedoTexture, typeof(Cubemap), false, helpEnabled, GUILayout.Height(16f));
m_profileValues.m_hDPBSGroundEmissionTexture = (Cubemap)m_editorUtils.ObjectField("PBSGroundEmissionTexture", m_profileValues.m_hDPBSGroundEmissionTexture, typeof(Cubemap), false, helpEnabled, GUILayout.Height(16f));
EditorGUILayout.Space();
m_editorUtils.LabelField("SpaceSettings", EditorStyles.boldLabel);
m_profileValues.m_hDPBSSpaceRotation = m_editorUtils.Vector3Field("PBSSpaceRotation", m_profileValues.m_hDPBSSpaceRotation, helpEnabled);
m_profileValues.m_hDPBSSpaceEmissionTexture = (Cubemap)m_editorUtils.ObjectField("PBSSpaceEmissionTexture", m_profileValues.m_hDPBSSpaceEmissionTexture, typeof(Cubemap), false, helpEnabled, GUILayout.Height(16f));
EditorGUILayout.Space();
m_editorUtils.LabelField("ArtisticOverrides", EditorStyles.boldLabel);
m_profileValues.m_hDPBSColorSaturation = m_editorUtils.Slider("PBSColorSaturation", m_profileValues.m_hDPBSColorSaturation, 0f, 1f, helpEnabled);
m_profileValues.m_hDPBSAlphaSaturation = m_editorUtils.Slider("PBSAlphaSaturation", m_profileValues.m_hDPBSAlphaSaturation, 0f, 1f, helpEnabled);
m_profileValues.m_hDPBSAlphaMultiplier = m_editorUtils.Slider("PBSAlphaMultiplier", m_profileValues.m_hDPBSAlphaMultiplier, 0f, 1f, helpEnabled);
m_profileValues.m_hDPBSHorizonTint = m_editorUtils.ColorField("PBSHorizonTint", m_profileValues.m_hDPBSHorizonTint, helpEnabled);
m_profileValues.m_hDPBSHorizonZenithShift = m_editorUtils.Slider("PBSHorizonZenithShift", m_profileValues.m_hDPBSHorizonZenithShift, -1f, 1f, helpEnabled);
m_profileValues.m_hDPBSZenithTint = m_editorUtils.ColorField("PBSZenithTint", m_profileValues.m_hDPBSZenithTint, helpEnabled);
EditorGUILayout.Space();
m_editorUtils.LabelField("MiscellaneousSettings", EditorStyles.boldLabel);
m_profileValues.m_hDPBSNumberOfBounces = m_editorUtils.IntSlider("PBSNumberOfBounces", m_profileValues.m_hDPBSNumberOfBounces, 1, 10, helpEnabled);
m_profileValues.m_hDPBSIntensityMode = (GaiaConstants.HDIntensityMode)m_editorUtils.EnumPopup("PBSIntensityMode", m_profileValues.m_hDPBSIntensityMode, helpEnabled);
if (m_profileValues.m_hDPBSIntensityMode == GaiaConstants.HDIntensityMode.Exposure)
{
m_profileValues.m_hDPBSExposure = m_editorUtils.FloatField("PBSExposure", m_profileValues.m_hDPBSExposure, helpEnabled);
}
else
{
m_profileValues.m_hDPBSMultiplier = m_editorUtils.FloatField("PBSMultiplier", m_profileValues.m_hDPBSMultiplier, helpEnabled);
}
m_profileValues.m_hDPBSIncludeSunInBaking = m_editorUtils.Toggle("PBSIncludeSunInBaking", m_profileValues.m_hDPBSIncludeSunInBaking, helpEnabled);
}
else
{
m_profileValues.m_hDGradientTopColor = m_editorUtils.ColorField("TopColor", m_profileValues.m_hDGradientTopColor);
m_profileValues.m_hDGradientMiddleColor = m_editorUtils.ColorField("MiddleColor", m_profileValues.m_hDGradientMiddleColor);
m_profileValues.m_hDGradientBottomColor = m_editorUtils.ColorField("BottomColor", m_profileValues.m_hDGradientBottomColor);
m_profileValues.m_hDGradientDiffusion = m_editorUtils.FloatField("Diffusion", m_profileValues.m_hDGradientDiffusion);
m_profileValues.m_hDGradientExposure = m_editorUtils.FloatField("Exposure", m_profileValues.m_hDGradientExposure);
m_profileValues.m_hDGradientMultiplier = m_editorUtils.FloatField("Multiplier", m_profileValues.m_hDGradientMultiplier);
}
EditorGUI.indentLevel--;
GUILayout.Space(20f);
}
m_editorUtils.Heading("AmbientSettings");
EditorGUI.indentLevel++;
m_profileValues.m_hDAmbientMode = (GaiaConstants.HDAmbientMode)EditorGUILayout.EnumPopup("Ambient Mode", m_profileValues.m_hDAmbientMode);
#if !UNITY_2019_3_OR_NEWER
m_profileValues.m_hDAmbientDiffuseIntensity = m_editorUtils.FloatField("DiffuseIntensity", m_profileValues.m_hDAmbientDiffuseIntensity);
m_profileValues.m_hDAmbientSpecularIntensity = m_editorUtils.FloatField("SpecularIntensity", m_profileValues.m_hDAmbientSpecularIntensity);
#else
if (m_profileValues.m_hDAmbientMode == GaiaConstants.HDAmbientMode.Static)
{
EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("HDRP2019_3AmbientMode"), MessageType.Info);
}
#endif
EditorGUI.indentLevel--;
GUILayout.Space(20f);
if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky)
{
m_editorUtils.Heading("FogSettings");
EditorGUI.indentLevel++;
m_profileValues.m_hDFogType2019_3 = (GaiaConstants.HDFogType2019_3)EditorGUILayout.EnumPopup("Fog Mode", m_profileValues.m_hDFogType2019_3);
if (m_profileValues.m_hDFogType2019_3 == GaiaConstants.HDFogType2019_3.None)
{
EditorGUILayout.HelpBox("No fog mode selected. If you want to use fog please select a different mode", MessageType.Info);
}
else
{
m_profileValues.m_hDVolumetricFogScatterColor = m_editorUtils.ColorField("ScatterColor", m_profileValues.m_hDVolumetricFogScatterColor);
m_profileValues.m_hDVolumetricFogDistance = m_editorUtils.FloatField("FogDistance", m_profileValues.m_hDVolumetricFogDistance);
if (m_profileValues.m_hDVolumetricFogDistance < 0f)
{
m_profileValues.m_hDVolumetricFogDistance = 0f;
}
m_profileValues.m_hDVolumetricFogBaseHeight = m_editorUtils.FloatField("FogBaseHeight", m_profileValues.m_hDVolumetricFogBaseHeight);
if (m_profileValues.m_hDVolumetricFogBaseHeight < 0f)
{
m_profileValues.m_hDVolumetricFogBaseHeight = 0f;
}
m_profileValues.m_hDVolumetricFogMeanHeight = m_editorUtils.FloatField("FogMeanHeight", m_profileValues.m_hDVolumetricFogMeanHeight);
if (m_profileValues.m_hDVolumetricFogMeanHeight < 0f)
{
m_profileValues.m_hDVolumetricFogMeanHeight = 0f;
}
m_profileValues.m_hDVolumetricFogAnisotropy = m_editorUtils.Slider("FogAnisotropy", m_profileValues.m_hDVolumetricFogAnisotropy, 0f, 1f);
m_profileValues.m_hDVolumetricFogProbeDimmer = m_editorUtils.Slider("FogProbeDimmer", m_profileValues.m_hDVolumetricFogProbeDimmer, 0f, 1f);
m_profileValues.m_hDVolumetricFogMaxDistance = m_editorUtils.FloatField("MaxFogDistance", m_profileValues.m_hDVolumetricFogMaxDistance);
if (m_profileValues.m_hDVolumetricFogMaxDistance < 0f)
{
m_profileValues.m_hDVolumetricFogMaxDistance = 0f;
}
m_profileValues.m_hDVolumetricFogDepthExtent = m_editorUtils.FloatField("FogDepthExtent", m_profileValues.m_hDVolumetricFogDepthExtent);
if (m_profileValues.m_hDVolumetricFogDepthExtent < 0f)
{
m_profileValues.m_hDVolumetricFogDepthExtent = 0f;
}
m_profileValues.m_hDVolumetricFogSliceDistribution = m_editorUtils.Slider("FogSliceDistribution", m_profileValues.m_hDVolumetricFogSliceDistribution, 0f, 1f);
}
EditorGUI.indentLevel--;
}
}
GUI.enabled = true;
}
#if !GAIA_PRO_PRESENT
GUI.enabled = currentGUIState;
#endif
}
/// <summary>
/// Adds a new user profile
/// </summary>
private void AddNewCustomProfile()
{
//GaiaLightingProfileValues selectdValues = m_savedSettings.LoadSettings(m_profile, true);
GaiaLightingProfileValues selectdValues = m_profileValues;
GaiaLightingProfileValues newProfile = new GaiaLightingProfileValues();
GaiaUtils.CopyFields(selectdValues, newProfile);
int count = m_profile.m_lightingProfiles.Count + 1;
newProfile.m_typeOfLighting = "New User Profile " + count;
newProfile.m_userCustomProfile = true;
m_profile.m_lightingProfiles.Add(newProfile);
m_profile.m_selectedLightingProfileValuesIndex = m_profile.m_lightingProfiles.Count - 1;
if (m_profile.m_selectedLightingProfileValuesIndex != -99)
{
GaiaUtils.GetRuntimeSceneObject();
if (GaiaGlobal.Instance != null)
{
GaiaLighting.GetProfile(m_profile, m_gaiaSettings.m_pipelineProfile, m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled);
}
}
EditorUtility.SetDirty(m_profile);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e73ed42ad936a6747a9979aca2cb8577
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,240 @@
using UnityEditor;
namespace Gaia.GX.ProceduralWorlds
{
public class GaiaSkiesGX
{
#region Generic informational methods
/// <summary>
/// Returns the publisher name if provided.
/// This will override the publisher name in the namespace ie Gaia.GX.PublisherName
/// </summary>
/// <returns>Publisher name</returns>
public static string GetPublisherName()
{
return "Procedural Worlds";
}
/// <summary>
/// Returns the package name if provided
/// This will override the package name in the class name ie public class PackageName.
/// </summary>
/// <returns>Package name</returns>
public static string GetPackageName()
{
return "Skies";
}
#endregion
#region Methods exposed by Gaia as buttons must be prefixed with GX_
#if AMBIENT_SKIES
public static void GX_OpenAmbientSkies()
{
//Ambient Skies Editor Window
var mainWindow = EditorWindow.GetWindow<AmbientSkies.AmbientSkiesEditorWindow>(false, "Ambient Skies");
//Show window
mainWindow.Show();
}
#endif
/// <summary>
/// Does a quick optimize to your scene/project settings
/// </summary>
public static void GX_Optimization_QuickOptimize()
{
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
if (gaiaSettings != null)
{
GaiaLighting.QuickOptimize(gaiaSettings);
}
}
#if !AMBIENT_SKIES
/// <summary>
/// Sets the time of day to morning
/// </summary>
//public static void GX_TimeOfDay_Morning()
//{
// GaiaLightingProfile lightingProfile = AssetDatabase.LoadAssetAtPath<GaiaLightingProfile>(GetAssetPath("Gaia Lighting System Profile"));
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
// GaiaLighting.GetProfile(GaiaConstants.GaiaLightingProfileType.Morning, lightingProfile, gaiaSettings.m_pipelineProfile, gaiaSettings.m_currentRenderer);
//}
///// <summary>
///// Sets the time of day to day
///// </summary>
//public static void GX_TimeOfDay_Day()
//{
// GaiaLightingProfile lightingProfile = AssetDatabase.LoadAssetAtPath<GaiaLightingProfile>(GetAssetPath("Gaia Lighting System Profile"));
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
// GaiaLighting.GetProfile(GaiaConstants.GaiaLightingProfileType.Day, lightingProfile, gaiaSettings.m_pipelineProfile, gaiaSettings.m_currentRenderer);
//}
///// <summary>
///// Sets the time of day to evening
///// </summary>
//public static void GX_TimeOfDay_Evening()
//{
// GaiaLightingProfile lightingProfile = AssetDatabase.LoadAssetAtPath<GaiaLightingProfile>(GetAssetPath("Gaia Lighting System Profile"));
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
// GaiaLighting.GetProfile(GaiaConstants.GaiaLightingProfileType.Evening, lightingProfile, gaiaSettings.m_pipelineProfile, gaiaSettings.m_currentRenderer);
//}
///// <summary>
///// Sets the time of day to night
///// </summary>
//public static void GX_TimeOfDay_Night()
//{
// GaiaLightingProfile lightingProfile = AssetDatabase.LoadAssetAtPath<GaiaLightingProfile>(GetAssetPath("Gaia Lighting System Profile"));
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
// GaiaLighting.GetProfile(GaiaConstants.GaiaLightingProfileType.Night, lightingProfile, gaiaSettings.m_pipelineProfile, gaiaSettings.m_currentRenderer);
//}
///// <summary>
///// Sets the time of day to default procedural
///// </summary>
//public static void GX_TimeOfDay_DefaultProcedural()
//{
// GaiaLightingProfile lightingProfile = AssetDatabase.LoadAssetAtPath<GaiaLightingProfile>(GetAssetPath("Gaia Lighting System Profile"));
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
// GaiaLighting.GetProfile(GaiaConstants.GaiaLightingProfileType.Default, lightingProfile, gaiaSettings.m_pipelineProfile, gaiaSettings.m_currentRenderer);
//}
/// <summary>
/// Removes gaia lighting from the scene
/// </summary>
///
public static void GX_TimeOfDay_SelectLightingAndWaterProfile()
{
GaiaLighting.OpenProfileSelection();
}
public static void GX_TimeOfDay_SetupLightingProfiles()
{
if (EditorUtility.DisplayDialog("Opening Lighting Profile", "This will open the lighting profile settings. In there you will be able to adjust lighting settings for Gaia, and you can also edit the default lighting parameters for 'Day', 'Nighttime', etc.", "OK", "Cancel"))
{
GaiaUtils.FocusLightingProfile();
}
}
public static void GX_TimeOfDay_RemoveGaiaLighting()
{
GaiaLighting.RemoveGaiaLighting();
}
#endif
/// <summary>
/// Adds occlusion culling volume
/// </summary>
public static void GX_OcclusionCulling_AddOcclusionCullingVolume()
{
GaiaLighting.AddOcclusionCulling(true, false, false);
}
/// <summary>
/// Removes occlusion volume
/// </summary>
public static void GX_OcclusionCulling_RemoveOcclusionCullingVolume()
{
GaiaLighting.RemoveOcclusionCulling(false, false, false);
}
/// <summary>
/// Bakes and adds occlusion volume
/// </summary>
public static void GX_OcclusionCulling_BakeOcclusionCulling()
{
GaiaLighting.BakeOcclusionCulling(true, true, false);
}
/// <summary>
/// Cancels occlusion bake
/// </summary>
public static void GX_OcclusionCulling_CancelOcclusionCulling()
{
GaiaLighting.CancelOcclusionCulling(true, false, false);
}
/// <summary>
/// Clears occlusion data
/// </summary>
public static void GX_OcclusionCulling_ClearOcclusionCulling()
{
GaiaLighting.ClearOcclusionCulling(true, false, true);
}
#if !AMBIENT_SKIES
/// <summary>
/// Bakes lightmapping
/// </summary>
public static void GX_Lightmaps_BakeLighting()
{
GaiaSettings settings = GaiaUtils.GetGaiaSettings();
if (settings != null)
{
if (GaiaUtils.CheckIfSceneProfileExists())
{
GaiaLighting.BakeLighting(GaiaGlobal.Instance.SceneProfile.m_lightingBakeMode, GaiaGlobal.Instance.SceneProfile.m_lightingProfiles[GaiaGlobal.Instance.SceneProfile.m_selectedLightingProfileValuesIndex]);
}
}
}
/// <summary>
/// Cancels lightmapping
/// </summary>
public static void GX_Lightmaps_CancelLightmapBaking()
{
GaiaLighting.CancelLightmapBaking();
}
/// <summary>
/// Clear baked lightmapping
/// </summary>
public static void GX_Lightmaps_ClearBakedLightmaps()
{
GaiaLighting.ClearBakedLightmaps();
}
/// <summary>
/// Clear lightmapping data on disk
/// </summary>
public static void GX_Lightmaps_ClearBakedLightmapDataOnDisk()
{
GaiaLighting.ClearLightmapDataOnDisk();
}
#endif
#endregion
#region Utils
/// <summary>
/// Get the asset path of the first thing that matches the name
/// </summary>
/// <param name="name">Name to search for</param>
/// <returns></returns>
private static string GetAssetPath(string name)
{
string[] assets = AssetDatabase.FindAssets(name, null);
if (assets.Length > 0)
{
return AssetDatabase.GUIDToAssetPath(assets[0]);
}
return null;
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0a915d5bd3fca2f41b5e21c1968b1b4b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,289 @@
using System;
using System.Collections.Generic;
using ProceduralWorlds.WaterSystem;
using UnityEngine;
using UnityEditor;
namespace Gaia
{
public static class LightProbeUtils
{
#region Variables
//Probe locaions
private static Quadtree<LightProbeGroup> m_probeLocations = new Quadtree<LightProbeGroup>(new Rect(0, 0, 10f, 10f));
//Stored list of reflection probes
public static int m_storedProbes;
//Current created count
public static int m_currentProbeCount;
#endregion
#region Light Probe Creation Button Functions
/// <summary>
/// Setup for the automatically probe spawning
/// </summary>
/// <param name="profile"></param>
public static void CreateAutomaticProbes(ReflectionProbeData profile)
{
int numberTerrains = Terrain.activeTerrains.Length;
if (numberTerrains == 0)
{
Debug.LogError("Unable to initiate probe spawning systen. No terrain found");
}
else
{
if (profile.lightProbesPerRow < 2)
{
Debug.LogError("Please set Light Probes Per Row to a value of 2 or higher");
}
else
{
LoadProbesFromScene();
m_probeLocations = null;
ClearCreatedLightProbes();
float seaLevel = 0f;
PWS_WaterSystem gaiawater = GameObject.FindObjectOfType<PWS_WaterSystem>();
if (gaiawater != null)
{
seaLevel = gaiawater.SeaLevel;
}
if (GaiaUtils.HasDynamicLoadedTerrains())
{
Action<Terrain> terrAction = (t) => GenerateProbesOnTerrain(t, profile, seaLevel);
GaiaUtils.CallFunctionOnDynamicLoadedTerrains(terrAction, true, null, "Generating Light Probes");
}
else
{
foreach (var activeTerrain in Terrain.activeTerrains)
{
GenerateProbesOnTerrain(activeTerrain, profile, seaLevel);
}
}
}
}
}
#endregion
#region Light Probe Utils
private static void GenerateProbesOnTerrain(Terrain terrain, ReflectionProbeData profile, float seaLevel)
{
GameObject lightProbeObject = GameObject.Find(terrain.name + " Light Probes Group Data");
if (lightProbeObject == null)
{
lightProbeObject = new GameObject(terrain.name + " Light Probes Group Data");
}
LightProbeGroup lightProbeData = lightProbeObject.GetComponent<LightProbeGroup>();
if (lightProbeData == null)
{
lightProbeData = lightProbeObject.AddComponent<LightProbeGroup>();
lightProbeData.probePositions = new Vector3[0];
}
GameObject lightParentObject = LightProbeParenting(terrain);
Vector3 terrainSize = terrain.terrainData.size;
m_storedProbes = profile.lightProbesPerRow * profile.lightProbesPerRow;
for (int row = 0; row < profile.lightProbesPerRow; ++row)
{
for (int columns = 0; columns < profile.lightProbesPerRow; ++columns)
{
Vector3 newPosition = lightProbeObject.transform.position - lightProbeData.transform.position;
newPosition.x = ((columns + 1) * terrainSize.x / profile.lightProbesPerRow) - terrainSize.x / profile.lightProbesPerRow / 2f + terrain.transform.position.x;
newPosition.z = ((row + 1) * terrainSize.z / profile.lightProbesPerRow) - terrainSize.z / profile.lightProbesPerRow / 2f + terrain.transform.position.z;
float sampledHeight = terrain.SampleHeight(newPosition);
newPosition.y = sampledHeight + 2.5f;
List<Vector3> probePositions = new List<Vector3>(lightProbeData.probePositions);
if (sampledHeight > seaLevel)
{
probePositions.Add(newPosition);
newPosition += new Vector3(0f, 2.5f, 0f);
probePositions.Add(newPosition);
newPosition += new Vector3(0f, 10f, 0f);
probePositions.Add(newPosition);
lightProbeData.probePositions = probePositions.ToArray();
m_currentProbeCount++;
}
}
}
lightProbeObject.transform.SetParent(lightParentObject.transform);
EditorGUIUtility.PingObject(lightParentObject);
}
/// <summary>
/// Creates the reflection prrobe parent object
/// </summary>
/// <param name="parentWithGaia"></param>
/// <returns></returns>
private static GameObject LightProbeParenting(Terrain parentTerrain)
{
if (parentTerrain == null)
{
Debug.LogWarning("Terrain provided in ReflectionProbeParenting() is null");
return null;
}
GameObject reflectionProbeParent = GameObject.Find(parentTerrain.name + " Light Probes");
if (reflectionProbeParent == null)
{
reflectionProbeParent = new GameObject(parentTerrain.name + " Light Probes");
}
reflectionProbeParent.transform.SetParent(parentTerrain.transform);
return reflectionProbeParent;
}
/// <summary>
/// Load the probes in from the scene
/// </summary>
private static void LoadProbesFromScene()
{
//Start time
//DateTime startTime = DateTime.Now;
//Destroy previous contents
m_probeLocations = null;
//Work out the bounds of the environment
float minY = float.NaN;
float minX = float.NaN;
float maxX = float.NaN;
float minZ = float.NaN;
float maxZ = float.NaN;
Terrain sampleTerrain = null;
foreach (Terrain terrain in Terrain.activeTerrains)
{
if (float.IsNaN(minY))
{
sampleTerrain = terrain;
minY = terrain.transform.position.y;
minX = terrain.transform.position.x;
minZ = terrain.transform.position.z;
maxX = minX + terrain.terrainData.size.x;
maxZ = minZ + terrain.terrainData.size.z;
}
else
{
if (terrain.transform.position.x < minX)
{
minX = terrain.transform.position.x;
}
if (terrain.transform.position.z < minZ)
{
minZ = terrain.transform.position.z;
}
if ((terrain.transform.position.x + terrain.terrainData.size.x) > maxX)
{
maxX = terrain.transform.position.x + terrain.terrainData.size.x;
}
if ((terrain.transform.position.z + terrain.terrainData.size.z) > maxZ)
{
maxZ = terrain.transform.position.z + terrain.terrainData.size.z;
}
}
}
if (sampleTerrain != null)
{
Rect terrainBounds = new Rect(minX, minZ, maxX - minX, maxZ - minZ);
m_probeLocations = new Quadtree<LightProbeGroup>(terrainBounds);
}
else
{
Rect bigSpace = new Rect(-10000f, -10000f, 20000f, 20000f);
m_probeLocations = new Quadtree<LightProbeGroup>(bigSpace);
}
//Now grab all the light probes in the scene
LightProbeGroup probeGroup;
LightProbeGroup[] probeGroups = UnityEngine.Object.FindObjectsOfType<LightProbeGroup>();
for (int probeGroupIdx = 0; probeGroupIdx < probeGroups.Length; probeGroupIdx++)
{
probeGroup = probeGroups[probeGroupIdx];
for (int probePosition = 0; probePosition < probeGroup.probePositions.Length; probePosition++)
{
m_probeLocations.Insert(probeGroup.transform.position.x + probeGroup.probePositions[probePosition].x, probeGroup.transform.position.z + probeGroup.probePositions[probePosition].z, probeGroup);
}
}
}
/// <summary>
/// Add a probe instance into storage - must be called after the initial load call
/// </summary>
/// <param name="position">Position it is being located at</param>
/// <param name="probeGroup">Probe group being managed</param>
public static void AddProbe(Vector3 position, LightProbeGroup probeGroup)
{
if (m_probeLocations == null)
{
return;
}
m_probeLocations.Insert(position.x, position.z, probeGroup);
}
/// <summary>
/// Add a probe instance into storage - must be called after the initial load call
/// </summary>
/// <param name="position">Position it is being located at</param>
/// <param name="probeGroup">Probe group being managed</param>
public static void RemoveProbe(Vector3 position, LightProbeGroup probeGroup)
{
if (m_probeLocations == null)
{
return;
}
m_probeLocations.Remove(position.x, position.z, probeGroup);
}
/// <summary>
/// Clears reflection probes created
/// </summary>
public static void ClearCreatedLightProbes()
{
if (GaiaUtils.HasDynamicLoadedTerrains())
{
Action<Terrain> terrAction = (t) => DeleteProbeGroup(t);
GaiaUtils.CallFunctionOnDynamicLoadedTerrains(terrAction, true, null, "Clearing Light Probes");
}
else
{
if (Terrain.activeTerrains.Length < 1)
{
Debug.LogError("No terrains we're found, unable to clear light probes.");
}
else
{
foreach (var activeTerrain in Terrain.activeTerrains)
{
DeleteProbeGroup(activeTerrain);
}
}
}
}
private static void DeleteProbeGroup(Terrain terrain)
{
GameObject lightProbeParent = GameObject.Find(terrain.name + " Light Probes");
if (lightProbeParent != null)
{
GameObject.DestroyImmediate(lightProbeParent);
m_currentProbeCount = 0;
}
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b30a587256c138f47a06f1684a8a3541
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,73 @@
using System.Collections;
using System.Collections.Generic;
using Gaia.Internal;
using PWCommon4;
using UnityEditor;
using UnityEngine;
namespace Gaia
{
[CustomEditor(typeof(PWSkyPostProcessingManager))]
public class PWSkyPostProcessingManagerEditor : PWEditor
{
private PWSkyPostProcessingManager m_profile;
private EditorUtils m_editorUtils;
private GaiaConstants.EnvironmentRenderer m_renderpipeline;
private const string m_builtInText = "Post processing settigns are modified in the Gaia PW Sky Weather and Time Of Day system. This will change most of the common settings such as.";
private const string m_srpText = "";
private void OnEnable()
{
m_renderpipeline = GaiaUtils.GetActivePipeline();
if (m_editorUtils == null)
{
// Get editor utils for this
m_editorUtils = PWApp.GetEditorUtils(this);
}
}
public override void OnInspectorGUI()
{
//Initialization
m_editorUtils.Initialize(); // Do not remove this!
m_profile = (PWSkyPostProcessingManager) target;
m_editorUtils.Panel("GlobalSettings", GlobalSettings, true);
}
private void GlobalSettings(bool helpEnabled)
{
#if GAIA_PRO_PRESENT
if (m_renderpipeline == GaiaConstants.EnvironmentRenderer.BuiltIn)
{
//EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("BuiltInHelpText"), MessageType.Info);
m_editorUtils.TextNonLocalized(m_editorUtils.GetTextValue("BuiltInHelpText"));
if (ProceduralWorldsGlobalWeather.Instance != null)
{
if (ProceduralWorldsGlobalWeather.Instance.m_modifyPostProcessing)
{
//if (GUILayout.Button(new GUIContent("Disable Post FX In Weather", "Disables the post processing fx to be used/synced in the PW Sky weather and time of day system")))
if (m_editorUtils.Button("DisablePostFXInWeather"))
{
m_profile.DisableWeatherPostFX();
}
}
else
{
//if (GUILayout.Button(new GUIContent("Enable Post FX In Weather", "Enables the post processing fx to be used/synced in the PW Sky weather and time of day system")))
if (m_editorUtils.Button("EnablePostFXInWeather"))
{
m_profile.EnableWeatherPostFX();
}
}
}
}
else
{
//EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("SRPHelpText"), MessageType.Info);
m_editorUtils.TextNonLocalized(m_editorUtils.GetTextValue("SRPHelpText"));
}
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 49bda3c9ad25b1849bafe668c4dfcdd0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,231 @@
using UnityEngine;
using UnityEditor;
#if HDPipeline
using UnityEngine.Rendering.HighDefinition;
#endif
using System.Collections.Generic;
using ProceduralWorlds.WaterSystem;
using System;
using UnityEngine.Rendering;
namespace Gaia
{
public static class ReflectionProbeEditorUtils
{
#region Variables
//Stored list of reflection probes
public static List<ReflectionProbe> m_storedProbes = new List<ReflectionProbe>();
//Current created count
public static int m_currentProbeCount;
//If the probe system is active to begin baking the probes
public static bool m_probeRenderActive = false;
#endregion
#region Reflection Probe Creation Button Functions
/// <summary>
/// Setup for the automatically probe spawning
/// </summary>
/// <param name="reflectionProbeData"></param>
public static void CreateAutomaticProbes(ReflectionProbeData reflectionProbeData, GaiaConstants.EnvironmentRenderer renderPipelineSettings)
{
if (reflectionProbeData == null)
{
return;
}
if (reflectionProbeData.reflectionProbeRefresh == GaiaConstants.ReflectionProbeRefreshModePW.ProbeManager && reflectionProbeData.reflectionProbeMode == ReflectionProbeMode.Realtime)
{
#if GAIA_PRO_PRESENT
ReflectionProbeManager manager = ReflectionProbeManager.GetOrCreateProbeManager();
if (manager != null)
{
manager.ProbeLayerMask = reflectionProbeData.reflectionprobeCullingMask;
}
#endif
}
else
{
#if GAIA_PRO_PRESENT
ReflectionProbeManager.RemoveReflectionProbeManager();
#endif
}
ClearCreatedReflectionProbes();
GameObject oldReflectionProbe = GameObject.Find("Global Reflection Probe");
if (oldReflectionProbe != null)
{
UnityEngine.Object.DestroyImmediate(oldReflectionProbe);
Debug.Log("Old Reflection Probe Destroyed");
}
if (reflectionProbeData.reflectionProbesPerRow < 2)
{
Debug.LogError("Please set Probes Per Row to a value of 2 or higher");
}
else
{
m_currentProbeCount = 0;
float seaLevel = 0f;
bool seaLevelActive = false;
PWS_WaterSystem gaiawater = GameObject.FindObjectOfType<PWS_WaterSystem>();
if (gaiawater != null)
{
seaLevel = gaiawater.SeaLevel;
seaLevelActive = true;
}
if (GaiaUtils.HasDynamicLoadedTerrains())
{
Action<Terrain> terrAction = (t) => GenerateProbesOnTerrain(t, reflectionProbeData, seaLevelActive, seaLevel, renderPipelineSettings);
GaiaUtils.CallFunctionOnDynamicLoadedTerrains(terrAction, true, null, "Generating Reflection Probes");
}
else
{
if (Terrain.activeTerrains.Length < 1)
{
Debug.LogError("No terrains we're found, unable to generate reflection probes.");
}
else
{
foreach (var activeTerrain in Terrain.activeTerrains)
{
GenerateProbesOnTerrain(activeTerrain, reflectionProbeData, seaLevelActive, seaLevel, renderPipelineSettings);
}
}
}
m_probeRenderActive = true;
}
}
#endregion
#region Reflection Probe Utils
private static void GenerateProbesOnTerrain(Terrain terrain, ReflectionProbeData reflectionProbeData, bool seaLevelActive, float seaLevel, GaiaConstants.EnvironmentRenderer renderPipelineSettings)
{
GameObject reflectionParentObject = ReflectionProbeParenting(terrain);
Vector3 terrainSize = terrain.terrainData.size;
#if GAIA_PRO_PRESENT
ReflectionProbeManager rpManager = ReflectionProbeManager.Instance;
for (int row = 0; row < reflectionProbeData.reflectionProbesPerRow; ++row)
{
for (int columns = 0; columns < reflectionProbeData.reflectionProbesPerRow; ++columns)
{
Vector3 newPosition = new Vector3
{
x = ((columns + 1) * terrainSize.x / reflectionProbeData.reflectionProbesPerRow) - terrainSize.x / reflectionProbeData.reflectionProbesPerRow / 2f + terrain.transform.position.x,
z = ((row + 1) * terrainSize.z / reflectionProbeData.reflectionProbesPerRow) - terrainSize.z / reflectionProbeData.reflectionProbesPerRow / 2f + terrain.transform.position.z
};
Vector3 size = new Vector3(terrain.terrainData.size.x / reflectionProbeData.reflectionProbesPerRow, terrain.terrainData.size.y, terrain.terrainData.size.z / reflectionProbeData.reflectionProbesPerRow);
if (rpManager != null)
{
ReflectionProbe newProbe = ReflectionProbeUtils.CreateReflectionProbe(newPosition, size, terrain, reflectionProbeData, seaLevelActive, seaLevel, reflectionParentObject.transform, renderPipelineSettings == GaiaConstants.EnvironmentRenderer.HighDefinition, rpManager.UseReflectionProbeCuller);
m_storedProbes.Add(newProbe);
}
else
{
ReflectionProbe newProbe = ReflectionProbeUtils.CreateReflectionProbe(newPosition, size, terrain, reflectionProbeData, seaLevelActive, seaLevel, reflectionParentObject.transform, renderPipelineSettings == GaiaConstants.EnvironmentRenderer.HighDefinition);
m_storedProbes.Add(newProbe);
}
m_currentProbeCount++;
}
}
#else
for (int row = 0; row < reflectionProbeData.reflectionProbesPerRow; ++row)
{
for (int columns = 0; columns < reflectionProbeData.reflectionProbesPerRow; ++columns)
{
Vector3 newPosition = new Vector3
{
x = ((columns + 1) * terrainSize.x / reflectionProbeData.reflectionProbesPerRow) - terrainSize.x / reflectionProbeData.reflectionProbesPerRow / 2f + terrain.transform.position.x,
z = ((row + 1) * terrainSize.z / reflectionProbeData.reflectionProbesPerRow) - terrainSize.z / reflectionProbeData.reflectionProbesPerRow / 2f + terrain.transform.position.z
};
Vector3 size = new Vector3(terrain.terrainData.size.x / reflectionProbeData.reflectionProbesPerRow, terrain.terrainData.size.y, terrain.terrainData.size.z / reflectionProbeData.reflectionProbesPerRow);
ReflectionProbe newProbe = ReflectionProbeUtils.CreateReflectionProbe(newPosition, size, terrain, reflectionProbeData, seaLevelActive, seaLevel, reflectionParentObject.transform, renderPipelineSettings == GaiaConstants.EnvironmentRenderer.HighDefinition);
m_storedProbes.Add(newProbe);
m_currentProbeCount++;
}
}
#endif
EditorGUIUtility.PingObject(reflectionParentObject);
}
/// <summary>
/// Creates the reflection prrobe parent object
/// </summary>
/// <param name="parentWithAmbientSkies"></param>
/// <returns></returns>
private static GameObject ReflectionProbeParenting(Terrain parentTerrain)
{
if (parentTerrain == null)
{
Debug.LogWarning("Terrain provided in ReflectionProbeParenting() is null");
return null;
}
GameObject reflectionProbeParent = GameObject.Find(parentTerrain.name + " Reflection Probes");
if (reflectionProbeParent == null)
{
reflectionProbeParent = new GameObject(parentTerrain.name + " Reflection Probes");
}
reflectionProbeParent.transform.SetParent(parentTerrain.transform);
return reflectionProbeParent;
}
/// <summary>
/// Clears reflection probes created
/// </summary>
public static void ClearCreatedReflectionProbes()
{
GameObject oldReflectionProbe = GameObject.Find("Global Reflection Probe");
if (oldReflectionProbe != null)
{
UnityEngine.Object.DestroyImmediate(oldReflectionProbe);
Debug.Log("Old Reflection Probe Destroyed");
}
if (GaiaUtils.HasDynamicLoadedTerrains())
{
Action<Terrain> terrAction = (t) => DeleteProbeGroup(t);
GaiaUtils.CallFunctionOnDynamicLoadedTerrains(terrAction, true, null, "Clearning Reflection Probes");
}
else
{
if (Terrain.activeTerrains.Length < 1)
{
Debug.LogError("No terrains we're found, unable to generate reflection probes.");
}
else
{
foreach (var activeTerrain in Terrain.activeTerrains)
{
DeleteProbeGroup(activeTerrain);
}
}
}
}
private static void DeleteProbeGroup(Terrain terrain)
{
GameObject reflectionProbeParent = GameObject.Find(terrain.name + " Reflection Probes");
if (reflectionProbeParent != null)
{
GameObject.DestroyImmediate(reflectionProbeParent);
m_currentProbeCount = 0;
}
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 162317b4afb83b24c996aff0f997f2cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,251 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Gaia
{
public class SRPConversionUtils
{
#region Universal Utils
public static void ConvertProfileToURP(SceneProfile lightingProfile, GaiaLightingProfileValues profile, bool convertToNewProfile = false)
{
try
{
if (GaiaUtils.GetActivePipeline() != GaiaConstants.EnvironmentRenderer.Universal)
{
Debug.Log("Need to be using Universal render pipeline to use this function");
return;
}
GaiaLightingProfileValues profileValue = profile;
if (convertToNewProfile)
{
GaiaLightingProfileValues newProfileValues = new GaiaLightingProfileValues();
GaiaUtils.CopyFields(profile, newProfileValues);
profileValue = newProfileValues;
lightingProfile.m_lightingProfiles.Add(profileValue);
profileValue.m_typeOfLighting = "Converted URP Profile " + (lightingProfile.m_lightingProfiles.Count - 1);
lightingProfile.m_selectedLightingProfileValuesIndex = lightingProfile.m_lightingProfiles.Count - 1;
}
if (EditorUtility.DisplayDialog("Convert Sun", "Would you like to convert the Sun Values", "Yes", "No"))
{
ConvertSun(profileValue, GaiaConstants.EnvironmentRenderer.Universal);
}
//ConvertPWWeather(profileValue, GaiaConstants.EnvironmentRenderer.Universal);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
#endregion
#region High Definition Utils
public static void ConvertProfileToHDRP(SceneProfile lightingProfile, GaiaLightingProfileValues profile, bool convertToNewProfile = false)
{
try
{
if (GaiaUtils.GetActivePipeline() != GaiaConstants.EnvironmentRenderer.HighDefinition)
{
Debug.Log("Need to be using High Definition render pipeline to use this function");
return;
}
GaiaLightingProfileValues profileValue = profile;
if (convertToNewProfile)
{
GaiaLightingProfileValues newProfileValues = new GaiaLightingProfileValues();
GaiaUtils.CopyFields(profile, newProfileValues);
profileValue = newProfileValues;
lightingProfile.m_lightingProfiles.Add(profileValue);
profileValue.m_typeOfLighting = "Converted HDRP Profile " + (lightingProfile.m_lightingProfiles.Count - 1);
lightingProfile.m_selectedLightingProfileValuesIndex = lightingProfile.m_lightingProfiles.Count - 1;
}
if (EditorUtility.DisplayDialog("Convert Sun", "Would you like to convert the Sun Values", "Yes", "No"))
{
ConvertSun(profileValue, GaiaConstants.EnvironmentRenderer.HighDefinition);
}
//ConvertPWWeather(profileValue, GaiaConstants.EnvironmentRenderer.HighDefinition);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
#endregion
#region Utils
private static void ConvertSun(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
profile.m_lWSunColor = profile.m_sunColor;
profile.m_lWSunIntensity = profile.m_sunIntensity + 0.15f;
}
else
{
profile.m_hDSunColor = profile.m_sunColor;
profile.m_hDSunIntensity = profile.m_sunIntensity * 3f;
}
}
private static void ConvertPWWeather(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
ConvertCloudBrightness(profile, renderPipeline);
ConvertAmbientIntensity(profile, renderPipeline);
ConvertAtmosphereThickness(profile, renderPipeline);
ConvertCloudHeightLevelDensity(profile, renderPipeline);
ConvertCloudHeightLevelThickness(profile, renderPipeline);
ConvertCloudOpacity(profile, renderPipeline);
ConvertFogDensity(profile, renderPipeline);
ConvertSunIntensity(profile, renderPipeline);
}
private static void ConvertCloudBrightness(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.CloudDomeBrightness.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.CloudDomeBrightness.keys[i].value += 0.1f;
}
}
else
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.CloudDomeBrightness.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.CloudDomeBrightness.keys[i].value += 0.15f;
}
}
}
private static void ConvertAmbientIntensity(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODAmbientIntensity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODAmbientIntensity.keys[i].value += 0.05f;
}
}
else
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODAmbientIntensity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODAmbientIntensity.keys[i].value += 0.15f;
}
}
}
private static void ConvertAtmosphereThickness(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODAtmosphereThickness.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODAtmosphereThickness.keys[i].value += 0.05f;
}
}
else
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODAtmosphereThickness.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODAtmosphereThickness.keys[i].value += 0.075f;
}
}
}
private static void ConvertCloudHeightLevelDensity(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODCloudHeightLevelDensity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODCloudHeightLevelDensity.keys[i].value += 0.01f;
}
}
else
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODCloudHeightLevelDensity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODCloudHeightLevelDensity.keys[i].value += 0.02f;
}
}
}
private static void ConvertCloudHeightLevelThickness(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness.keys[i].value += 0.1f;
}
}
else
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness.keys[i].value += 0.125f;
}
}
}
private static void ConvertCloudOpacity(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODCloudOpacity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODCloudOpacity.keys[i].value += 0.01f;
}
}
else
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODCloudOpacity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODCloudOpacity.keys[i].value += 0.05f;
}
}
}
private static void ConvertFogDensity(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
//Does not need changing
}
else
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODFogDensity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODFogDensity.keys[i].value += 0.005f;
}
}
}
private static void ConvertSunIntensity(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline)
{
if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal)
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODSunIntensity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODSunIntensity.keys[i].value += 0.06f;
}
}
else
{
for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODSunIntensity.keys.Length; i++)
{
profile.m_pwSkyAtmosphereData.TODSunIntensity.keys[i].value *= 3f;
}
}
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1bd43ad3ef775c46ba7420904e10820
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,189 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Gaia
{
public class SelectProfileWindowEditor : EditorWindow
{
private GaiaLightingProfile m_lightingProfile;
private GaiaWaterProfile m_waterProfile;
private GaiaSettings m_gaiaSettings;
private GUIStyle m_boxStyle;
private List<string> LightingList = new List<string>();
private List<string> WaterList = new List<string>();
/// <summary>
/// Show Select Profile Manager editor window
/// </summary>
public static void ShowProfileManager(GaiaLightingProfile lightingProfile, GaiaWaterProfile waterProfile, GaiaSettings gaiaSettings)
{
var manager = EditorWindow.GetWindow<SelectProfileWindowEditor>(false, "Lighting And Water Profile Selection");
if (manager != null)
{
manager.m_lightingProfile = lightingProfile;
manager.m_waterProfile = waterProfile;
manager.m_gaiaSettings = gaiaSettings;
Vector2 initialSize = new Vector2(350f, 120f);
manager.position = new Rect(new Vector2(Screen.currentResolution.width / 2f - initialSize.x / 2f, Screen.currentResolution.height / 2f - initialSize.y / 2f), initialSize);
manager.Show();
}
}
void OnGUI()
{
//Set up the box style
if (m_boxStyle == null)
{
m_boxStyle = new GUIStyle(GUI.skin.box);
m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
m_boxStyle.fontStyle = FontStyle.Bold;
m_boxStyle.alignment = TextAnchor.UpperLeft;
}
if (m_lightingProfile != null && m_waterProfile != null)
{
CreateArrayLists();
MainTab();
}
}
private void MainTab()
{
EditorGUILayout.BeginVertical(m_boxStyle);
Lighting();
Water();
Weather();
EditorGUILayout.EndVertical();
}
private void Lighting()
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Lighting Preset", EditorStyles.boldLabel, GUILayout.Width(105f));
m_lightingProfile.m_selectedLightingProfileValuesIndex = EditorGUILayout.Popup(m_lightingProfile.m_selectedLightingProfileValuesIndex, LightingList.ToArray());
if (GUILayout.Button("Edit"))
{
GaiaLighting.FocusGaiaLightingProfile();
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
{
if (GaiaGlobal.Instance != null)
{
GaiaUtils.GetRuntimeSceneObject();
GaiaLighting.GetProfile(GaiaGlobal.Instance.SceneProfile, m_gaiaSettings.m_pipelineProfile, m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled);
}
}
}
private void Water()
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Water Preset", EditorStyles.boldLabel, GUILayout.Width(105f));
m_gaiaSettings.m_gaiaWaterProfile.m_selectedWaterProfileValuesIndex = EditorGUILayout.Popup(m_gaiaSettings.m_gaiaWaterProfile.m_selectedWaterProfileValuesIndex, WaterList.ToArray());
if (GUILayout.Button("Edit"))
{
GaiaUtils.FocusWaterProfile();
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
{
Material waterMat = GaiaWater.GetGaiaOceanMaterial();
GaiaUtils.GetRuntimeSceneObject();
if (GaiaGlobal.Instance != null)
{
GaiaWater.GetProfile(m_gaiaSettings.m_gaiaWaterProfile.m_selectedWaterProfileValuesIndex, waterMat, GaiaGlobal.Instance.SceneProfile, true, false);
}
}
}
private void Weather()
{
#if GAIA_PRO_PRESENT
if (ProceduralWorldsGlobalWeather.Instance != null)
{
if (Application.isPlaying)
{
GUI.enabled = true;
}
else
{
if (ProceduralWorldsGlobalWeather.Instance.m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition)
{
EditorGUILayout.HelpBox("Playing/Stoping weather is only avaliable in play mode", MessageType.Info);
GUI.enabled = false;
}
}
if (ProceduralWorldsGlobalWeather.Instance.m_renderPipeline == GaiaConstants.EnvironmentRenderer.HighDefinition)
{
EditorGUILayout.HelpBox("Rain and Snow is not avaliable for HDRP, this feature will be available soon.", MessageType.Info);
GUI.enabled = false;
}
EditorGUILayout.BeginHorizontal();
if (!ProceduralWorldsGlobalWeather.Instance.IsRaining)
{
if (GUILayout.Button("Start Rain"))
{
ProceduralWorldsGlobalWeather.Instance.PlayRain();
}
}
else
{
if (GUILayout.Button("Stop Rain"))
{
ProceduralWorldsGlobalWeather.Instance.StopRain();
}
}
if (!ProceduralWorldsGlobalWeather.Instance.IsSnowing)
{
if (GUILayout.Button("Start Snow"))
{
if (ProceduralWorldsGlobalWeather.Instance.m_player.transform.position.y > ProceduralWorldsGlobalWeather.Instance.SnowHeight)
{
ProceduralWorldsGlobalWeather.Instance.PlaySnow();
}
else
{
Debug.Log("You are not at the right altitude for snow to happen. Your altitude is: " + ProceduralWorldsGlobalWeather.Instance.m_player.transform.position.y + " Snow can happen at altitude: " + ProceduralWorldsGlobalWeather.Instance.SnowHeight);
}
}
}
else
{
if (GUILayout.Button("Stop Snow"))
{
ProceduralWorldsGlobalWeather.Instance.StopSnow();
}
}
GUI.enabled = true;
EditorGUILayout.EndHorizontal();
}
#endif
}
private void CreateArrayLists()
{
LightingList.Clear();
foreach(GaiaLightingProfileValues gaiaLighting in m_lightingProfile.m_lightingProfiles)
{
LightingList.Add(gaiaLighting.m_typeOfLighting);
}
WaterList.Clear();
foreach(GaiaWaterProfileValues gaiaWater in m_waterProfile.m_waterProfiles)
{
WaterList.Add(gaiaWater.m_typeOfWater);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cff6553670a0cf1469dc4262c7ada6bd
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: 223176b09fd283c4da4828330e326a50
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,88 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Gaia
{
public class GaiaLightingProfile : ScriptableObject
{
[HideInInspector]
public bool m_multiSceneLightingSupport = true;
[HideInInspector]
public bool m_updateInRealtime = false;
//[HideInInspector]
//public GaiaConstants.GaiaLightingProfileType m_lightingProfile = GaiaConstants.GaiaLightingProfileType.Day;
[HideInInspector]
public int m_selectedLightingProfileValuesIndex = 0;
[HideInInspector]
public bool m_renamingProfile = false;
[HideInInspector]
public bool m_editSettings = false;
[HideInInspector]
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
[HideInInspector]
public Material m_masterSkyboxMaterial;
public List<GaiaLightingProfileValues> m_lightingProfiles = new List<GaiaLightingProfileValues>();
[HideInInspector]
public bool m_parentObjects = true;
[HideInInspector]
public bool m_hideProcessVolume = true;
[HideInInspector]
public bool m_enablePostProcessing = true;
[HideInInspector]
public bool m_enableAmbientAudio = true;
[HideInInspector]
public bool m_enableFog = true;
[HideInInspector]
public GaiaConstants.GaiaProAntiAliasingMode m_antiAliasingMode = GaiaConstants.GaiaProAntiAliasingMode.TAA;
[HideInInspector]
public float m_AAJitterSpread = 0.55f;
[HideInInspector]
public float m_AAStationaryBlending = 0.95f;
[HideInInspector]
public float m_AAMotionBlending = 0.9f;
[HideInInspector]
public float m_AASharpness = 0.25f;
[HideInInspector]
public float m_antiAliasingTAAStrength = 0.7f;
[HideInInspector]
public bool m_cameraDithering = true;
[HideInInspector]
public float m_cameraAperture = 16f;
[HideInInspector]
public bool m_usePhysicalCamera = false;
[HideInInspector]
public Vector2 m_cameraSensorSize = new Vector2(70.41f, 52.63f);
[HideInInspector]
public float m_cameraFocalLength = 50f;
[HideInInspector]
public bool m_globalReflectionProbe = true;
//Auto DOF
public bool m_enableAutoDOF = true;
public LayerMask m_dofLayerDetection = 1;
/// <summary>
/// Create Gaia Lighting System Profile asset
/// </summary>
#if UNITY_EDITOR
[MenuItem("Assets/Create/Procedural Worlds/Gaia/Lighting Profile")]
public static void CreateSkyProfiles()
{
GaiaLightingProfile asset = ScriptableObject.CreateInstance<GaiaLightingProfile>();
AssetDatabase.CreateAsset(asset, "Assets/Gaia Lighting System Profile.asset");
AssetDatabase.SaveAssets();
EditorUtility.FocusProjectWindow();
Selection.activeObject = asset;
}
#endif
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 676ccfb230608cb4ca778255020cb5fc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: dffcb73693a3ab445abdc7e1ad4b8bb3, type: 3}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c61a006a6550afd4d9c71f7a04519c46
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,68 @@
using UnityEngine;
#if UNITY_POST_PROCESSING_STACK_V2
using UnityEngine.Rendering.PostProcessing;
#endif
namespace Gaia
{
[ExecuteInEditMode]
public class GaiaPostProcessBiome : MonoBehaviour
{
[HideInInspector]
public string PostProcessingFileName;
#if UNITY_POST_PROCESSING_STACK_V2
[Header("Global Settings")]
public bool m_removeThisAwake = true;
public PostProcessProfile m_postProcessProfile;
public PostProcessVolume m_postProcessVolume;
public float m_blendDistance;
public float m_priority;
[Header("Trigger")]
public BoxCollider m_triggerCollider;
public Vector3 m_triggerSize;
private void Awake()
{
if (Application.isPlaying)
{
if (m_removeThisAwake)
{
Destroy(this);
}
}
}
private void LateUpdate()
{
if (!Application.isPlaying)
{
if (m_postProcessVolume != null)
{
m_postProcessVolume.blendDistance = m_blendDistance;
m_postProcessVolume.priority = m_priority;
if (m_postProcessProfile != null)
{
if (m_postProcessVolume.sharedProfile != m_postProcessProfile)
{
m_postProcessVolume.sharedProfile = m_postProcessProfile;
}
}
}
else
{
m_postProcessVolume = GetComponent<PostProcessVolume>();
}
if (m_triggerCollider != null)
{
m_triggerCollider.size = m_triggerSize;
}
else
{
m_triggerCollider = GetComponent<BoxCollider>();
}
}
}
#endif
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f6eb838d53a16d24885018cb5a33169d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,213 @@
using UnityEngine;
namespace Gaia
{
/// <summary>
/// Contains all the shader ID's for all shaders needed for weather and water
/// </summary>
public static class GaiaShaderID
{
//PW Sky
public static readonly int m_cloudFade;
public static readonly int m_cloudBrightness;
public static readonly int m_cloudAmbientColor;
public static readonly int m_SunDirection;
public static readonly int m_SunColor;
public static readonly int m_cloudDomeBrightness;
public static readonly int m_cloudSunDirection;
public static readonly int m_skySunDirection;
public static readonly int m_cloudOpacity;
public static readonly int m_cloudDomeFogColor;
public static readonly int m_cloudDomeSunColor;
public static readonly int m_cloudDomeFinalCloudColor;
public static readonly int m_cloudDomeFinalSkyColor;
public static readonly int m_cloudHeightDensity;
public static readonly int m_cloudHeightThickness;
public static readonly int m_cloudSpeed;
public static readonly int m_pwSkyFogHeight;
public static readonly int m_pwSkyFogGradient;
public static readonly string m_cloudShaderName = "PWS/VFX/PW_SkydomeCloudsHight";
public static readonly string m_pwSkySkyboxShader = "PWS/Skybox/PW_Procedural";
//PW VFX
public static readonly int m_rainIntensity;
public static readonly int m_weatherMainColor;
public static readonly int m_weatherColor;
//PW Water
public static readonly int m_waterDepthRamp;
public static readonly int m_waterSmoothness;
public static readonly int m_waterFoamTex;
public static readonly int m_waterFoamTexTiling;
public static readonly int m_waterFoamRampAlpha;
public static readonly int m_waterFoamDepth;
public static readonly int m_waterTransparentDepth;
public static readonly int m_waterReflectionDistortion;
public static readonly int m_waterReflectionStrength;
public static readonly int m_waterWaveShoreMove;
public static readonly int m_waterMetallic;
public static readonly string m_waterGrabPass = "GrabPass";
public static readonly int m_underwaterColor;
public static readonly int InvViewProjection;
public static readonly int CameraRoll;
public static readonly int _normalLayer0_ID;
public static readonly int _normalLayer1_ID;
public static readonly int _normalLayer2_ID;
public static readonly int _normalLayer0Scale_ID;
public static readonly int _normalLayer1Scale_ID;
public static readonly int _normalLayer2Scale_ID;
public static readonly int _normalSpeed_ID;
public static readonly int _normalFadeStart_ID;
public static readonly int _normalFadeDistance_ID;
public static readonly int _normalTile_ID;
public static readonly int _waveShoreClamp_ID;
public static readonly int _waveLength_ID;
public static readonly int _waveSteepness_ID;
public static readonly int _waveSpeed_ID;
public static readonly int _waveDirection_ID;
public static readonly int _edgeWaterColor_ID;
public static readonly int _edgeWaterDist_ID;
public static readonly string _cbufName = "Echo_Refaction";
public static readonly int _grabID = 0;
public static readonly int m_foamBubblesTexture;
public static readonly int m_foamBubblesScale;
public static readonly int m_foamBubblesTiling;
public static readonly int m_foamStrength;
public static readonly int m_foamBubblesStrength;
public static readonly int m_foamEdge;
public static readonly int m_foamMoveSpeed;
public static readonly string m_cameraOpaqueTexture = "_CameraOpaqueTexture";
public static readonly string m_refractionOn = "_PW_MC_REFRACTION_ON";
public static readonly string m_refractionOff = "_PW_MC_REFRACTION_OFF";
public static readonly int m_blendSRC;
public static readonly int m_blendDST;
//PW GlobalGlobal
public static readonly int m_globalLightDirection;
public static readonly int m_globalLightColor;
public static readonly int m_globalLightIntensity;
public static readonly int m_globalLightSpecColor;
public static readonly int m_globalWind;
public static readonly int m_globalReflectionTexture;
public static readonly int m_globalAmbientColor;
public static readonly int m_hdrpZTest;
//Unity Skybox
public static readonly string m_unitySkyboxShader = "PWS/Skybox/PW_Procedural";
public static readonly string m_unitySkyboxShaderHDRI = "PWS/Skybox/PW_HDRI";
public static readonly int m_unitySkyboxGroundColor;
public static readonly int m_unitySkyboxAtmosphereThickness;
public static readonly int m_unitySkyboxSunSize;
public static readonly int m_unitySkyboxSunSizeConvergence;
public static readonly int m_unitySkyboxTint;
public static readonly int m_unitySkyboxTintHDRI;
public static readonly int m_unitySkyboxCubemap;
public static readonly int m_unitySkyboxExposure;
public static readonly int m_unitySkyboxRotation;
public static readonly int m_unitySkyboxSunDisk;
public static readonly string m_unitySunQualityKeyword = "_SUNDISK_HIGH_QUALITY";
//Check strings
public static readonly string m_checkNameSpace = "Space";
public static readonly string m_checkCloudHeight = "CloudsHight";
//Water Shaders
public static readonly string BuiltInWaterShader = "PWS/PW_Water";
public static readonly string HDRPWaterShader = "Shader Graphs/PW_Water_RP";
public static readonly string HDRPWaterShaderFile = "PW_Water_RP";
static GaiaShaderID()
{
//PW Sky
m_cloudFade = Shader.PropertyToID(("PW_Clouds_Fade"));
m_cloudBrightness = Shader.PropertyToID(("PW_Cloud_Brightness"));
m_cloudAmbientColor = Shader.PropertyToID(("PW_AmbientColor"));
m_SunDirection = Shader.PropertyToID(("PW_SunDirection"));
m_SunColor = Shader.PropertyToID(("PW_SunColor"));
m_cloudDomeBrightness = Shader.PropertyToID(("PW_SkyDome_Brightness"));
m_cloudSunDirection = Shader.PropertyToID(("PW_SunDirection_Clouds_HA"));
m_skySunDirection = Shader.PropertyToID(("PW_SunDirection_Sky"));
m_cloudOpacity = Shader.PropertyToID(("PW_Clouds_Opacity"));
m_cloudDomeFogColor = Shader.PropertyToID(("PW_SkyDome_Fog_Color"));
m_cloudDomeSunColor = Shader.PropertyToID(("PW_SkyDome_Sun_Color"));
m_cloudDomeFinalCloudColor = Shader.PropertyToID(("PW_SkyDome_FinalClouds_Color"));
m_cloudDomeFinalSkyColor = Shader.PropertyToID(("PW_SkyDome_FinalSky_Color"));
m_cloudHeightDensity = Shader.PropertyToID(("PW_Clouds_Hight_Density"));
m_cloudHeightThickness = Shader.PropertyToID(("PW_Clouds_Hight_Thickness"));
m_cloudSpeed = Shader.PropertyToID(("PW_Clouds_Speed_HA"));
m_pwSkyFogHeight = Shader.PropertyToID(("_FogHeight"));
m_pwSkyFogGradient = Shader.PropertyToID(("_FogGradient"));
//PW VFX
m_rainIntensity = Shader.PropertyToID(("_PW_VFX_Weather_Intensity"));
m_weatherMainColor = Shader.PropertyToID(("_MainColor"));
m_weatherColor = Shader.PropertyToID(("_Color"));
//PW Water
m_waterDepthRamp = Shader.PropertyToID(("_WaterDepthRamp"));
m_waterSmoothness = Shader.PropertyToID(("_Smoothness"));
m_waterFoamTex = Shader.PropertyToID(("_FoamTex"));
m_waterFoamTexTiling = Shader.PropertyToID(("_FoamTexTile"));
m_waterFoamRampAlpha = Shader.PropertyToID(("_FoamRampAlpha"));
m_waterFoamDepth = Shader.PropertyToID(("_FoamDepth"));
m_waterTransparentDepth = Shader.PropertyToID(("_TransparentDepth"));
m_waterReflectionDistortion = Shader.PropertyToID(("_ReflectionDistortion"));
m_waterReflectionStrength = Shader.PropertyToID(("_ReflectionStrength"));
m_waterWaveShoreMove = Shader.PropertyToID(("_WaveShoreMove"));
m_waterMetallic = Shader.PropertyToID(("_Metallic"));
m_underwaterColor = Shader.PropertyToID("_UnderWaterColor");
InvViewProjection = Shader.PropertyToID("_InvViewProjection");
CameraRoll = Shader.PropertyToID("_CameraRoll");
_normalLayer0_ID = Shader.PropertyToID("_NormalLayer0");
_normalLayer1_ID = Shader.PropertyToID("_NormalLayer1");
_normalLayer2_ID = Shader.PropertyToID("_NormalLayer2");
_normalLayer0Scale_ID = Shader.PropertyToID("_NormalLayer0Scale");
_normalLayer1Scale_ID = Shader.PropertyToID("_NormalLayer1Scale");
_normalLayer2Scale_ID = Shader.PropertyToID("_NormalLayer2Scale");
_normalSpeed_ID = Shader.PropertyToID("_NormalSpeed");
_normalFadeStart_ID = Shader.PropertyToID("_NormalFadeStart");
_normalFadeDistance_ID = Shader.PropertyToID("_NormalFadeDistance");
_normalTile_ID = Shader.PropertyToID("_NormalTile");
_waveShoreClamp_ID = Shader.PropertyToID("_WaveShoreClamp");
_waveLength_ID = Shader.PropertyToID("_WaveLength");
_waveSteepness_ID = Shader.PropertyToID("_WaveSteepness");
_waveSpeed_ID = Shader.PropertyToID("_WaveSpeed");
_waveDirection_ID = Shader.PropertyToID("_WaveDirection");
_edgeWaterColor_ID = Shader.PropertyToID("_EdgeWaterColor");
_edgeWaterDist_ID = Shader.PropertyToID("_EdgeWaterDist");
_grabID = Shader.PropertyToID ( "_EchoTemp");
m_foamBubblesTexture = Shader.PropertyToID ( "_FoamBubbles");
m_foamBubblesScale = Shader.PropertyToID ( "_FoamBubblesScale");
m_foamBubblesTiling = Shader.PropertyToID ( "_FoamBubblesTile");
m_foamStrength = Shader.PropertyToID ( "_FoamStrength");
m_foamBubblesStrength = Shader.PropertyToID ( "_FoamBubblesStrength");
m_foamEdge = Shader.PropertyToID ( "_FoamEdge");
m_foamMoveSpeed = Shader.PropertyToID ( "_FoamMoveSpeed");
m_blendSRC = Shader.PropertyToID ("_PW_SrcBlend");
m_blendDST = Shader.PropertyToID ("_PW_DstBlend");
//PW Global
m_globalLightDirection = Shader.PropertyToID(("_PW_MainLightDir"));
m_globalLightColor = Shader.PropertyToID(("_PW_MainLightColor"));
m_globalLightIntensity = Shader.PropertyToID(("_PW_MainLightIntensity"));
m_globalLightSpecColor = Shader.PropertyToID(("_PW_MainLightSpecular"));
m_globalWind = Shader.PropertyToID(("_WaveDirection"));
m_globalReflectionTexture = Shader.PropertyToID(("_ReflectionTex"));
m_globalAmbientColor = Shader.PropertyToID(("_AmbientColor"));
m_hdrpZTest = Shader.PropertyToID(("_ZTestTransparent"));
//Unity Skybox
m_unitySkyboxGroundColor = Shader.PropertyToID(("_GroundColor"));
m_unitySkyboxAtmosphereThickness = Shader.PropertyToID(("_AtmosphereThickness"));
m_unitySkyboxSunDisk = Shader.PropertyToID(("_SunDisk"));
m_unitySkyboxSunSize = Shader.PropertyToID(("_SunSize"));
m_unitySkyboxSunSizeConvergence = Shader.PropertyToID(("_SunSizeConvergence"));
m_unitySkyboxTint = Shader.PropertyToID(("_SkyTint"));
m_unitySkyboxTintHDRI = Shader.PropertyToID(("_Tint"));
m_unitySkyboxCubemap = Shader.PropertyToID(("_Tex"));
m_unitySkyboxExposure = Shader.PropertyToID(("_Exposure"));
m_unitySkyboxRotation = Shader.PropertyToID(("_Rotation"));
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e49b358574224ec408d5885d322ad51c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,26 @@
using UnityEngine;
namespace Gaia
{
public class PWSkyPostProcessingManager : MonoBehaviour
{
public void DisableWeatherPostFX()
{
#if GAIA_PRO_PRESENT
if (ProceduralWorldsGlobalWeather.Instance != null)
{
ProceduralWorldsGlobalWeather.Instance.m_modifyPostProcessing = false;
}
#endif
}
public void EnableWeatherPostFX()
{
#if GAIA_PRO_PRESENT
if (ProceduralWorldsGlobalWeather.Instance != null)
{
ProceduralWorldsGlobalWeather.Instance.m_modifyPostProcessing = true;
}
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2f67ba8e9d41eb84fb82199a9931c742
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,144 @@
using UnityEngine;
using UnityEditor;
#if HDPipeline
using UnityEngine.Rendering.HighDefinition;
#endif
using System.Collections.Generic;
using ProceduralWorlds.WaterSystem;
using System;
using UnityEngine.Rendering;
namespace Gaia
{
public static class ReflectionProbeUtils
{
/// <summary>
/// Creates a single Reflection Probe in the given position
/// </summary>
/// <param name="position"></param>
/// <param name="terrain"></param>
/// <param name="reflectionProbeData"></param>
/// <param name="seaLevelActive"></param>
/// <param name="seaLevel"></param>
/// <param name="parentTransform"></param>
/// <param name="isHDRP"></param>
/// <returns></returns>
public static ReflectionProbe CreateReflectionProbe(Vector3 position, Vector3 size, Terrain terrain, ReflectionProbeData reflectionProbeData, bool seaLevelActive, float seaLevel, Transform parentTransform, bool isHDRP, bool probeCulling = false)
{
GameObject probeObject = new GameObject("Global Generated Reflection Probe");
float sampledHeight = terrain.SampleHeight(position);
ReflectionProbe reflectionProbe = probeObject.AddComponent<ReflectionProbe>();
reflectionProbe.enabled = false;
reflectionProbe.blendDistance = 0f;
reflectionProbe.cullingMask = reflectionProbeData.reflectionprobeCullingMask;
reflectionProbe.farClipPlane = reflectionProbeData.reflectionProbeClipPlaneDistance;
reflectionProbe.mode = reflectionProbeData.reflectionProbeMode;
switch (reflectionProbeData.reflectionProbeRefresh)
{
case GaiaConstants.ReflectionProbeRefreshModePW.OnAwake:
reflectionProbe.refreshMode = ReflectionProbeRefreshMode.OnAwake;
break;
case GaiaConstants.ReflectionProbeRefreshModePW.EveryFrame:
reflectionProbe.refreshMode = ReflectionProbeRefreshMode.EveryFrame;
break;
case GaiaConstants.ReflectionProbeRefreshModePW.ViaScripting:
reflectionProbe.refreshMode = ReflectionProbeRefreshMode.ViaScripting;
break;
case GaiaConstants.ReflectionProbeRefreshModePW.ProbeManager:
reflectionProbe.refreshMode = ReflectionProbeRefreshMode.ViaScripting;
break;
}
if (!seaLevelActive)
{
position.y = 500f + seaLevel + 0.2f;
}
else
{
position.y = sampledHeight + reflectionProbeData.reflectionProbeOffset;
reflectionProbe.center = new Vector3(0f, 0f - reflectionProbeData.reflectionProbeOffset - sampledHeight, 0f);
}
if (position.y < seaLevel)
{
position.y = seaLevel + reflectionProbeData.reflectionProbeOffset;
}
probeObject.transform.position = position;
probeObject.transform.SetParent(parentTransform);
switch (reflectionProbeData.reflectionProbeResolution)
{
case GaiaConstants.ReflectionProbeResolution.Resolution16:
reflectionProbe.resolution = 16;
break;
case GaiaConstants.ReflectionProbeResolution.Resolution32:
reflectionProbe.resolution = 32;
break;
case GaiaConstants.ReflectionProbeResolution.Resolution64:
reflectionProbe.resolution = 64;
break;
case GaiaConstants.ReflectionProbeResolution.Resolution128:
reflectionProbe.resolution = 128;
break;
case GaiaConstants.ReflectionProbeResolution.Resolution256:
reflectionProbe.resolution = 256;
break;
case GaiaConstants.ReflectionProbeResolution.Resolution512:
reflectionProbe.resolution = 512;
break;
case GaiaConstants.ReflectionProbeResolution.Resolution1024:
reflectionProbe.resolution = 1024;
break;
case GaiaConstants.ReflectionProbeResolution.Resolution2048:
reflectionProbe.resolution = 2048;
break;
}
reflectionProbe.shadowDistance = 80f;
reflectionProbe.size = size;
reflectionProbe.timeSlicingMode = reflectionProbeData.reflectionProbeTimeSlicingMode;
reflectionProbe.hdr = true;
reflectionProbe.shadowDistance = reflectionProbeData.reflectionProbeShadowDistance;
//If HDRP
if (isHDRP)
{
#if HDPipeline
HDAdditionalReflectionData reflectionData = probeObject.GetComponent<HDAdditionalReflectionData>();
if (reflectionData == null)
{
reflectionData = probeObject.AddComponent<HDAdditionalReflectionData>();
}
reflectionData.multiplier = 1f;
reflectionData.realtimeMode = ProbeSettings.RealtimeMode.OnEnable;
#endif
}
#if GAIA_PRO_PRESENT
ReflectionProbeCuller culler = reflectionProbe.GetComponent<ReflectionProbeCuller>();
if (probeCulling)
{
if (culler == null)
{
culler = reflectionProbe.gameObject.AddComponent<ReflectionProbeCuller>();
culler.m_probe = reflectionProbe;
culler.Initialize();
}
}
else
{
if (culler != null)
{
GameObject.DestroyImmediate(culler);
}
}
#endif
return reflectionProbe;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 957eede4476a032468e7906e9d02bcfe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: