Search Issue Tracker

By Design

Votes

0

Found in

2019.1.0a1

2019.1.0a14

2019.1.0f1

2019.2.0a1

2019.3.0a1

Issue ID

1145965

Regression

Yes

Using UsePass "Standard/SHADOWCASTER", IsKeywordEnabled("_ALPHABLEND_ON") prints true, but its not present in Frame Debugger

Shaders

-

To reproduce:
1. Open users attached project "TestVRM.zip"
2. Open "SampleScene.unity" scene
3. Select "Cube1" game object in the hierarchy
4. Press in the top menu Test > Test
5. Observe the console as Debug.Log(Selection.activeGameObject.GetComponent<Renderer>().material.IsKeywordEnabled("_ALPHABLEND_ON")); prints true
6. Select "Cube2" game object in the hierarchy
7. Press in the top menu Test > Test
8. Observe the console as Debug.Log(Selection.activeGameObject.GetComponent<Renderer>().material.IsKeywordEnabled("_ALPHABLEND_ON")); prints true
9. Open Analysis > Frame Debugger and enable it
10. Select Draw Mesh Cube1 from the list on the left and observe as _ALPHABLEND_ON keyword is present
12. Select Draw Mesh Cube2 from the list on the left and observe as _ALPHABLEND_ON keyword is not present even though material.IsKeywordEnabled("_ALPHABLEND_ON") returns true

Expected result: if the keyword is not present in the shader IsKeywordEnabled("_ALPHABLEND_ON") should print out "False"
Actual result: IsKeywordEnabled("_ALPHABLEND_ON") prints out "True" even though it is not shown in the Frame Debugger

Reproduced on:
2019.1.0a14 2019.1.f1 2019.2.0a14 2019.3.0a1

Not reproduced on:
2018.3.0f1 2018.3.14f1 2019.1.0a1 2019.1.0a13

Notes:
- Reproduces on Metal and OpenGLCore
- Same results on macOS and win10 machines

  1. Resolution Note (2019.3.X):

    Local keywords are prioritized over global ones. This means that if a shader defines a keyword both as local and global, only the local one will work as expected.

    The user shader in this case is defining _ALPHABLEND_ON as global keywords but the UsePass source defines it as local keyword. When enabling _ALPHABLEND_ON from the script, it will affect only the local keyword. This can be easily worked around by modifying the shader to not have conflicting keyword types. In this particular case modifying the _ALPHABLEND_ON to use multi_compile_local is the correct fix.

    We acknowledge that the current situation is not optimal as the local keywords feature can break existing content in some cases and those can't be resolved with automatic shader upgrader. To make these cases easier to spot and fix, we'll be adding new warnings when having conflicting keyword definitions in the shaders.

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.