Search Issue Tracker
By Design
Votes
2
Found in
2022.3.46f1
6000.0.19f1
6000.1.0a7
Issue ID
UUM-79681
Regression
No
HDR color values set with MaterialPropertBlock.SetColor are incorrect when using Linear Color Space
Steps to reproduce:
1. Open the “BugCheck” project
2. Open the “MPB_Test” scene
3. Enter Play Mode
4. Open the Frame Debugger Window
5. Open the “DrawOpaqueObjects” → “RenderLoop.Draw” fields
6. Select the “Draw Mesh Cube_Material”
7. Open the “Vectors” Tab in the Frame Debugger
8. Observe the “_HDRColor” vector
9. Observe the “_HDRColor” vector of “Draw Mesh Cube_MPB”
Expected result: The “_HDRColor” vectors have the same values on both cubes
Actual result: The “Draw Mesh Cube_MPB” GameObject has much higher values of “_HDRColor”
Reproducible in: 2022.3.46f1, 6000.0.19f1
Couldn’t test with: 2021.3.43f1 (Frame Debugger has no Vectors Field)
Reproducible on: Windows 11
Not reproducible on: No other environment tested
Comments (1)
-
kz_kizaki
Sep 18, 2024 03:12
It is not only MaterialPropertyBlock.SetColor, values that setting color with AnimationClip to HDRColor also is incorrect.
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
- Shader Graph Asset icon is not shown on creation unless you confirm the name
- APV Sky occlusion doesn't consider the terrain
- [iOS] "EXC_BAD_ACCESS" Player crash when Script Debugging is enabled
- Cursor skips input fields when tabbing between two sets of input fields
- "Shader error redefinition of 'Varyings'" error appears when selecting the shader
Resolution Note:
The reason behind this difference is coming from the difference between how "Material" and "MBP"s are handling color values. The MBP.SetColor considers color value to be always set in sRGB space and is converted to linear if the active color space is linear while this is not the case for Material.SetColor . So basically you need manual updating of the color value if you switch between color spaces. This is a conscious performance-oriented trade-off, and we won't change this behavior. If you want to work around it, just set the animated values in gamma space with the formula:
gammaRGB = new Color(
Mathf.Pow(hdrColor.r, 1f / 2.2f),
Mathf.Pow(hdrColor.g, 1f / 2.2f),
Mathf.Pow(hdrColor.b, 1f / 2.2f),
linearColor.a );