Skip to content

Commit 6e0729f

Browse files
arttu-peltonenEvergreen
authored andcommitted
Fix shader errors when post processing shaders are stripped
1 parent 30e66f8 commit 6e0729f

6 files changed

Lines changed: 12 additions & 11 deletions

File tree

Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/BloomPostProcessPass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public BloomPostProcessPass(Shader shader)
3434
this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1;
3535
this.profilingSampler = URPProfilingSamplers.Bloom;
3636

37-
m_Material = PostProcessUtils.LoadShader(shader, passName);
37+
m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log);
3838

3939
// Array for bloom pyramid materials.
4040
// Materials are references in the command buffer, so we need a separate material for each mip level.
4141
m_MaterialPyramid = new Material[k_MaxPyramidSize];
4242
for (uint i = 0; i < k_MaxPyramidSize; ++i)
43-
m_MaterialPyramid[i] = PostProcessUtils.LoadShader(shader, passName);
43+
m_MaterialPyramid[i] = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log);
4444

4545
// Check if the pass init was successful.
4646
m_IsValid = m_Material != null;

Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldBokehProcessPass.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public DepthOfFieldBokehPostProcessPass(Shader shader)
2323
{
2424
this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1;
2525
this.profilingSampler = URPProfilingSamplers.BokehDepthOfField;
26-
27-
m_Material = PostProcessUtils.LoadShader(shader, passName);
26+
m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log);
2827
m_IsValid = m_Material != null;
2928
}
3029

Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldGaussianPostProcessPass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public DepthOfFieldGaussianPostProcessPass(Shader shader)
2121
this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1;
2222
this.profilingSampler = URPProfilingSamplers.GaussianDepthOfField;
2323

24-
m_Material = PostProcessUtils.LoadShader(shader, passName);
25-
m_MaterialCoc = PostProcessUtils.LoadShader(shader, passName);
24+
m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log);
25+
m_MaterialCoc = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log);
2626
m_IsValid = m_Material != null && m_MaterialCoc != null;
2727

2828
// Depth of Field

Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/MotionBlurPostProcessPass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public MotionBlurPostProcessPass(Shader shader)
1616
this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1;
1717
this.profilingSampler = URPProfilingSamplers.MotionBlur;
1818

19-
m_Material = PostProcessUtils.LoadShader(shader, passName);
19+
m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log);
2020
m_IsValid = m_Material != null;
2121
}
2222

Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/PaniniProjectionPostProcessPass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public PaniniProjectionPostProcessPass(Shader shader)
1616
this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1;
1717
this.profilingSampler = URPProfilingSamplers.PaniniProjection;
1818

19-
m_Material = PostProcessUtils.LoadShader(shader, passName);
19+
m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log);
2020
m_IsValid = m_Material != null;
2121
}
2222

Packages/com.unity.render-pipelines.universal/Runtime/PostProcessUtils.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ public static class PostProcessUtils
1414
/// </summary>
1515
/// <param name="shader">Shader used for the material</param>
1616
/// <param name="passName">Pass name for error messages.</param>
17-
/// <returns>A new Material instance using the provided shader. Null if the shader is not supported.</returns>
18-
internal static Material LoadShader(Shader shader, string passName = "")
17+
/// <param name="logLevel">LogType for the message if the shader is not supported.</param>
18+
/// <returns>A new Material instance using the provided shader. Null if the shader is not supported or it's missing.</returns>
19+
internal static Material LoadShader(Shader shader, string passName = "", LogType logLevel = LogType.Warning)
1920
{
2021
if (shader == null)
2122
{
@@ -24,7 +25,7 @@ internal static Material LoadShader(Shader shader, string passName = "")
2425
}
2526
else if (!shader.isSupported)
2627
{
27-
Debug.LogWarning($"Shader '{shader.name}' is not supported (in '{passName}'). PostProcessing render passes will not execute.");
28+
Debug.unityLogger.Log(logLevel, $"Shader '{shader.name}' is not supported or has been stripped from the build (in '{passName}'). PostProcessing render passes will not execute.");
2829
return null;
2930
}
3031

@@ -34,6 +35,7 @@ internal static Material LoadShader(Shader shader, string passName = "")
3435
/// <summary>
3536
/// Creates a texture compatible with post-processing effects.
3637
/// </summary>
38+
3739
/// <param name="renderGraph">RenderGraph that creates the texture.</param>
3840
/// <param name="source">Source texture for the texture descriptor.</param>
3941
/// <param name="name">Texture name.</param>

0 commit comments

Comments
 (0)