Skip to content

Commit 4ebd021

Browse files
committed
Misc changes
1 parent 7c71ae7 commit 4ebd021

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,7 @@ private void FillCommandBuffer()
247247
{
248248
_renderObjects.Clear();
249249
_outlineLayers.GetRenderObjects(_renderObjects);
250-
251-
foreach (var renderObject in _renderObjects)
252-
{
253-
renderer.Render(renderObject);
254-
}
250+
renderer.Render(_renderObjects);
255251
}
256252
}
257253
}

Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/OutlineRenderer.cs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace UnityFx.Outline
4040
private readonly TextureDimension _rtDimention;
4141
private readonly RenderTargetIdentifier _rt;
4242
private readonly RenderTargetIdentifier _depth;
43-
private readonly CommandBuffer _commandBuffer;
43+
private readonly CommandBuffer _commandBuffer;
4444
private readonly OutlineResources _resources;
4545

4646
#endregion
@@ -213,24 +213,41 @@ public OutlineRenderer(CommandBuffer cmd, OutlineResources resources, RenderTarg
213213
}
214214

215215
/// <summary>
216-
/// Renders outline around a single object. This version allows enumeration of <paramref name="renderers"/> with no GC allocations.
216+
/// Renders outline around a single object.
217217
/// </summary>
218218
/// <param name="obj">An object to be outlined.</param>
219-
/// <seealso cref="Render(IReadOnlyList{Renderer}, IOutlineSettings)"/>
220-
/// <seealso cref="Render(Renderer, IOutlineSettings)"/>
219+
/// <seealso cref="Render(IReadOnlyList{OutlineRenderObject})"/>
221220
public void Render(OutlineRenderObject obj)
222221
{
223222
Render(obj.Renderers, obj.OutlineSettings, obj.Tag);
224223
}
225224

226225
/// <summary>
227-
/// Renders outline around a single object. This version allows enumeration of <paramref name="renderers"/> with no GC allocations.
226+
/// Renders outline around multiple <paramref name="objects"/>.
227+
/// </summary>
228+
/// <param name="objects">An object to be outlined.</param>
229+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="objects"/> is <see langword="null"/>.</exception>
230+
/// <seealso cref="Render(OutlineRenderObject)"/>
231+
public void Render(IReadOnlyList<OutlineRenderObject> objects)
232+
{
233+
if (objects is null)
234+
{
235+
throw new ArgumentNullException(nameof(objects));
236+
}
237+
238+
for (var i = 0; i < objects.Count; i++)
239+
{
240+
Render(objects[i]);
241+
}
242+
}
243+
244+
/// <summary>
245+
/// Renders outline around multiple <paramref name="renderers"/>.
228246
/// </summary>
229247
/// <param name="renderers">One or more renderers representing a single object to be outlined.</param>
230248
/// <param name="settings">Outline settings.</param>
231249
/// <param name="sampleName">Optional name of the sample (visible in profiler).</param>
232250
/// <exception cref="ArgumentNullException">Thrown if any of the arguments is <see langword="null"/>.</exception>
233-
/// <seealso cref="Render(OutlineRenderObject)"/>
234251
/// <seealso cref="Render(Renderer, IOutlineSettings, string)"/>
235252
public void Render(IReadOnlyList<Renderer> renderers, IOutlineSettings settings, string sampleName = null)
236253
{
@@ -267,13 +284,12 @@ public void Render(IReadOnlyList<Renderer> renderers, IOutlineSettings settings,
267284
}
268285

269286
/// <summary>
270-
/// Renders outline around a single object.
287+
/// Renders outline around a single <paramref name="renderer"/>.
271288
/// </summary>
272289
/// <param name="renderer">A <see cref="Renderer"/> representing an object to be outlined.</param>
273290
/// <param name="settings">Outline settings.</param>
274291
/// <param name="sampleName">Optional name of the sample (visible in profiler).</param>
275292
/// <exception cref="ArgumentNullException">Thrown if any of the arguments is <see langword="null"/>.</exception>
276-
/// <seealso cref="Render(OutlineRenderObject)"/>
277293
/// <seealso cref="Render(IReadOnlyList{Renderer}, IOutlineSettings, string)"/>
278294
public void Render(Renderer renderer, IOutlineSettings settings, string sampleName = null)
279295
{
@@ -301,18 +317,9 @@ public void Render(Renderer renderer, IOutlineSettings settings, string sampleNa
301317
_commandBuffer.EndSample(sampleName);
302318
}
303319

304-
/// <summary>
305-
/// Gets depth texture identifier for built-in render pipeline.
306-
/// </summary>
307-
public static RenderTargetIdentifier GetBuiltinDepth(RenderingPath renderingPath)
308-
{
309-
return (renderingPath == RenderingPath.DeferredShading || renderingPath == RenderingPath.DeferredLighting) ? BuiltinRenderTextureType.ResolvedDepth : BuiltinRenderTextureType.Depth;
310-
}
311-
312320
/// <summary>
313321
/// Specialized render target setup. Do not use if not sure.
314322
/// </summary>
315-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
316323
public void RenderObjectClear(OutlineRenderFlags flags)
317324
{
318325
// NOTE: Use the camera depth buffer when rendering the mask. Shader only reads from the depth buffer (ZWrite Off).
@@ -448,6 +455,11 @@ private void Blit(RenderTargetIdentifier src, int shaderPass, Material mat, Mate
448455
}
449456
}
450457

458+
private static RenderTargetIdentifier GetBuiltinDepth(RenderingPath renderingPath)
459+
{
460+
return (renderingPath == RenderingPath.DeferredShading || renderingPath == RenderingPath.DeferredLighting) ? BuiltinRenderTextureType.ResolvedDepth : BuiltinRenderTextureType.Depth;
461+
}
462+
451463
#endregion
452464
}
453465
}

Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Scripts/OutlinePass.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData
7979
{
8080
renderer.RenderObjectClear(outlineSettings.OutlineRenderMode);
8181
context.ExecuteCommandBuffer(cmd);
82-
cmd.Clear();
8382

8483
context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings, ref renderStateBlock);
84+
85+
cmd.Clear();
8586
renderer.RenderOutline(outlineSettings);
8687
}
8788
}
@@ -98,11 +99,7 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData
9899
{
99100
_renderObjects.Clear();
100101
_feature.OutlineLayers.GetRenderObjects(_renderObjects);
101-
102-
foreach (var obj in _renderObjects)
103-
{
104-
renderer.Render(obj);
105-
}
102+
renderer.Render(_renderObjects);
106103
}
107104

108105
context.ExecuteCommandBuffer(cmd);

0 commit comments

Comments
 (0)