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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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 );