Hi all!
So, I have created a new material expression parameter called StaticMultiSwitchParameter that just like StaticSwitchParameter but can output several value. The material node(SMSP) show below:
I have changed “GLOBALSHADERMAP_DERIVEDDATA_VER” and “MATERIALSHADERMAP_DERIVEDDATA_VER” to my new GUID in “ShaderDerivedDataVersion.h”. Also, I added some code to tell “FStaticParameterSet” that there is a new Static Parameter I added. Something like this:
USTRUCT()
struct FStaticParameterSet
{
GENERATED_USTRUCT_BODY();
...
UPROPERTY()
TArray<FStaticMultiSwitchParameter> StaticMultiSwitchParameters;
...
bool IsEmpty() const
{
return StaticSwitchParameters.Num() == 0 && StaticComponentMaskParameters.Num() == 0 && TerrainLayerWeightParameters.Num() == 0 && MaterialLayersParameters.Num() == 0 && StaticMultiSwitchParameters.Num() == 0;
}
void Serialize(FArchive& Ar)
{
Ar.UsingCustomVersion(FRenderingObjectVersion::GUID);
Ar.UsingCustomVersion(FReleaseObjectVersion::GUID);
// Note: FStaticParameterSet is saved both in packages (UMaterialInstance) and the DDC (FMaterialShaderMap)
// Backwards compatibility only works with FStaticParameterSet's stored in packages.
// You must bump MATERIALSHADERMAP_DERIVEDDATA_VER as well if changing the serialization of FStaticParameterSet.
Ar << StaticSwitchParameters;
Ar << StaticComponentMaskParameters;
Ar << TerrainLayerWeightParameters;
if (Ar.CustomVer(FReleaseObjectVersion::GUID) >= FReleaseObjectVersion::MaterialLayersParameterSerializationRefactor)
{
Ar << MaterialLayersParameters;
}
//BENDER NOTE: Compatibility problem
if (Ar.CustomVer(FReleaseObjectVersion::GUID) >= FReleaseObjectVersion::AddStaticMultiSwitchParameter)
{
Ar << StaticMultiSwitchParameters;
}
}
}
So far, everything works perfectly my material expression works as I wish. But, a serious problem has arisen - Compatibility. When I saved my level/map, it could not be opened by the UE editor of the previous version.The previous version of the UE even could not show this level in content browser.
Is there a solution to this problem? Thanks!