- Home /
is this a bug?
Unity 2021.1.15f1
Converting material to Lit with HDRP The displayed Amplitude value of HightMap is different from what it actually looks like. When you re-enter the same value, it returns to normal. When I checked the change value in debug mode, _HeightPoMAmplitude is the value shown in the inspector window. Actually, the _HeightAmplitude value and the HeightCenter value are not properly entered.
I later found out about this problem and had to run some code to re-update the _HeightAmplitude values of all HDRP/Lit materials in the project. If it's a bug, please fix it.
If you look at Lit.Shader // Caution: Default value of Height Amplitude must be (_HeightMax - _HeightMin) 0.01 It is stated In my case, I had to do _HeightPoMAmplitude 0.01 to get the correct value.
Answer by twocomet · Jul 27, 2021 at 02:14 AM
This is how I temporarily solved it
void Refresh()
{
DirectoryInfo Di = new DirectoryInfo("Assets");
FileInfo[] file = Di.GetFiles("*.mat", SearchOption.AllDirectories);
foreach (var item in file)
{
string filePath = Path.Combine(item.Directory.FullName, item.Name);
filePath = filePath.Substring(filePath.IndexOf("Assets\\"));
Material target = (Material)AssetDatabase.LoadAssetAtPath(filePath, typeof(Material));
if (!target || target.shader.name != "HDRP/Lit" || target.GetFloat("_HeightAmplitude") == 0)
continue;
target.SetFloat("_HeightAmplitude", target.GetFloat("_HeightPoMAmplitude") * 0.01f);
}
}
.
Your answer
![](https://koobas.hobune.stream/wayback/20220613040837im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Scrambled textures on first run of game only. 2 Answers
v4.2.2: Graphics.DrawTexture now ignoring material tiling & offsets? 0 Answers
Decals only appear on materials that have been selected in the editor 0 Answers
Material heightmap broken with texture tiling? 0 Answers
Material load from asset bundle are missing texture 1 Answer