bool UpdateVolumeProfile(Volume volume, out VisualEnvironment visualEnvironment, out HDRISky sky, ref int volumeProfileHash) { var lookDevVolumeProfile = m_GlobalSettings.GetOrAssignLookDevVolumeProfile(); int newHashCode = lookDevVolumeProfile.GetHashCode(); if (newHashCode != volumeProfileHash) { VolumeProfile oldProfile = volume.sharedProfile; volumeProfileHash = newHashCode; VolumeProfile profile = ScriptableObject.Instantiate(lookDevVolumeProfile); profile.hideFlags = HideFlags.HideAndDontSave; volume.sharedProfile = profile; // Remove potentially existing components in the user profile. if (profile.TryGet(out visualEnvironment)) { profile.Remove <VisualEnvironment>(); } if (profile.TryGet(out sky)) { profile.Remove <HDRISky>(); } // If there was a profile before we needed to re-instantiate the new profile, we need to copy the data over for sky settings. if (oldProfile != null) { if (oldProfile.TryGet(out HDRISky oldSky)) { sky = Object.Instantiate(oldSky); profile.components.Add(sky); } if (oldProfile.TryGet(out VisualEnvironment oldVisualEnv)) { visualEnvironment = Object.Instantiate(oldVisualEnv); profile.components.Add(visualEnvironment); } CoreUtils.Destroy(oldProfile); } else { visualEnvironment = profile.Add <VisualEnvironment>(); visualEnvironment.skyType.Override((int)SkyType.HDRI); visualEnvironment.skyAmbientMode.Override(SkyAmbientMode.Dynamic); sky = profile.Add <HDRISky>(); } return(true); } else { visualEnvironment = null; sky = null; return(false); } }
void IDataProvider.FirstInitScene(StageRuntimeInterface SRI) { Camera camera = SRI.camera; camera.allowHDR = true; var additionalCameraData = camera.gameObject.AddComponent <HDAdditionalCameraData>(); additionalCameraData.clearColorMode = HDAdditionalCameraData.ClearColorMode.Color; additionalCameraData.clearDepth = true; additionalCameraData.backgroundColorHDR = camera.backgroundColor; additionalCameraData.volumeAnchorOverride = camera.transform; additionalCameraData.volumeLayerMask = 1 << 31; //31 is the culling layer used in LookDev Light light = SRI.sunLight; HDAdditionalLightData additionalLightData = light.gameObject.AddComponent <HDAdditionalLightData>(); #if UNITY_EDITOR HDAdditionalLightData.InitDefaultHDAdditionalLightData(additionalLightData); #endif additionalLightData.intensity = 0f; additionalLightData.SetShadowResolution(2048); GameObject volumeGO = SRI.AddGameObject(persistent: true); volumeGO.name = "SkyManagementVolume"; Volume volume = volumeGO.AddComponent <Volume>(); volume.isGlobal = true; volume.priority = float.MaxValue; VolumeProfile profile = ScriptableObject.CreateInstance <VolumeProfile>(); volume.sharedProfile = profile; HDShadowSettings shadows = profile.Add <HDShadowSettings>(); shadows.maxShadowDistance.Override(25f); shadows.cascadeShadowSplitCount.Override(2); VisualEnvironment visualEnvironment = profile.Add <VisualEnvironment>(); visualEnvironment.fogType.Override(FogType.None); HDRISky sky = profile.Add <HDRISky>(); SRI.SRPData = new LookDevDataForHDRP() { additionalCameraData = additionalCameraData, additionalLightData = additionalLightData, visualEnvironment = visualEnvironment, sky = sky, volume = volume }; //[TODO: remove] //temp for debug: show component in scene hierarchy //UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(camera.gameObject, GameObject.Find("Main Camera").scene); //camera.gameObject.hideFlags = HideFlags.None; //UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(volumeGO, GameObject.Find("Main Camera").scene); //volumeGO.hideFlags = HideFlags.None; //UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(light.gameObject, GameObject.Find("Main Camera").scene); //light.gameObject.hideFlags = HideFlags.None; }
bool UpdateVolumeProfile(Volume volume, out VisualEnvironment visualEnvironment, out HDRISky sky) { HDRenderPipelineAsset hdrpAsset = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; if (hdrpAsset.defaultLookDevProfile == null) hdrpAsset.defaultLookDevProfile = hdrpAsset.renderPipelineEditorResources.lookDev.defaultLookDevVolumeProfile; int newHashCode = hdrpAsset.defaultLookDevProfile.GetHashCode(); if (newHashCode != m_LookDevVolumeProfileHash) { VolumeProfile oldProfile = volume.sharedProfile; m_LookDevVolumeProfileHash = newHashCode; VolumeProfile profile = ScriptableObject.Instantiate(hdrpAsset.defaultLookDevProfile); volume.sharedProfile = profile; // Remove potentially existing components in the user profile. if (profile.TryGet(out visualEnvironment)) profile.Remove<VisualEnvironment>(); if (profile.TryGet(out sky)) profile.Remove<HDRISky>(); // If there was a profile before we needed to re-instantiate the new profile, we need to copy the data over for sky settings. if (oldProfile != null) { if (oldProfile.TryGet(out HDRISky oldSky)) { sky = Object.Instantiate(oldSky); profile.components.Add(sky); } if (oldProfile.TryGet(out VisualEnvironment oldVisualEnv)) { visualEnvironment = Object.Instantiate(oldVisualEnv); profile.components.Add(visualEnvironment); } CoreUtils.Destroy(oldProfile); } else { visualEnvironment = profile.Add<VisualEnvironment>(); visualEnvironment.skyType.Override((int)SkyType.HDRI); visualEnvironment.skyAmbientMode.Override(SkyAmbientMode.Dynamic); sky = profile.Add<HDRISky>(); } return true; } else { visualEnvironment = null; sky = null; return false; } }
void IDataProvider.FirstInitScene(StageRuntimeInterface SRI) { Camera camera = SRI.camera; camera.allowHDR = true; var additionalCameraData = camera.gameObject.AddComponent <HDAdditionalCameraData>(); additionalCameraData.clearColorMode = HDAdditionalCameraData.ClearColorMode.Color; additionalCameraData.clearDepth = true; additionalCameraData.backgroundColorHDR = camera.backgroundColor; additionalCameraData.volumeAnchorOverride = camera.transform; additionalCameraData.volumeLayerMask = 1 << 31; //31 is the culling layer used in LookDev additionalCameraData.customRenderingSettings = true; additionalCameraData.renderingPathCustomFrameSettings.SetEnabled(FrameSettingsField.SSR, false); // LookDev cameras are enabled/disabled all the time so history is destroyed each frame. // In this case we know we want to keep history alive as long as the camera is. additionalCameraData.hasPersistentHistory = true; Light light = SRI.sunLight; HDAdditionalLightData additionalLightData = light.gameObject.AddComponent <HDAdditionalLightData>(); #if UNITY_EDITOR HDAdditionalLightData.InitDefaultHDAdditionalLightData(additionalLightData); #endif additionalLightData.intensity = 0f; additionalLightData.SetShadowResolution(2048); GameObject volumeGO = SRI.AddGameObject(persistent: true); volumeGO.name = "SkyManagementVolume"; Volume volume = volumeGO.AddComponent <Volume>(); volume.isGlobal = true; volume.priority = float.MaxValue; VolumeProfile profile = ScriptableObject.CreateInstance <VolumeProfile>(); volume.sharedProfile = profile; HDShadowSettings shadows = profile.Add <HDShadowSettings>(); shadows.maxShadowDistance.Override(25f); shadows.cascadeShadowSplitCount.Override(2); VisualEnvironment visualEnvironment = profile.Add <VisualEnvironment>(); visualEnvironment.skyType.Override((int)SkyType.HDRI); visualEnvironment.skyAmbientMode.Override(SkyAmbientMode.Dynamic); HDRISky sky = profile.Add <HDRISky>(); SRI.SRPData = new LookDevDataForHDRP() { additionalCameraData = additionalCameraData, additionalLightData = additionalLightData, visualEnvironment = visualEnvironment, sky = sky, volume = volume }; }
public void UpdateVolumeProfile(VolumeProfile p) { if (!p.Has <PUnderwaterOverride>()) { p.Add <PUnderwaterOverride>(); } PUnderwaterOverride underwaterSettings; if (p.TryGet <PUnderwaterOverride>(out underwaterSettings)) { underwaterSettings.active = EnableUnderwater; if (EnableUnderwater) { underwaterSettings.waterLevel.Override(UnderwaterWaterLevel); underwaterSettings.maxDepth.Override(UnderwaterMaxDepth); underwaterSettings.surfaceColorBoost.Override(UnderwaterSurfaceColorBoost); underwaterSettings.shallowFogColor.Override(UnderwaterShallowFogColor); underwaterSettings.deepFogColor.Override(UnderwaterDeepFogColor); underwaterSettings.viewDistance.Override(UnderwaterViewDistance); underwaterSettings.enableCaustic.Override(UnderwaterEnableCaustic); underwaterSettings.causticTexture.Override(UnderwaterCausticTexture); underwaterSettings.causticSize.Override(UnderwaterCausticSize); underwaterSettings.causticStrength.Override(UnderwaterCausticStrength); underwaterSettings.enableDistortion.Override(UnderwaterEnableDistortion); underwaterSettings.distortionNormalMap.Override(UnderwaterDistortionTexture); underwaterSettings.distortionStrength.Override(UnderwaterDistortionStrength); underwaterSettings.waterFlowSpeed.Override(UnderwaterWaterFlowSpeed); } } if (!p.Has <PWetLensOverride>()) { p.Add <PWetLensOverride>(); } PWetLensOverride wetLensSettings; if (p.TryGet <PWetLensOverride>(out wetLensSettings)) { wetLensSettings.active = EnableWetLens; if (EnableWetLens) { wetLensSettings.normalMap.Override(WetLensNormalMap); wetLensSettings.strength.Override(WetLensStrength); } } }
protected override void Awake() { if (!postProcessingProfile.TryGet <T>(out setting)) //Try to get the setting { setting = postProcessingProfile.Add <T>(true); //Create it if it can't be found } base.Awake(); }
void IDataProvider.FirstInitScene(StageRuntimeInterface SRI) { Camera camera = SRI.camera; camera.allowHDR = true; var additionalData = camera.gameObject.AddComponent <HDAdditionalCameraData>(); additionalData.clearColorMode = HDAdditionalCameraData.ClearColorMode.Color; additionalData.clearDepth = true; additionalData.backgroundColorHDR = camera.backgroundColor; additionalData.volumeAnchorOverride = camera.transform; additionalData.volumeLayerMask = 1 << 31; //31 is the culling layer used in LookDev GameObject volumeGO = SRI.AddGameObject(persistent: true); volumeGO.name = "SkyManagementVolume"; Volume volume = volumeGO.AddComponent <Volume>(); volume.isGlobal = true; volume.priority = float.MaxValue; VolumeProfile profile = ScriptableObject.CreateInstance <VolumeProfile>(); volume.profile = profile; VisualEnvironment visualEnvironment = profile.Add <VisualEnvironment>(); HDRISky sky = profile.Add <HDRISky>(); SRI.SRPData = new LookDevDataForHDRP() { additionalCameraData = additionalData, visualEnvironment = visualEnvironment, sky = sky, volume = volume }; //temp for debug: show component in scene hierarchy //UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(camera.gameObject, GameObject.Find("Main Camera").scene); //camera.gameObject.hideFlags = HideFlags.None; //UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(volumeGO, GameObject.Find("Main Camera").scene); //volumeGO.hideFlags = HideFlags.None; }
public void RestorePostProcess() { VolumeProfile profile = Volume.sharedProfile; if (!profile.TryGet <ColorAdjustments>(out var ColorAdj)) { ColorAdj = profile.Add <ColorAdjustments>(false); } ColorAdj.saturation.value = 0; }
// Start is called before the first frame update void Start() { // StartCoroutine(blackout()); profile = volume.sharedProfile; if (!profile.TryGet <ColorAdjustments>(out var colorAdjustments)) { colorAdjustments = profile.Add <ColorAdjustments>(false); } FindObjectOfType <AudioManager>().Play("ooo"); }
private void OnEnable() { profile.TryGet(out colorAdjustment); if (colorAdjustment == null) { profile.Add <ColorAdjustments>(); profile.TryGet(out colorAdjustment); colorAdjustment.saturation.overrideState = true; } originalSaturation = colorAdjustment.saturation.value; }
private void Start() { StartCoroutine(GetSettingsWhenInitialized()); cubemapEventListenerSet = onCubemapUpdate.GetPersistentEventCount() > 0; HDCameraData = XRCamera.GetComponent <HDAdditionalCameraData>(); if (!m_skyboxProfile.TryGet(out volumeSky)) { volumeSky = m_skyboxProfile.Add <HDRISky>(true); } if (!m_skyboxProfile.TryGet(out volumeExposure)) { volumeExposure = m_skyboxProfile.Add <Exposure>(true); } if (!m_skyboxProfile.TryGet(out volumeVSTWhiteBalance)) { volumeVSTWhiteBalance = m_skyboxProfile.Add <VSTWhiteBalance>(true); } }
private void Start() { originalOpaqueValue = VarjoRendering.GetOpaque(); VarjoRendering.SetOpaque(false); cubemapEventListenerSet = onCubemapUpdate.GetPersistentEventCount() > 0; HDCameraData = xrCamera.GetComponent <HDAdditionalCameraData>(); if (!m_skyboxProfile.TryGet(out volumeSky)) { volumeSky = m_skyboxProfile.Add <HDRISky>(true); } if (!m_skyboxProfile.TryGet(out volumeExposure)) { volumeExposure = m_skyboxProfile.Add <Exposure>(true); } if (!m_skyboxProfile.TryGet(out volumeVSTWhiteBalance)) { volumeVSTWhiteBalance = m_skyboxProfile.Add <VSTWhiteBalance>(true); } }
public static T CreateVolumeComponent <T>(VolumeProfile profile, bool overrides = false, bool saveAsset = true) where T : VolumeComponent { var comp = profile.Add <T>(overrides); AssetDatabase.AddObjectToAsset(comp, profile); if (saveAsset) { AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } return(comp); }
public void PostProcess() { VolumeProfile profile = Volume.sharedProfile; if (!profile.TryGet <ColorAdjustments>(out var ColorAdj)) { ColorAdj = profile.Add <ColorAdjustments>(false); } if (Health >= 100) { ColorAdj.saturation.value = 0; } else if (Health < 100) { ColorAdj.saturation.value = Health - 100; } }
protected T AddVolumeComponentToAsset <T>(VolumeProfile targetProfileAsset) where T : VolumeComponent { if (!targetProfileAsset) { return(null); } var profilePath = AssetDatabase.GetAssetPath(targetProfileAsset); if (string.IsNullOrEmpty(profilePath)) { return(null); } var newVolumeComponent = targetProfileAsset.Add <T>(); AssetDatabase.AddObjectToAsset(newVolumeComponent, targetProfileAsset); return(newVolumeComponent); }
void Awake() { activeDistance = focusFarDistance; activeExtent = focusFarExtent; activeFalloff = focusFarFalloff; volumeProfile = ScriptableObject.CreateInstance <VolumeProfile>(); volumeProfile.hideFlags = HideFlags.HideAndDontSave; dof = volumeProfile.Add <DepthOfField>(); dof.hideFlags = HideFlags.HideAndDontSave; dof.focusMode.Override(DepthOfFieldMode.Manual); dof.quality.Override((int)ScalableSettingLevelParameter.Level.Medium); dof.nearFocusStart.Override(0.0f); dof.nearFocusEnd.Override(0.0f); dof.farFocusStart.Override(focusFarExtent); dof.farFocusEnd.Override(focusFarExtent); volume = this.gameObject.AddComponent <Volume>(); volume.hideFlags = HideFlags.HideAndDontSave; volume.isGlobal = true; volume.priority = 100; volume.sharedProfile = volumeProfile; }
/// <summary> /// This hook allows HDRP to init the scene when creating the view /// </summary> /// <param name="SRI">The StageRuntimeInterface allowing to communicate with the LookDev</param> void IDataProvider.FirstInitScene(StageRuntimeInterface SRI) { Camera camera = SRI.camera; camera.allowHDR = true; var additionalCameraData = camera.gameObject.AddComponent <HDAdditionalCameraData>(); additionalCameraData.clearColorMode = HDAdditionalCameraData.ClearColorMode.Color; additionalCameraData.clearDepth = true; additionalCameraData.backgroundColorHDR = camera.backgroundColor; additionalCameraData.volumeAnchorOverride = camera.transform; additionalCameraData.volumeLayerMask = 1 << 31; //31 is the culling layer used in LookDev additionalCameraData.customRenderingSettings = true; additionalCameraData.renderingPathCustomFrameSettings.SetEnabled(FrameSettingsField.SSR, false); // LookDev cameras are enabled/disabled all the time so history is destroyed each frame. // In this case we know we want to keep history alive as long as the camera is. additionalCameraData.hasPersistentHistory = true; Light light = SRI.sunLight; HDAdditionalLightData additionalLightData = light.gameObject.AddComponent <HDAdditionalLightData>(); #if UNITY_EDITOR HDAdditionalLightData.InitDefaultHDAdditionalLightData(additionalLightData); #endif additionalLightData.intensity = 0f; additionalLightData.SetShadowResolution(2048); GameObject volumeGO = SRI.AddGameObject(persistent: true); volumeGO.name = "StageVolume"; Volume volume = volumeGO.AddComponent <Volume>(); volume.isGlobal = true; volume.priority = float.MaxValue; volume.enabled = false; #if UNITY_EDITOR HDRenderPipelineAsset hdrpAsset = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; if (hdrpAsset.defaultLookDevProfile == null) { hdrpAsset.defaultLookDevProfile = hdrpAsset.renderPipelineEditorResources.lookDev.defaultLookDevVolumeProfile; } VolumeProfile profile = ScriptableObject.Instantiate(hdrpAsset.defaultLookDevProfile); volume.sharedProfile = profile; VisualEnvironment visualEnvironment; if (profile.TryGet(out visualEnvironment)) { profile.Remove <VisualEnvironment>(); } visualEnvironment = profile.Add <VisualEnvironment>(); visualEnvironment.skyType.Override((int)SkyType.HDRI); visualEnvironment.skyAmbientMode.Override(SkyAmbientMode.Dynamic); HDRISky sky; if (profile.TryGet(out sky)) { profile.Remove <HDRISky>(); } sky = profile.Add <HDRISky>(); SRI.SRPData = new LookDevDataForHDRP() { additionalCameraData = additionalCameraData, additionalLightData = additionalLightData, visualEnvironment = visualEnvironment, sky = sky, volume = volume }; #else //remove unasigned warnings when building SRI.SRPData = new LookDevDataForHDRP() { additionalCameraData = null, additionalLightData = null, visualEnvironment = null, sky = null, volume = null }; #endif }