Search Issue Tracker

Fixed in 2022.1.X

Votes

0

Found in

2020.3.20f1

Issue ID

1374795

Regression

No

Shader displays different colors in Editor and when using Build

Shader System

-

Reproduction steps:
1. Open the project "1374795.zip"
2. Open "SampleScene" in the Assets folder
3. Watch the colors of cubes in the Editor
4. Build and Run the project
5. Watch the colors of cubes now

Expected result: the left cube is red, the right cube is green
Actual result: both cubes are green

Reproduces on versions before 2021.2

Note:
- Both cubes got a Material with the custom Shader "NewUnlitShader" on them
- It is only reproducible if red Material's keyword string does not contain _COLOR_RED
- It is not reproducible if there is only 1 cube
- The issue can only be seen in Standalone Build, but not in the Editor
- Reproducible both in Mono and IL2CPP

  1. Resolution Note (fix version 2022.1):

    The material keyword system used to lack validation of the state, which could cause the material to have an invalid keyword state. In this case particularly, the red material did not have either _COLOR_RED or _COLOR_GREEN selected, which caused it in the player build to select the only existing variant, which was the green one.

    This issue is already fixed in 2021.2. While waiting for the potential backports, on older versions it is possible to workaround the issue by selecting the material and then in the inspector selecting a value for each KeywordEnum. This will set a valid keyword state.

    Fixed in: 2021.2.0a18

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.