I wonder if there is a better way to assign the PBRCustomMaterial property?
private copyMaterialProperties(source: PBRMaterial, target: PBRCustomMaterial) {
target.uniqueId = source.uniqueId;
target.albedoColor = source.albedoColor;
target.albedoTexture = source.albedoTexture;
target.metallic = source?.metallic;
target.roughness = source?.roughness;
target.metallicTexture = source?.metallicTexture;
target.reflectionColor = source?.reflectionColor;
target.reflectanceTexture = source?.reflectionTexture;
target.reflectionColor = source?.reflectionColor;
target.clearCoat.isEnabled = source.clearCoat?.isEnabled;
target.clearCoat.intensity = source.clearCoat?.intensity;
target.alpha = source?.alpha;
target.alphaMode = source?.alphaMode;
target.transparencyMode = source?.transparencyMode;
target.useAlphaFromAlbedoTexture = source.useAlphaFromAlbedoTexture;
if (target.albedoTexture) {
target.albedoTexture.hasAlpha = source.albedoTexture!.hasAlpha;
}
target.needAlphaBlending = () => source.needAlphaBlending();
target.needDepthPrePass = source.needDepthPrePass;
...
}
As it turns out, I missed a lot of properties, because after replacing the material, the rendering is different than before!!
Any advice you give me will be helpful!!Thank you all