Search Issue Tracker
By Design
Votes
0
Found in
2019.4.40f1
2021.3.17f1
Issue ID
UUM-31908
Regression
No
Setting a material's shader to a copy if it has HDR colors can cause those colors to be incorrectly converted
Noticed with copies of the TextMeshPro/Distance Field shaders.
Original post: [https://unity.slack.com/archives/C06TQ82JY/p1680093001453539]
The case this was seen in:
# At boot an instance of the shader and default property sheet get created.
# The color properties are defaulted to low-range and all have {{m_Flags}} values of 0, so "_FaceColor" (the problem property) ends up with its {{m_Descs}} flag with {{kMaskSRGB}} set.
# An instance of this shader (and a material) is now loaded from an asset bundle. {{m_Flags}} in this case is set to 16 ({{{}kPropFlagHDR{}}}), as the _FaceColor value is high-range. {{m_Descs}} does not end up with {{kMaskSRGB}} set.
# A script 'corrects' the shader of the material to what is the embedded version of the shader. From the script's perspective this doesn't seem it should be an issue since they share the same properties anyway.
# The shader set calls {{BuildProperties}} which does a\{{ ShaderPropertySheet::CopyFrom}} using the 'default' copy of the shader's property sheet, including the\{{ m_Descs}} state which means {{kMaskSRGB}} ends up set, as if the properties aren't going to now have the serialized values dropped in.
# {{AssignDefinedPropertiesTo}} copies in the high-range colour values which are not recognized as high-range because of {{{}m_Descs{}}}'s state having been changed, so the values get incorrectly converted.
The precursor to this happening appears to be having the in-project version of the shader somehow serialized with m_Flags values serialized as 0 for the HDR properties.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [Render Graph Viewer] Resource list icons cropped and in inconsistent positions
- Scene View with Debug Draw Mode enabled is gray when GPU Resident Drawer is enabled
- The UI is not visible when resizing out of focus built Player window with Application.runInBackground set to false
- [Linux] "Error while reading movie" errors are thrown when opening templates
- Shader warnings are being thrown after building Mixed Reality Template
Resolution Note:
The issue is user-side, one of the shader copies is missing [HDR] property markup.