Search Issue Tracker

Won't Fix

Votes

0

Found in

2021.3.40f1

2022.3.35f1

6000.0.8f1

Issue ID

UUM-74995

Regression

No

Material properties update one frame late when set from a Custom Pass

-

Reproduction steps:
1. Open the “ReproProject“ project
2. Open the “Assets/OutdoorsScene“ scene
3. Enter Play Mode
4. Observe the “DebugQuad” GameObject in the Game View

Expected result: The “DebugQuad” GameObject is green
Actual result: The “DebugQuad” GameObject color flickers between red and green

Reproducible with: 2021.3.40f1, 2022.3.35f1, 6000.0.8f1

Reproducible on: Windows 11 Pro (22H2)
Not reproducible on: No other environment tested

Note: Reproduces only if the injection point of the Custom Pass Volume component is Before Rendering. If it is set to After Opaque Depth And Normal the quad shows the expected result

  1. Resolution Note:

    This issue can be resolved but there are several reasons not to resolve.

    1. Multithreading Issue :
    Intuitive solution of this ticket can break multi-threading. (It will change render-realated property during the frame.)
    Furthemore, As a rule of thumb, unity engine wants to lock in renderer properties when we kick off a frame (due to multi-threading).

    2. Limited Benefit from Resolving the Issue:
    Even if we change it to utilize the MaterialPropertyBlock from the current frame instead of the previous frame,
    the Custom Pass will still function correctly at certain Injection Points.

    Before the fix (using the MaterialPropertyBlock from the previous frame):
    BeforeRendering: Issue occurs
    (After Opaque Depth and Normal, After Opaque and Sky, Before Transparent, etc.): Functions correctly
    After the fix (using the MaterialPropertyBlock from the current frame):
    BeforeRendering: Functions correctly
    (After Opaque Depth and Normal, After Opaque and Sky, Before Transparent, etc.): Issue occurs

    3. Simple C# Workaround:
    The issue can be bypassed with a simple C# code change in the Repro project.
    By caching the MaterialPropertyBlock values set in the previous frame and using these values in the current frame.
    Custom Pass can be injected BeforeRendering without causing issues.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.