Search Issue Tracker
By Design
By Design in 6000.1.X
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
- Texture Import Warnings are obscured by other Terrain Layer options in the Inspector
- Active Targets section text in Graph Inspector is truncated despite available space
- Burst Inspector middle divider is jittering when resized with the Burst Inspector window docked
- Shader Graph Node information is briefly displayed in Graph Inspector when clicking on Category in the Blackboard
- JsonConvert conversion fails trying to call GetCallbackMethodsForType when [OnDeserialized] is used in a class
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 );
Resolution Note (6000.1.X):
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 );