Hi,
When importing normal maps at runtime they look like this:
And when importing the files in the editor and assigning them manually in the Material Instance, they look correct:
Both images are made with the same files, same parameters, yet the first one looks all wrong.
The only difference as far as i know is that in the first one the texture was imported at runtime.
Here is what i d. It’s a bit tricky because the mesh are already assigned a Material Instance, so:
// i first create a MID from the parent material
DiceMaterialInstance = UMaterialInstanceDynamic::Create(DiceParentMaterial, this);
// then assign it to the mesh
DiceStaticMesh->SetMaterial(0, DiceMaterialInstance);
// then get all the parameters from the original Material Instance (i checked in many ways that they are copied correctly)
DiceMaterialInstance->CopyMaterialUniformParameters(DiceMat);
// then assign the new textures
DiceMaterialInstance->SetTextureParameterValue("DiceNumbers", TexturePair.LayoutTexture);
DiceMaterialInstance->SetTextureParameterValue("DiceNormalMap", TexturePair.NormalTexture);
I checked that all parameters are correctly set with things like this applied both on meshes having the original MI and meshes having my home made MID, the numbers are the same:
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::Printf(TEXT("SetupTexture Roughness: %f"), DiceMaterialInstance->K2_GetScalarParameterValue(FName("Roughness"))));
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::Printf(TEXT("SetupTexture Specular: %f"), DiceMaterialInstance->K2_GetScalarParameterValue(FName("Specular"))));
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::Printf(TEXT("SetupTexture Metallic: %f"), DiceMaterialInstance->K2_GetScalarParameterValue(FName("Metallic"))));
I tried to multiply the normal maps by various numbers with no visible result.
I also tried to invert some channels with no improvement.
So on the paper everything looks fine, the files are the same, the numbers are the same, but it’s all messed up when done at runtime.
I don’t know what it says about normals when it looks like this. Too strong ? Too small ? Wrong direction ?.
I already saw similar things in the past but it was always that the normals were incorrect on the mesh, which is obviously nothe case here.
Anyone knows a direction i could try ?
Thanks
Cedric