Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with completely black AO on double sided materials when normal mode is set to None.
- Fixed UI drawing of the quaternion (1251235)
- Fix an issue with the quality mode and perf mode on RTR and RTGI and getting rid of unwanted nans (1256923).
- Fixed unitialized ray tracing resources when using non-default HDRP asset (case 1259467).

### Changed
- Improve MIP selection for decals on Transparents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,57 +572,64 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau
}

#if UNITY_EDITOR
void UpgradeResourcesIfNeeded()
void UpgradeResourcesInAssetIfNeeded(HDRenderPipelineAsset asset)
{
// The first thing we need to do is to set the defines that depend on the render pipeline settings
m_Asset.EvaluateSettings();

// Check that the serialized Resources are not broken
if (HDRenderPipeline.defaultAsset.renderPipelineResources == null)
HDRenderPipeline.defaultAsset.renderPipelineResources
if (asset.renderPipelineResources == null)
asset.renderPipelineResources
= UnityEditor.AssetDatabase.LoadAssetAtPath<RenderPipelineResources>(HDUtils.GetHDRenderPipelinePath() + "Runtime/RenderPipelineResources/HDRenderPipelineResources.asset");
#if UNITY_EDITOR_LINUX // Temp hack to be able to make linux test run. To clarify
ResourceReloader.TryReloadAllNullIn(HDRenderPipeline.defaultAsset.renderPipelineResources, HDUtils.GetHDRenderPipelinePath());
ResourceReloader.TryReloadAllNullIn(asset.renderPipelineResources, HDUtils.GetHDRenderPipelinePath());
#else
ResourceReloader.ReloadAllNullIn(HDRenderPipeline.defaultAsset.renderPipelineResources, HDUtils.GetHDRenderPipelinePath());
ResourceReloader.ReloadAllNullIn(asset.renderPipelineResources, HDUtils.GetHDRenderPipelinePath());
#endif

if (m_RayTracingSupported)
{
if (HDRenderPipeline.defaultAsset.renderPipelineRayTracingResources == null)
HDRenderPipeline.defaultAsset.renderPipelineRayTracingResources
if (asset.renderPipelineRayTracingResources == null)
asset.renderPipelineRayTracingResources
= UnityEditor.AssetDatabase.LoadAssetAtPath<HDRenderPipelineRayTracingResources>(HDUtils.GetHDRenderPipelinePath() + "Runtime/RenderPipelineResources/HDRenderPipelineRayTracingResources.asset");
#if UNITY_EDITOR_LINUX // Temp hack to be able to make linux test run. To clarify
ResourceReloader.TryReloadAllNullIn(HDRenderPipeline.defaultAsset.renderPipelineRayTracingResources, HDUtils.GetHDRenderPipelinePath());
ResourceReloader.TryReloadAllNullIn(asset.renderPipelineRayTracingResources, HDUtils.GetHDRenderPipelinePath());
#else
ResourceReloader.ReloadAllNullIn(HDRenderPipeline.defaultAsset.renderPipelineRayTracingResources, HDUtils.GetHDRenderPipelinePath());
ResourceReloader.ReloadAllNullIn(asset.renderPipelineRayTracingResources, HDUtils.GetHDRenderPipelinePath());
#endif
}
else
{
// If ray tracing is not enabled we do not want to have ray tracing resources referenced
HDRenderPipeline.defaultAsset.renderPipelineRayTracingResources = null;
asset.renderPipelineRayTracingResources = null;
}

var editorResourcesPath = HDUtils.GetHDRenderPipelinePath() + "Editor/RenderPipelineResources/HDRenderPipelineEditorResources.asset";
if (HDRenderPipeline.defaultAsset.renderPipelineEditorResources == null)
if (asset.renderPipelineEditorResources == null)
{
var objs = InternalEditorUtility.LoadSerializedFileAndForget(editorResourcesPath);
HDRenderPipeline.defaultAsset.renderPipelineEditorResources = objs != null && objs.Length > 0 ? objs.First() as HDRenderPipelineEditorResources : null;
asset.renderPipelineEditorResources = objs != null && objs.Length > 0 ? objs.First() as HDRenderPipelineEditorResources : null;
}

if (ResourceReloader.ReloadAllNullIn(HDRenderPipeline.defaultAsset.renderPipelineEditorResources,
if (ResourceReloader.ReloadAllNullIn(asset.renderPipelineEditorResources,
HDUtils.GetHDRenderPipelinePath()))
{
InternalEditorUtility.SaveToSerializedFileAndForget(
new Object[]{HDRenderPipeline.defaultAsset.renderPipelineEditorResources },
new Object[]{asset.renderPipelineEditorResources },
editorResourcesPath,
true);
}

// Upgrade the resources (re-import every references in RenderPipelineResources) if the resource version mismatches
// It's done here because we know every HDRP assets have been imported before
HDRenderPipeline.defaultAsset.renderPipelineResources?.UpgradeIfNeeded();
asset.renderPipelineResources?.UpgradeIfNeeded();
}

void UpgradeResourcesIfNeeded()
{
// The first thing we need to do is to set the defines that depend on the render pipeline settings
m_Asset.EvaluateSettings();

// Check and fix both the default and current HDRP asset
UpgradeResourcesInAssetIfNeeded(HDRenderPipeline.defaultAsset);
UpgradeResourcesInAssetIfNeeded(HDRenderPipeline.currentAsset);
}

void ValidateResources()
Expand Down