Skip to content

Commit ef31d07

Browse files
elliomanEvergreen
authored andcommitted
[POI-817] SSAO to use a single UnsafePass (RenderGraph optimization) + Adding a Game Camera helper + Adding a SetKeyword overload
* Optimize RenderGraph CPU cost by converting Screen Space Ambient Occlusion (SSAO) from many RasterPasses into a single UnsafePass. * Adds a `isGameCamera` to UniversalCameraData (Already had one for scene and preview cameras) * Adds an overload for SetKeyword in CoreUtils that accepts LocalKeyword. [POI-817](https://jira.unity3d.com/browse/POI-817) [GFXRPF-172](https://jira.unity3d.com/browse/GFXRPF-172)
1 parent 2c07076 commit ef31d07

File tree

3 files changed

+221
-348
lines changed

3 files changed

+221
-348
lines changed

Packages/com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ public static void SetKeyword(BaseCommandBuffer cmd, string keyword, bool state)
11561156

11571157
// Caution: such a call should not be use interlaced with command buffer command, as it is immediate
11581158
/// <summary>
1159-
/// Set a keyword immediatly on a Material.
1159+
/// Set a keyword immediately on a Material.
11601160
/// </summary>
11611161
/// <param name="material">Material on which to set the keyword.</param>
11621162
/// <param name="keyword">Keyword to set on the material.</param>
@@ -1169,6 +1169,21 @@ public static void SetKeyword(Material material, string keyword, bool state)
11691169
material.DisableKeyword(keyword);
11701170
}
11711171

1172+
// Caution: such a call should not be use interlaced with command buffer command, as it is immediate
1173+
/// <summary>
1174+
/// Set a keyword immediately on a Material.
1175+
/// </summary>
1176+
/// <param name="material">Material on which to set the keyword.</param>
1177+
/// <param name="keyword">Keyword to set on the material.</param>
1178+
/// <param name="state">Value of the keyword to set on the material.</param>
1179+
public static void SetKeyword(Material material, LocalKeyword keyword, bool state)
1180+
{
1181+
if (state)
1182+
material.EnableKeyword(keyword);
1183+
else
1184+
material.DisableKeyword(keyword);
1185+
}
1186+
11721187
/// <summary>
11731188
/// Set a keyword to a compute shader
11741189
/// </summary>

Packages/com.unity.render-pipelines.universal/Runtime/FrameData/UniversalCameraData.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ internal bool requireSrgbConversion
257257
}
258258
}
259259

260+
/// <summary>
261+
/// True if the camera rendering is for regular in-game.
262+
/// </summary>
263+
public bool isGameCamera => cameraType == CameraType.Game;
264+
260265
/// <summary>
261266
/// True if the camera rendering is for the scene window in the editor.
262267
/// </summary>

0 commit comments

Comments
 (0)