public AmbientOcclusionSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { m_Settings = hdAsset.currentPlatformRenderPipelineSettings; m_Resources = defaultResources; if (!hdAsset.currentPlatformRenderPipelineSettings.supportSSAO) { return; } AllocRT(0.5f); }
public GBufferManager(HDRenderPipelineAsset asset, RenderPipelineMaterial deferredMaterial) : base(deferredMaterial.GetMaterialGBufferCount(asset)) { Debug.Assert(m_BufferCount <= 8); for (int i = 0; i < m_BufferCount; ++i) { m_RTIDsArray[i] = new RenderTargetIdentifier[i + 1]; } m_DeferredMaterial = deferredMaterial; m_asset = asset; }
void InitializePrepass(HDRenderPipelineAsset hdAsset) { m_DepthResolveMaterial = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.shaders.depthValuesPS); m_GBufferOutput = new GBufferOutput(); m_GBufferOutput.mrt = new TextureHandle[RenderGraph.kMaxMRTCount]; m_DBufferOutput = new DBufferOutput(); m_DBufferOutput.mrt = new TextureHandle[(int)Decal.DBufferMaterial.Count]; m_DepthBufferMipChainInfo = new HDUtils.PackedMipChainInfo(); m_DepthBufferMipChainInfo.Allocate(); }
public override void GetMaterialGBufferDescription(HDRenderPipelineAsset asset, out GraphicsFormat[] RTFormat, out GBufferUsage[] gBufferUsage, out bool[] enableWrite) { int gBufferCount; bool supportShadowMask; bool supportLightLayers; GetGBufferOptions(asset, out gBufferCount, out supportShadowMask, out supportLightLayers); RTFormat = new GraphicsFormat[gBufferCount]; gBufferUsage = new GBufferUsage[gBufferCount]; enableWrite = new bool[gBufferCount]; RTFormat[0] = GraphicsFormat.R8G8B8A8_SRGB; // Albedo sRGB / SSSBuffer gBufferUsage[0] = GBufferUsage.SubsurfaceScattering; enableWrite[0] = true; RTFormat[1] = GraphicsFormat.R8G8B8A8_UNorm; // Normal Buffer gBufferUsage[1] = GBufferUsage.Normal; enableWrite[1] = true; // normal buffer is used as RWTexture to composite decals in forward RTFormat[2] = GraphicsFormat.R8G8B8A8_UNorm; // Data gBufferUsage[2] = GBufferUsage.None; enableWrite[2] = true; RTFormat[3] = Builtin.GetLightingBufferFormat(); gBufferUsage[3] = GBufferUsage.None; enableWrite[3] = true; #if ENABLE_VIRTUALTEXTURES int index = 4; RTFormat[index] = VTBufferManager.GetFeedbackBufferFormat(); gBufferUsage[index] = GBufferUsage.VTFeedback; enableWrite[index] = false; index++; #else int index = 4; #endif if (supportLightLayers) { RTFormat[index] = GraphicsFormat.R8G8B8A8_UNorm; gBufferUsage[index] = GBufferUsage.LightLayers; index++; } // All buffer above are fixed. However shadow mask buffer can be setup or not depends on light in view. // Thus it need to be the last one, so all indexes stay the same if (supportShadowMask) { RTFormat[index] = Builtin.GetShadowMaskBufferFormat(); gBufferUsage[index] = GBufferUsage.ShadowMask; index++; } }
public override void Build(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; // Create Materials m_preIntegratedFGDMaterial_Ward = CoreUtils.CreateEngineMaterial(defaultResources.shaders.preIntegratedFGD_WardPS); if (m_preIntegratedFGDMaterial_Ward == null) { throw new Exception("Failed to create material for Ward BRDF pre-integration!"); } m_preIntegratedFGDMaterial_CookTorrance = CoreUtils.CreateEngineMaterial(defaultResources.shaders.preIntegratedFGD_CookTorrancePS); if (m_preIntegratedFGDMaterial_CookTorrance == null) { throw new Exception("Failed to create material for Cook-Torrance BRDF pre-integration!"); } // Create render textures where we will render the FGD tables m_preIntegratedFGD_Ward = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear); m_preIntegratedFGD_Ward.hideFlags = HideFlags.HideAndDontSave; m_preIntegratedFGD_Ward.filterMode = FilterMode.Bilinear; m_preIntegratedFGD_Ward.wrapMode = TextureWrapMode.Clamp; m_preIntegratedFGD_Ward.hideFlags = HideFlags.DontSave; m_preIntegratedFGD_Ward.name = CoreUtils.GetRenderTargetAutoName(128, 128, 1, RenderTextureFormat.ARGB2101010, "PreIntegratedFGD_Ward"); m_preIntegratedFGD_Ward.Create(); m_preIntegratedFGD_CookTorrance = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear); m_preIntegratedFGD_CookTorrance.hideFlags = HideFlags.HideAndDontSave; m_preIntegratedFGD_CookTorrance.filterMode = FilterMode.Bilinear; m_preIntegratedFGD_CookTorrance.wrapMode = TextureWrapMode.Clamp; m_preIntegratedFGD_CookTorrance.hideFlags = HideFlags.DontSave; m_preIntegratedFGD_CookTorrance.name = CoreUtils.GetRenderTargetAutoName(128, 128, 1, RenderTextureFormat.ARGB2101010, "PreIntegratedFGD_CookTorrance"); m_preIntegratedFGD_CookTorrance.Create(); // LTC data m_LtcData = new Texture2DArray(LTCAreaLight.k_LtcLUTResolution, LTCAreaLight.k_LtcLUTResolution, 3, TextureFormat.RGBAHalf, false /*mipmap*/, true /* linear */) { hideFlags = HideFlags.HideAndDontSave, wrapMode = TextureWrapMode.Clamp, filterMode = FilterMode.Bilinear, name = CoreUtils.GetTextureAutoName(LTCAreaLight.k_LtcLUTResolution, LTCAreaLight.k_LtcLUTResolution, TextureFormat.RGBAHalf, depth: 2, dim: TextureDimension.Tex2DArray, name: "LTC_LUT") }; // Caution: This need to match order define in AxFLTCAreaLight LTCAreaLight.LoadLUT(m_LtcData, 0, TextureFormat.RGBAHalf, LTCAreaLight.s_LtcMatrixData_GGX); m_LtcData.Apply(); }
//Initialization of builder public void Initialize(HDRenderPipelineAsset asset, HDShadowManager shadowManager, HDRenderPipeline.LightLoopTextureCaches textureCaches) { m_Asset = asset; m_TextureCaches = textureCaches; m_ShadowManager = shadowManager; // Screen space shadow int numMaxShadows = Math.Max(m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.maxScreenSpaceShadowSlots, 1); m_CurrentScreenSpaceShadowData = new HDRenderPipeline.ScreenSpaceShadowData[numMaxShadows]; //Allocate all the GPU critical buffers, for the case were there are no lights. //This ensures we can bind an empty buffer on ComputeBuffer SetData() call AllocateLightData(0, 0); }
public AmbientOcclusionSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { m_Settings = hdAsset.currentPlatformRenderPipelineSettings; m_Resources = defaultResources; #if ENABLE_RAYTRACING m_RTResources = hdAsset.renderPipelineRayTracingResources; #endif if (!hdAsset.currentPlatformRenderPipelineSettings.supportSSAO) { return; } AllocRT(0.5f); }
public void Build(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources, IBLFilterBSDF[] iblFilterBSDFArray) { m_SkyRenderingContext = new SkyRenderingContext(iblFilterBSDFArray, (int)hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize, true); #if UNITY_EDITOR m_PreviewSkyRenderingContext = new SkyRenderingContext(iblFilterBSDFArray, (int)hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize, true); #endif m_StandardSkyboxMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.skyboxCubemapPS); m_BlitCubemapMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.blitCubemapPS); m_OpaqueAtmScatteringMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.opaqueAtmosphericScatteringPS); m_OpaqueAtmScatteringBlock = new MaterialPropertyBlock(); m_LightingOverrideVolumeStack = VolumeManager.instance.CreateStack(); m_LightingOverrideLayerMask = hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyLightingOverrideLayerMask; m_StaticLightingSkyRenderingContext = new SkyRenderingContext(iblFilterBSDFArray, (int)hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize, false); }
void InitializePrepass(HDRenderPipelineAsset hdAsset) { m_DepthResolveMaterial = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.shaders.depthValuesPS); m_GBufferOutput = new GBufferOutput(); m_GBufferOutput.mrt = new TextureHandle[RenderGraph.kMaxMRTCount]; m_DBufferOutput = new DBufferOutput(); m_DBufferOutput.mrt = new TextureHandle[(int)Decal.DBufferMaterial.Count]; m_DepthBufferMipChainInfo = new HDUtils.PackedMipChainInfo(); m_DepthBufferMipChainInfo.Allocate(); m_DepthPyramidDesc = new TextureDesc(ComputeDepthBufferMipChainSize, true, true) { colorFormat = GraphicsFormat.R32_SFloat, enableRandomWrite = true, name = "CameraDepthBufferMipChain" }; }
/// <summary>Register FrameSettingsHistory for DebugMenu</summary> public static IDebugData RegisterDebug(Camera camera, HDAdditionalCameraData additionalCameraData) { HDRenderPipelineAsset hdrpAsset = GraphicsSettings.currentRenderPipeline as HDRenderPipelineAsset; var defaultHdrpAsset = HDRenderPipeline.defaultAsset; Assertions.Assert.IsNotNull(hdrpAsset); // complete frame settings history is required for displaying debug menu. // AggregateFrameSettings will finish the registration if it is not yet registered FrameSettings registering = new FrameSettings(); AggregateFrameSettings(ref registering, camera, additionalCameraData, hdrpAsset, defaultHdrpAsset); GenerateFrameSettingsPanel(camera.name, frameSettingsHistory[camera]); #if UNITY_EDITOR if (sceneViewCamera == null && camera.cameraType == CameraType.SceneView) { sceneViewCamera = camera; } #endif return(frameSettingsHistory[camera]); }
public LightCookieManager(HDRenderPipelineAsset hdAsset, int maxCacheSize) { // Keep track of the render pipeline asset m_RenderPipelineAsset = hdAsset; var hdResources = HDRenderPipeline.defaultAsset.renderPipelineResources; // Create the texture cookie cache that we shall be using for the area lights GlobalLightLoopSettings gLightLoopSettings = hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings; // Also make sure to create the engine material that is used for the filtering m_MaterialFilterAreaLights = CoreUtils.CreateEngineMaterial(hdResources.shaders.filterAreaLightCookiesPS); int cookieAtlasSize = (int)gLightLoopSettings.cookieAtlasSize; cookieFormat = (GraphicsFormat)gLightLoopSettings.cookieFormat; cookieAtlasLastValidMip = gLightLoopSettings.cookieAtlasLastValidMip; m_CookieAtlas = new PowerOfTwoTextureAtlas(cookieAtlasSize, gLightLoopSettings.cookieAtlasLastValidMip, cookieFormat, name: "Cookie Atlas (Punctual Lights)", useMipMap: true); m_CookieCubeResolution = (int)gLightLoopSettings.pointCookieSize; }
public LightCookieManager(HDRenderPipelineAsset hdAsset, int maxCacheSize) { // Keep track of the render pipeline asset m_RenderPipelineAsset = hdAsset; var hdResources = HDRenderPipeline.defaultAsset.renderPipelineResources; // Create the texture cookie cache that we shall be using for the area lights GlobalLightLoopSettings gLightLoopSettings = hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings; // Also make sure to create the engine material that is used for the filtering m_MaterialFilterAreaLights = CoreUtils.CreateEngineMaterial(hdResources.shaders.filterAreaLightCookiesPS); int cookieCubeSize = gLightLoopSettings.cubeCookieTexArraySize; int cookieAtlasSize = (int)gLightLoopSettings.cookieAtlasSize; cookieFormat = (GraphicsFormat)gLightLoopSettings.cookieFormat; cookieAtlasLastValidMip = gLightLoopSettings.cookieAtlasLastValidMip; if (PowerOfTwoTextureAtlas.GetApproxCacheSizeInByte(1, cookieAtlasSize, true, cookieFormat) > HDRenderPipeline.k_MaxCacheSize) { cookieAtlasSize = PowerOfTwoTextureAtlas.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, true, cookieFormat); } m_CookieAtlas = new PowerOfTwoTextureAtlas(cookieAtlasSize, gLightLoopSettings.cookieAtlasLastValidMip, cookieFormat, name: "Cookie Atlas (Punctual Lights)", useMipMap: true); m_CubeToPanoMaterial = CoreUtils.CreateEngineMaterial(hdResources.shaders.cubeToPanoPS); m_CubeCookieTexArray = new TextureCacheCubemap("Cookie"); int cookieCubeResolution = (int)gLightLoopSettings.pointCookieSize; if (TextureCacheCubemap.GetApproxCacheSizeInByte(cookieCubeSize, cookieCubeResolution, 1) > HDRenderPipeline.k_MaxCacheSize) { cookieCubeSize = TextureCacheCubemap.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, cookieCubeResolution, 1); } // For now the cubemap cookie array format is hardcoded to R8G8B8A8 SRGB. m_CubeCookieTexArray.AllocTextureArray(cookieCubeSize, cookieCubeResolution, cookieFormat, true, m_CubeToPanoMaterial); }
public void Build(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources, IBLFilterBSDF[] iblFilterBSDFArray) { var hdrp = HDRenderPipeline.defaultAsset; m_Resolution = (int)hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize; m_IBLFilterArray = iblFilterBSDFArray; m_StandardSkyboxMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.skyboxCubemapPS); m_BlitCubemapMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.blitCubemapPS); m_OpaqueAtmScatteringMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.opaqueAtmosphericScatteringPS); m_OpaqueAtmScatteringBlock = new MaterialPropertyBlock(); m_ComputeAmbientProbeCS = hdrp.renderPipelineResources.shaders.ambientProbeConvolutionCS; m_ComputeAmbientProbeKernel = m_ComputeAmbientProbeCS.FindKernel("AmbientProbeConvolution"); lightingOverrideVolumeStack = VolumeManager.instance.CreateStack(); lightingOverrideLayerMask = hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyLightingOverrideLayerMask; int resolution = (int)hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize; m_SkyboxBSDFCubemapIntermediate = RTHandles.Alloc(resolution, resolution, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureDimension.Cube, useMipMap: true, autoGenerateMips: false, filterMode: FilterMode.Trilinear, name: "SkyboxBSDFIntermediate"); m_CubemapScreenSize = new Vector4((float)resolution, (float)resolution, 1.0f / (float)resolution, 1.0f / (float)resolution); var cubeProj = Matrix4x4.Perspective(90.0f, 1.0f, 0.01f, 1.0f); for (int i = 0; i < 6; ++i) { var lookAt = Matrix4x4.LookAt(Vector3.zero, CoreUtils.lookAtList[i], CoreUtils.upVectorList[i]); var worldToView = lookAt * Matrix4x4.Scale(new Vector3(1.0f, 1.0f, -1.0f)); // Need to scale -1.0 on Z to match what is being done in the camera.wolrdToCameraMatrix API. ... m_facePixelCoordToViewDirMatrices[i] = HDUtils.ComputePixelCoordToWorldSpaceViewDirectionMatrix(0.5f * Mathf.PI, Vector2.zero, m_CubemapScreenSize, worldToView, true); m_CameraRelativeViewMatrices[i] = worldToView; } InitializeBlackCubemapArray(); }
static ObservableList <DebugUI.Widget> GenerateHistoryArea(HDRenderPipelineAsset defaultHdrpAsset, ref FrameSettingsHistory frameSettings, int groupIndex) { if (!attributesGroup.ContainsKey(groupIndex) || attributesGroup[groupIndex] == null) { attributesGroup[groupIndex] = attributes?.Where(pair => pair.Value?.group == groupIndex)?.OrderBy(pair => pair.Value.orderInGroup); } if (!attributesGroup.ContainsKey(groupIndex)) { throw new ArgumentException("Unknown groupIndex"); } var area = new ObservableList <DebugUI.Widget>(); foreach (var field in attributesGroup[groupIndex]) { switch (field.Value.type) { case FrameSettingsFieldAttribute.DisplayType.BoolAsCheckbox: area.Add(GenerateHistoryBoolField(defaultHdrpAsset, ref frameSettings, field.Key, field.Value)); break; case FrameSettingsFieldAttribute.DisplayType.BoolAsEnumPopup: area.Add(GenerateHistoryEnumField( defaultHdrpAsset, ref frameSettings, field.Key, field.Value, RetrieveEnumTypeByField(field.Key) )); break; case FrameSettingsFieldAttribute.DisplayType.Others: // for now, skip other display settings. Add them if needed break; } } return(area); }
public void Init(HDRenderPipelineAsset asset, SkyManager skyManager, HDRaytracingManager raytracingManager, SharedRTManager sharedRTManager) { // Keep track of the pipeline asset m_PipelineAsset = asset; m_PipelineResources = asset.renderPipelineResources; // Keep track of the sky manager m_SkyManager = skyManager; // keep track of the ray tracing manager m_RaytracingManager = raytracingManager; // Keep track of the shared rt manager m_SharedRTManager = sharedRTManager; m_RaytracingFlagTarget = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R8_SNorm, enableRandomWrite: true, useMipMap: false, name: "RaytracingFlagTexture"); m_DebugRaytracingTexture = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "DebugRaytracingBuffer"); m_RaytracingFlagStateBlock = new RenderStateBlock { depthState = new DepthState(false, CompareFunction.LessEqual), mask = RenderStateMask.Depth }; }
/// <summary>Same than FrameSettings.AggregateFrameSettings but keep history of agregation in a collection for DebugMenu. /// Aggregation is default with override of the renderer then sanitazed depending on supported features of hdrpasset. Then the DebugMenu override occurs.</summary> /// <param name="aggregatedFrameSettings">The aggregated FrameSettings result.</param> /// <param name="camera">The camera rendering.</param> /// <param name="additionalData">Additional data of the camera rendering.</param> /// <param name="hdrpAsset">HDRenderPipelineAsset contening default FrameSettings.</param> public static void AggregateFrameSettings(ref FrameSettings aggregatedFrameSettings, Camera camera, HDAdditionalCameraData additionalData, HDRenderPipelineAsset hdrpAsset, HDRenderPipelineAsset defaultHdrpAsset) => AggregateFrameSettings( ref aggregatedFrameSettings, camera, additionalData, ref defaultHdrpAsset.GetDefaultFrameSettings(additionalData?.defaultFrameSettings ?? FrameSettingsRenderType.Camera), //fallback on Camera for SceneCamera and PreviewCamera hdrpAsset.currentPlatformRenderPipelineSettings );
internal static void MigrateFromHDRPAsset(HDRenderPipelineAsset oldAsset) { assetToBeMigrated = oldAsset; }
public virtual void GetMaterialGBufferDescription(HDRenderPipelineAsset asset, out GraphicsFormat[] RTFormat, out GBufferUsage[] gBufferUsage, out bool[] enableWrite) { RTFormat = null; gBufferUsage = null; enableWrite = null; }
public virtual int GetMaterialGBufferCount(HDRenderPipelineAsset asset) { return(0); }
public VTBufferManager(HDRenderPipelineAsset asset) { downSampleCS = asset.renderPipelineResources.shaders.VTFeedbackDownsample; }
internal AmbientOcclusionSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { m_Settings = hdAsset.currentPlatformRenderPipelineSettings; m_Resources = defaultResources; }
public override void Build(HDRenderPipelineAsset hdAsset, HDRenderPipelineRuntimeResources defaultResources) { PreIntegratedFGD.instance.Build(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse); LTCAreaLight.instance.Build(); PreIntegratedAzimuthalScattering.instance.Build(); }
// Regular interface public virtual void Build(HDRenderPipelineAsset hdAsset, HDRenderPipelineRuntimeResources defaultResources) { }
public void Build(HDRenderPipelineAsset hdAsset) { }
public void InitializeHDRPResouces(HDRenderPipelineAsset asset) { m_ClearPropertyMaskBufferShader = asset.renderPipelineResources.shaders.decalClearPropertyMaskBufferCS; m_ClearPropertyMaskBufferKernel = m_ClearPropertyMaskBufferShader.FindKernel("CSMain"); }
/// <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 }
public override void Build(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { PreIntegratedFGD.instance.Build(PreIntegratedFGD.FGDIndex.FGD_CharlieAndFabricLambert); //LTCAreaLight.instance.Build(); }
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); } }
public override void Build(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { PreIntegratedFGD.instance.Build(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse); LTCAreaLight.instance.Build(); SPTDistribution.instance.Build(); }
internal static HDRenderPipelineGlobalSettings MigrateFromHDRPAsset(HDRenderPipelineAsset oldAsset, string path, bool bClearObsoleteFields = true, bool canCreateNewAsset = true) { HDRenderPipelineGlobalSettings assetCreated = null; // 1. Load or Create the HDAsset and save it on disk assetCreated = AssetDatabase.LoadAssetAtPath <HDRenderPipelineGlobalSettings>(path); if (assetCreated == null) { if (!canCreateNewAsset) { Debug.LogError("Cannot migrate HDRP Asset to a new HDRP Global Settings asset. If you are building a Player, make sure to save an HDRP Global Settings asset by opening the project in the Editor."); return(null); } if (!AssetDatabase.IsValidFolder("Assets/HDRPDefaultResources/")) { AssetDatabase.CreateFolder("Assets", "HDRPDefaultResources"); } assetCreated = ScriptableObject.CreateInstance <HDRenderPipelineGlobalSettings>(); AssetDatabase.CreateAsset(assetCreated, path); assetCreated.Init(); } #pragma warning disable 618 // Type or member is obsolete //2. Migrate obsolete assets (version DefaultSettingsAsAnAsset) assetCreated.volumeProfile = oldAsset.m_ObsoleteDefaultVolumeProfile; assetCreated.volumeProfileLookDev = oldAsset.m_ObsoleteDefaultLookDevProfile; assetCreated.m_RenderingPathDefaultCameraFrameSettings = oldAsset.m_ObsoleteFrameSettingsMovedToDefaultSettings; assetCreated.m_RenderingPathDefaultBakedOrCustomReflectionFrameSettings = oldAsset.m_ObsoleteBakedOrCustomReflectionFrameSettingsMovedToDefaultSettings; assetCreated.m_RenderingPathDefaultRealtimeReflectionFrameSettings = oldAsset.m_ObsoleteRealtimeReflectionFrameSettingsMovedToDefaultSettings; assetCreated.m_RenderPipelineResources = oldAsset.m_ObsoleteRenderPipelineResources; assetCreated.m_RenderPipelineRayTracingResources = oldAsset.m_ObsoleteRenderPipelineRayTracingResources; assetCreated.beforeTransparentCustomPostProcesses.AddRange(oldAsset.m_ObsoleteBeforeTransparentCustomPostProcesses); assetCreated.beforePostProcessCustomPostProcesses.AddRange(oldAsset.m_ObsoleteBeforePostProcessCustomPostProcesses); assetCreated.afterPostProcessCustomPostProcesses.AddRange(oldAsset.m_ObsoleteAfterPostProcessCustomPostProcesses); assetCreated.beforeTAACustomPostProcesses.AddRange(oldAsset.m_ObsoleteBeforeTAACustomPostProcesses); assetCreated.lightLayerName0 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteLightLayerName0); assetCreated.lightLayerName1 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteLightLayerName1); assetCreated.lightLayerName2 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteLightLayerName2); assetCreated.lightLayerName3 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteLightLayerName3); assetCreated.lightLayerName4 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteLightLayerName4); assetCreated.lightLayerName5 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteLightLayerName5); assetCreated.lightLayerName6 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteLightLayerName6); assetCreated.lightLayerName7 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteLightLayerName7); // Decal layer names were added in 2021 cycle if (oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName0 != null) { assetCreated.decalLayerName0 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName0); assetCreated.decalLayerName1 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName1); assetCreated.decalLayerName2 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName2); assetCreated.decalLayerName3 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName3); assetCreated.decalLayerName4 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName4); assetCreated.decalLayerName5 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName5); assetCreated.decalLayerName6 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName6); assetCreated.decalLayerName7 = System.String.Copy(oldAsset.currentPlatformRenderPipelineSettings.m_ObsoleteDecalLayerName7); } assetCreated.shaderVariantLogLevel = oldAsset.m_ObsoleteShaderVariantLogLevel; assetCreated.lensAttenuationMode = oldAsset.m_ObsoleteLensAttenuation; // we need to make sure the old diffusion profile had time to upgrade before moving it away if (oldAsset.diffusionProfileSettings != null) { oldAsset.diffusionProfileSettings.TryToUpgrade(); } System.Array.Resize(ref assetCreated.diffusionProfileSettingsList, oldAsset.m_ObsoleteDiffusionProfileSettingsList.Length); for (int i = 0; i < oldAsset.m_ObsoleteDiffusionProfileSettingsList.Length; ++i) { assetCreated.diffusionProfileSettingsList[i] = oldAsset.m_ObsoleteDiffusionProfileSettingsList[i]; } //3. Clear obsolete fields if (bClearObsoleteFields) { oldAsset.m_ObsoleteDefaultVolumeProfile = null; oldAsset.m_ObsoleteDefaultLookDevProfile = null; oldAsset.m_ObsoleteRenderPipelineResources = null; oldAsset.m_ObsoleteRenderPipelineRayTracingResources = null; oldAsset.m_ObsoleteBeforeTransparentCustomPostProcesses = null; oldAsset.m_ObsoleteBeforePostProcessCustomPostProcesses = null; oldAsset.m_ObsoleteAfterPostProcessCustomPostProcesses = null; oldAsset.m_ObsoleteBeforeTAACustomPostProcesses = null; oldAsset.m_ObsoleteDiffusionProfileSettingsList = null; } #pragma warning restore 618 AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); return(assetCreated); }