Skip to content

Commit e608f8f

Browse files
kennytannEvergreen
authored andcommitted
[6000][UUM-72414][UUM-72180] Fix blend issues in rendergraph pipeline
Fix UUM-72414 and UUM-72180
1 parent 8f42637 commit e608f8f

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Render2DLightingPass.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ private int DrawLayerBatches(
180180
var rtCount = 0U;
181181

182182
// Account for Sprite Mask and normal map usage where the first and last layer has to render the stencil pass
183-
bool hasSpriteMask = UnityEngine.SpriteMaskUtility.HasSpriteMaskInScene();
184183
bool normalsFirstClear = true;
185184

186185
// Draw lights
@@ -205,9 +204,7 @@ private int DrawLayerBatches(
205204

206205
batchesDrawn++;
207206

208-
if (layerBatch.lightStats.totalNormalMapUsage > 0 ||
209-
(hasSpriteMask && i == 0) ||
210-
(hasSpriteMask && i + 1 == batchCount))
207+
if (layerBatch.lightStats.totalNormalMapUsage > 0)
211208
{
212209
filterSettings.sortingLayerRange = layerBatch.layerRange;
213210
var depthTarget = m_NeedsDepth ? depthAttachmentHandle : null;

Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawNormal2DPass.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,10 @@ private static void Execute(RasterCommandBuffer cmd, PassData passData)
3030
public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData rendererData, ref LayerBatch layerBatch, int batchIndex)
3131
{
3232
Universal2DResourceData universal2DResourceData = frameData.Get<Universal2DResourceData>();
33-
bool hasSpriteMask = UnityEngine.SpriteMaskUtility.HasSpriteMaskInScene();
3433
int lastBatchIndex = universal2DResourceData.normalsTexture.Length - 1;
3534

3635
// Account for Sprite Mask and normal map usage where the first and last layer has to render the stencil pass
37-
if (!layerBatch.lightStats.useNormalMap &&
38-
!(hasSpriteMask && batchIndex == 0) &&
39-
!(hasSpriteMask && batchIndex == lastBatchIndex))
36+
if (!layerBatch.lightStats.useNormalMap)
4037
return;
4138

4239
UniversalRenderingData renderingData = frameData.Get<UniversalRenderingData>();

Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ private static void Execute(RasterGraphContext context, PassData passData)
4646
{
4747
if (passData.layerUseLights)
4848
{
49-
for (var blendStyleIndex = 0; blendStyleIndex < blendStylesCount; blendStyleIndex++)
49+
for (var i = 0; i < blendStylesCount; i++)
5050
{
51+
var blendStyleIndex = passData.blendStyleIndices[i];
5152
RendererLighting.EnableBlendStyle(cmd, blendStyleIndex, true);
5253
}
5354
}
@@ -191,9 +192,10 @@ void SetGlobalLightTextures(RenderGraph graph, IRasterRenderGraphBuilder builder
191192
{
192193
if (layerBatch.lightStats.useAnyLights)
193194
{
194-
for (var blendStyleIndex = 0; blendStyleIndex < lightTextures.Length; blendStyleIndex++)
195+
for (var i = 0; i < lightTextures.Length; i++)
195196
{
196-
builder.SetGlobalTextureAfterPass(lightTextures[blendStyleIndex], Shader.PropertyToID(RendererLighting.k_ShapeLightTextureIDs[blendStyleIndex]));
197+
var blendStyleIndex = layerBatch.activeBlendStylesIndices[i];
198+
builder.SetGlobalTextureAfterPass(lightTextures[i], Shader.PropertyToID(RendererLighting.k_ShapeLightTextureIDs[blendStyleIndex]));
197199
}
198200
}
199201
else if (rendererData.lightCullResult.IsSceneLit())

Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void CreateResources(RenderGraph renderGraph)
267267
if (!Light2DManager.GetGlobalColor(m_LayerBatches[i].startLayerID, index, out var clearColor))
268268
clearColor = Color.black;
269269

270-
universal2DResourceData.lightTextures[i][j] = UniversalRenderer.CreateRenderGraphTexture(renderGraph, desc, RendererLighting.k_ShapeLightTextureIDs[j], true, clearColor, FilterMode.Bilinear);
270+
universal2DResourceData.lightTextures[i][j] = UniversalRenderer.CreateRenderGraphTexture(renderGraph, desc, RendererLighting.k_ShapeLightTextureIDs[index], true, clearColor, FilterMode.Bilinear);
271271
}
272272
}
273273
}

0 commit comments

Comments
 (0)