diff --git a/Config/Engine.ini b/Config/Engine.ini index dec9cd468..2e84b95d3 100644 --- a/Config/Engine.ini +++ b/Config/Engine.ini @@ -127,4 +127,23 @@ +FunctionRedirects=( OldName="CesiumFeatureTexturePropertyBlueprintLibrary.GetPropertyKeys", - NewName="CesiumPropertyTexturePropertyBlueprintLibrary.GetPropertyNames") \ No newline at end of file + NewName="CesiumPropertyTexturePropertyBlueprintLibrary.GetPropertyNames") + ++EnumRedirects=(OldName="ECesiumPropertyComponentType", NewName="ECesiumPropertyComponentType_DEPRECATED", ValueChanges=( + ("Uint8","Uint8_DEPRECATED"), + ("Float","Float_DEPRECATED"), + )) + ++EnumRedirects=(OldName="ECesiumPropertyType", NewName="ECesiumPropertyType_DEPRECATED", ValueChanges=( + ("Scalar","Scalar_DEPRECATED"), + ("Vec2","Vec2_DEPRECATED"), + ("Vec3","Vec3_DEPRECATED"), + ("Vec4","Vec4_DEPRECATED"), + )) + ++EnumRedirects=(OldName="ECesiumFeatureTableAccessType", NewName="ECesiumFeatureTableAccessType_DEPRECATED", ValueChanges=( + ("Unknown","Unknown_DEPRECATED"), + ("Texture","Texture_DEPRECATED"), + ("Attribute","Attribute_DEPRECATED"), + ("Mixed","Mixed_DEPRECATED"), + )) \ No newline at end of file diff --git a/Content/Materials/MaterialFunctions/CesiumGetFeatureIdsFromTexture.uasset b/Content/Materials/MaterialFunctions/CesiumGetFeatureIdsFromTexture.uasset new file mode 100644 index 000000000..f53b3a32a Binary files /dev/null and b/Content/Materials/MaterialFunctions/CesiumGetFeatureIdsFromTexture.uasset differ diff --git a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp index 7f48e2f18..55fb194ed 100644 --- a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp +++ b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp @@ -938,9 +938,8 @@ void ACesium3DTileset::LoadTileset() { const UCesiumFeaturesMetadataComponent* pFeaturesMetadataComponent = this->FindComponentByClass(); if (pFeaturesMetadataComponent) { - this->_featuresDescription = {pFeaturesMetadataComponent->FeatureIdSets}; - this->_modelMetadataDescription = { - pFeaturesMetadataComponent->PropertyTables}; + this->_featuresDescription = pFeaturesMetadataComponent->Features; + this->_modelMetadataDescription = pFeaturesMetadataComponent->ModelMetadata; } else { this->_featuresDescription = {}; this->_modelMetadataDescription = {}; diff --git a/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp b/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp index 75760a677..af05088e9 100644 --- a/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp +++ b/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp @@ -119,7 +119,7 @@ std::optional encodeFeatureIdTexture( TRACE_CPUPROFILER_EVENT_SCOPE(Cesium::EncodeFeatureIdTexture) EncodedFeatureIdSet result; - EncodedFeatureIdTexture encodedFeatureIdTexture; + EncodedFeatureIdTexture& encodedFeatureIdTexture = result.texture.emplace(); encodedFeatureIdTexture.channels = featureIdTextureView.getChannels(); encodedFeatureIdTexture.textureCoordinateSetIndex = @@ -147,12 +147,12 @@ std::optional encodeFeatureIdTexture( encodedFeatureIdTexture.pTexture->filter = TextureFilter::TF_Nearest; if (!encodedFeatureIdTexture.pTexture->pTextureData) { - UE_LOG( - LogCesium, - Error, - TEXT( - "Error encoding a feature table property. Most likely could not allocate enough texture memory.")); - return std::nullopt; + UE_LOG( + LogCesium, + Error, + TEXT( + "Error encoding a feature ID texture. Most likely could not allocate enough texture memory.")); + return std::nullopt; } FTexture2DMipMap* pMip = new FTexture2DMipMap(); @@ -172,8 +172,6 @@ std::optional encodeFeatureIdTexture( pMip->BulkData.Unlock(); } - result.texture = encodedFeatureIdTexture; - return result; } } // namespace @@ -234,6 +232,7 @@ EncodedPrimitiveFeatures encodePrimitiveFeaturesAnyThreadPart( encodedSet->name = name; encodedSet->index = i; encodedSet->propertyTableName = pDescription->PropertyTableName; + result.featureIdSets.Add(*encodedSet); } diff --git a/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.h b/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.h index 7fe1b76d2..6f45dd805 100644 --- a/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.h +++ b/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.h @@ -35,6 +35,30 @@ struct FCesiumPrimitiveFeaturesDescription; */ namespace CesiumEncodedFeaturesMetadata { +/** + * Naming convention for encoded features + metadata material parameters + * + * Feature Id Textures: + * - Base: "FIT__"... + * - Texture: ..."TX" + * - Texture Coordinate Index: ..."UV" + * - Channel Mask: ..."CM" + * + * Feature Texture Properties: + * - Base: "FTX___"... + * - Texture: ..."TX" + * - Texture Coordinate Index: ..."UV" + * - Swizzle: ..."SW" + * + * Encoded Feature Table Properties: + * - Encoded Property Table: + * "FTB__" + */ +static const FString MaterialTextureSuffix = "_TX"; +static const FString MaterialTexCoordSuffix = "_UV"; +static const FString MaterialChannelsSuffix = "_CHANNELS"; +static const FString MaterialNumChannelsSuffix = "_NUM_CHANNELS"; + #pragma region Encoded Primitive Features /** diff --git a/Source/CesiumRuntime/Private/CesiumEncodedMetadataComponent.cpp b/Source/CesiumRuntime/Private/CesiumEncodedMetadataComponent.cpp deleted file mode 100644 index 56da11edb..000000000 --- a/Source/CesiumRuntime/Private/CesiumEncodedMetadataComponent.cpp +++ /dev/null @@ -1,900 +0,0 @@ -//// Copyright 2020-2021 CesiumGS, Inc. and Contributors -// -//#include "CesiumEncodedMetadataComponent.h" -//#include "Cesium3DTileset.h" -//#include "CesiumEncodedFeaturesMetadata.h" -//#include "CesiumPropertyTextureProperty.h" -//#include "CesiumGltfComponent.h" -//#include "CesiumGltfPrimitiveComponent.h" -//#include "CesiumMetadataConversions.h" -//#include "CesiumModelMetadata.h" -// -//#if WITH_EDITOR -//#include "AssetRegistry/AssetData.h" -//#include "AssetRegistry/AssetRegistryModule.h" -//#include "ComponentReregisterContext.h" -//#include "Containers/Map.h" -//#include "ContentBrowserModule.h" -//#include "Factories/MaterialFunctionMaterialLayerFactory.h" -//#include "IContentBrowserSingleton.h" -//#include "IMaterialEditor.h" -//#include "Materials/Material.h" -//#include "Materials/MaterialExpressionCustom.h" -//#include "Materials/MaterialExpressionFunctionInput.h" -//#include "Materials/MaterialExpressionFunctionOutput.h" -//#include "Materials/MaterialExpressionMaterialFunctionCall.h" -//#include "Materials/MaterialExpressionScalarParameter.h" -//#include "Materials/MaterialExpressionSetMaterialAttributes.h" -//#include "Materials/MaterialExpressionTextureCoordinate.h" -//#include "Materials/MaterialExpressionTextureObjectParameter.h" -//#include "Materials/MaterialExpressionTextureProperty.h" -//#include "Misc/PackageName.h" -//#include "Modules/ModuleManager.h" -//#include "Subsystems/AssetEditorSubsystem.h" -//#include "UObject/Package.h" -// -//extern UNREALED_API class UEditorEngine* GEditor; -//#endif -// -//using namespace CesiumEncodedMetadataUtility; -// -//void UCesiumEncodedMetadataComponent::AutoFill() { -// const ACesium3DTileset* pOwner = this->GetOwner(); -// if (!pOwner) { -// return; -// } -// -// for (const UActorComponent* pComponent : pOwner->GetComponents()) { -// const UCesiumGltfComponent* pGltf = Cast(pComponent); -// if (!pGltf) { -// continue; -// } -// -// const FCesiumMetadataModel& model = pGltf->Metadata; -// const TMap& featureTables = -// UCesiumMetadataModelBlueprintLibrary::GetFeatureTables(model); -// const TMap& featureTextures = -// UCesiumMetadataModelBlueprintLibrary::GetFeatureTextures(model); -// -// for (const auto& featureTableIt : featureTables) { -// const TMap& properties = -// UCesiumFeatureTableBlueprintLibrary::GetProperties( -// featureTableIt.Value); -// -// FFeatureTableDescription* pFeatureTable = -// this->FeatureTables.FindByPredicate( -// [&featureTableName = featureTableIt.Key]( -// const FFeatureTableDescription& existingFeatureTable) { -// return existingFeatureTable.Name == featureTableName; -// }); -// -// if (!pFeatureTable) { -// pFeatureTable = &this->FeatureTables.Emplace_GetRef(); -// pFeatureTable->Name = featureTableIt.Key; -// } -// -// for (const auto& propertyIt : properties) { -// if (pFeatureTable->Properties.FindByPredicate( -// [&propertyName = propertyIt.Key]( -// const FPropertyDescription& existingProperty) { -// return existingProperty.Name == propertyName; -// })) { -// // We have already filled this property. -// continue; -// } -// -// ECesiumMetadataTrueType type = -// UCesiumMetadataPropertyBlueprintLibrary::GetTrueType( -// propertyIt.Value); -// ECesiumMetadataTrueType componentType = -// UCesiumMetadataPropertyBlueprintLibrary::GetTrueComponentType( -// propertyIt.Value); -// int64 componentCount; -// -// ECesiumMetadataPackedGpuType gpuType = -// ECesiumMetadataPackedGpuType::None; -// if (type == ECesiumMetadataTrueType::Array) { -// gpuType = CesiumMetadataTrueTypeToDefaultPackedGpuType(componentType); -// componentCount = -// UCesiumMetadataPropertyBlueprintLibrary::GetComponentCount( -// propertyIt.Value); -// } else { -// gpuType = CesiumMetadataTrueTypeToDefaultPackedGpuType(type); -// componentCount = 1; -// } -// -// if (gpuType == ECesiumMetadataPackedGpuType::None) { -// continue; -// } -// -// FPropertyDescription& property = -// pFeatureTable->Properties.Emplace_GetRef(); -// property.Name = propertyIt.Key; -// -// switch (componentCount) { -// case 2: -// property.Type = ECesiumPropertyType::Vec2; -// break; -// case 3: -// property.Type = ECesiumPropertyType::Vec3; -// break; -// case 4: -// property.Type = ECesiumPropertyType::Vec4; -// break; -// default: -// property.Type = ECesiumPropertyType::Scalar; -// }; -// -// if (gpuType == ECesiumMetadataPackedGpuType::Uint8) { -// property.ComponentType = ECesiumPropertyComponentType::Uint8; -// } else /*if (gpuType == float)*/ { -// property.ComponentType = ECesiumPropertyComponentType::Float; -// } -// -// property.Normalized = -// UCesiumMetadataPropertyBlueprintLibrary::IsNormalized( -// propertyIt.Value); -// } -// } -// -// for (const auto& featureTextureIt : featureTextures) { -// FFeatureTextureDescription* pFeatureTexture = -// this->FeatureTextures.FindByPredicate( -// [&featureTextureName = featureTextureIt.Key]( -// const FFeatureTextureDescription& existingFeatureTexture) { -// return existingFeatureTexture.Name == featureTextureName; -// }); -// -// if (!pFeatureTexture) { -// pFeatureTexture = &this->FeatureTextures.Emplace_GetRef(); -// pFeatureTexture->Name = featureTextureIt.Key; -// } -// -// const TArray& propertyNames = -// UCesiumFeatureTextureBlueprintLibrary::GetPropertyKeys( -// featureTextureIt.Value); -// -// for (const FString& propertyName : propertyNames) { -// if (pFeatureTexture->Properties.FindByPredicate( -// [&propertyName](const FFeatureTexturePropertyDescription& -// existingProperty) { -// return propertyName == existingProperty.Name; -// })) { -// // We have already filled this property. -// continue; -// } -// -// FCesiumFeatureTextureProperty property = -// UCesiumFeatureTextureBlueprintLibrary::FindProperty( -// featureTextureIt.Value, -// propertyName); -// FFeatureTexturePropertyDescription& propertyDescription = -// pFeatureTexture->Properties.Emplace_GetRef(); -// propertyDescription.Name = propertyName; -// propertyDescription.Normalized = -// UCesiumFeatureTexturePropertyBlueprintLibrary::IsNormalized( -// property); -// -// switch ( -// UCesiumFeatureTexturePropertyBlueprintLibrary::GetComponentCount( -// property)) { -// case 2: -// propertyDescription.Type = ECesiumPropertyType::Vec2; -// break; -// case 3: -// propertyDescription.Type = ECesiumPropertyType::Vec3; -// break; -// case 4: -// propertyDescription.Type = ECesiumPropertyType::Vec4; -// break; -// // case 1: -// default: -// propertyDescription.Type = ECesiumPropertyType::Scalar; -// } -// -// propertyDescription.Swizzle = -// UCesiumFeatureTexturePropertyBlueprintLibrary::GetSwizzle(property); -// } -// } -// } -// -// for (const UActorComponent* pComponent : pOwner->GetComponents()) { -// const UCesiumGltfPrimitiveComponent* pGltfPrimitive = -// Cast(pComponent); -// if (!pGltfPrimitive) { -// continue; -// } -// -// const FCesiumMetadataPrimitive& primitive = pGltfPrimitive->Metadata; -// const TArray& attributes = -// UCesiumMetadataPrimitiveBlueprintLibrary::GetFeatureIdAttributes( -// primitive); -// const TArray& textures = -// UCesiumMetadataPrimitiveBlueprintLibrary::GetFeatureIdTextures( -// primitive); -// -// for (const FCesiumFeatureIdAttribute& attribute : attributes) { -// const FString& featureTableName = -// UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureTableName( -// attribute); -// for (FFeatureTableDescription& featureTable : this->FeatureTables) { -// if (featureTableName == featureTable.Name) { -// if (featureTable.AccessType == -// ECesiumFeatureTableAccessType::Unknown) { -// featureTable.AccessType = ECesiumFeatureTableAccessType::Attribute; -// } -// -// break; -// } -// } -// } -// -// for (const FCesiumFeatureIdTexture& texture : textures) { -// const FString& featureTableName = -// UCesiumFeatureIdTextureBlueprintLibrary::GetFeatureTableName(texture); -// for (FFeatureTableDescription& featureTable : this->FeatureTables) { -// if (featureTableName == featureTable.Name) { -// if (featureTable.AccessType == -// ECesiumFeatureTableAccessType::Unknown) { -// featureTable.AccessType = ECesiumFeatureTableAccessType::Texture; -// switch (texture.getFeatureIdTextureView().getChannel()) { -// case 1: -// featureTable.Channel = "g"; -// break; -// case 2: -// featureTable.Channel = "b"; -// break; -// case 3: -// featureTable.Channel = "a"; -// break; -// // case 0: -// default: -// featureTable.Channel = "r"; -// } -// } else if ( -// featureTable.AccessType == -// ECesiumFeatureTableAccessType::Attribute) { -// featureTable.AccessType = ECesiumFeatureTableAccessType::Mixed; -// } -// -// break; -// } -// } -// } -// } -//} -// -//#if WITH_EDITOR -//template -//static FORCEINLINE ObjClass* LoadObjFromPath(const FName& Path) { -// if (Path == NAME_None) -// return nullptr; -// -// return Cast( -// StaticLoadObject(ObjClass::StaticClass(), nullptr, *Path.ToString())); -//} -// -//static FORCEINLINE UMaterialFunction* LoadMaterialFunction(const FName& Path) { -// if (Path == NAME_None) -// return nullptr; -// -// return LoadObjFromPath(Path); -//} -// -//// Seperate nodes into auto-generated and user-added. Collect the property -//// result nodes. -//static void ClassifyNodes( -// UMaterialFunctionMaterialLayer* Layer, -// TArray& AutoGeneratedNodes, -// TArray& UserAddedNodes, -// TArray& ResultNodes) { -// -//#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 0 -// for (UMaterialExpression* Node : Layer->FunctionExpressions) { -//#else -// for (const TObjectPtr& Node : -// Layer->GetExpressionCollection().Expressions) { -//#endif -// // Check if this node is marked as autogenerated. -// if (Node->Desc.StartsWith( -// "AUTOGENERATED DO NOT EDIT", -// ESearchCase::Type::CaseSensitive)) { -// AutoGeneratedNodes.Add(Node); -// -// // The only auto-generated custom nodes are the property result nodes. -// UMaterialExpressionCustom* CustomNode = -// Cast(Node); -// if (CustomNode) { -// ResultNodes.Add(CustomNode); -// } -// } else { -// UserAddedNodes.Add(Node); -// } -// } -//} -// -//static void ClearAutoGeneratedNodes( -// UMaterialFunctionMaterialLayer* Layer, -// TMap>& ConnectionRemap) { -// -// TArray AutoGeneratedNodes; -// TArray UserAddedNodes; -// TArray ResultNodes; -// ClassifyNodes(Layer, AutoGeneratedNodes, UserAddedNodes, ResultNodes); -// -// // Determine which user-added connections to remap when regenerating the -// // auto-generated nodes. -// for (const UMaterialExpressionCustom* ResultNode : ResultNodes) { -// int32 OutputIndex = 0; -// for (const FExpressionOutput& PropertyOutput : ResultNode->Outputs) { -// FString Key = -// ResultNode->Description + PropertyOutput.OutputName.ToString(); -// -// // Look for user-made connections to this property. -// TArray Connections; -// for (UMaterialExpression* UserNode : UserAddedNodes) { -// for (FExpressionInput* Input : UserNode->GetInputs()) { -// if (Input->Expression == ResultNode && -// Input->OutputIndex == OutputIndex) { -// Connections.Add(Input); -// Input->Expression = nullptr; -// } -// } -// } -// -// ConnectionRemap.Emplace(MoveTemp(Key), MoveTemp(Connections)); -// ++OutputIndex; -// } -// } -// -// // Remove auto-generated nodes. -// for (UMaterialExpression* AutoGeneratedNode : AutoGeneratedNodes) { -//#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 0 -// Layer->FunctionExpressions.Remove(AutoGeneratedNode); -//#else -// Layer->GetExpressionCollection().RemoveExpression(AutoGeneratedNode); -//#endif -// } -//} -// -//static void RemapUserConnections( -// UMaterialFunctionMaterialLayer* Layer, -// TMap>& ConnectionRemap) { -// -// TArray AutoGeneratedNodes; -// TArray UserAddedNodes; -// TArray ResultNodes; -// ClassifyNodes(Layer, AutoGeneratedNodes, UserAddedNodes, ResultNodes); -// -// for (UMaterialExpressionCustom* ResultNode : ResultNodes) { -// int32 OutputIndex = 0; -// for (const FExpressionOutput& PropertyOutput : ResultNode->Outputs) { -// FString Key = -// ResultNode->Description + PropertyOutput.OutputName.ToString(); -// -// TArray* pConnections = ConnectionRemap.Find(Key); -// if (pConnections) { -// for (FExpressionInput* pConnection : *pConnections) { -// pConnection->Expression = ResultNode; -// pConnection->OutputIndex = OutputIndex; -// } -// } -// -// ++OutputIndex; -// } -// } -//} -// -//void UCesiumEncodedMetadataComponent::GenerateMaterial() { -// ACesium3DTileset* pTileset = Cast(this->GetOwner()); -// -// if (!pTileset) { -// return; -// } -// -// FString MaterialName = "ML_" + pTileset->GetFName().ToString() + "_Metadata"; -// FString PackageBaseName = "/Game/"; -// FString PackageName = PackageBaseName + MaterialName; -// -// UMaterialFunction* SelectTexCoordsFunction = LoadMaterialFunction( -// "/CesiumForUnreal/Materials/MaterialFunctions/CesiumSelectTexCoords.CesiumSelectTexCoords"); -// if (!SelectTexCoordsFunction) { -// return; -// } -// -// bool Overwriting = false; -// if (this->TargetMaterialLayer) { -// // Overwriting an existing material layer. -// Overwriting = true; -// GEditor->GetEditorSubsystem() -// ->CloseAllEditorsForAsset(this->TargetMaterialLayer); -// } else { -// UPackage* Package = CreatePackage(*PackageName); -// -// // Create an unreal material asset -// UMaterialFunctionMaterialLayerFactory* MaterialFactory = -// NewObject(); -// this->TargetMaterialLayer = -// (UMaterialFunctionMaterialLayer*)MaterialFactory->FactoryCreateNew( -// UMaterialFunctionMaterialLayer::StaticClass(), -// Package, -// *MaterialName, -// RF_Standalone | RF_Transactional, -// NULL, -// GWarn); -// FAssetRegistryModule::AssetCreated(this->TargetMaterialLayer); -// Package->FullyLoad(); -// Package->SetDirtyFlag(true); -// } -// -// this->TargetMaterialLayer->PreEditChange(NULL); -// -// TMap> ConnectionRemap; -// ClearAutoGeneratedNodes(this->TargetMaterialLayer, ConnectionRemap); -// -// TArray AutoGeneratedNodes; -// TArray OneTimeGeneratedNodes; -// -// const int32 IncrX = 400; -// const int32 IncrY = 200; -// int32 NodeX = 0; -// int32 NodeY = 0; -// -// for (const FFeatureTableDescription& featureTable : this->FeatureTables) { -// if (featureTable.AccessType == ECesiumFeatureTableAccessType::Unknown || -// featureTable.AccessType == ECesiumFeatureTableAccessType::Mixed) { -// continue; -// } -// -// int32 SectionLeft = NodeX; -// int32 SectionTop = NodeY; -// -// UMaterialExpressionCustom* FeatureTableLookup = -// NewObject(this->TargetMaterialLayer); -// FeatureTableLookup->Inputs.Reserve(featureTable.Properties.Num() + 2); -// FeatureTableLookup->Outputs.Reset(featureTable.Properties.Num() + 1); -// FeatureTableLookup->Outputs.Add(FExpressionOutput(TEXT("return"))); -// FeatureTableLookup->bShowOutputNameOnPin = true; -// FeatureTableLookup->Description = -// "Resolve properties from " + featureTable.Name; -// AutoGeneratedNodes.Add(FeatureTableLookup); -// -// if (featureTable.AccessType == ECesiumFeatureTableAccessType::Texture) { -// UMaterialExpressionTextureObjectParameter* FeatureIdTexture = -// NewObject( -// this->TargetMaterialLayer); -// FeatureIdTexture->ParameterName = -// FName("FIT_" + featureTable.Name + "_TX"); -// FeatureIdTexture->MaterialExpressionEditorX = NodeX; -// FeatureIdTexture->MaterialExpressionEditorY = NodeY; -// AutoGeneratedNodes.Add(FeatureIdTexture); -// -// FCustomInput& FeatureIdTextureInput = FeatureTableLookup->Inputs[0]; -// FeatureIdTextureInput.InputName = "FeatureIdTexture"; -// FeatureIdTextureInput.Input.Expression = FeatureIdTexture; -// -// NodeY += IncrY; -// -// UMaterialExpressionScalarParameter* TexCoordsIndex = -// NewObject( -// this->TargetMaterialLayer); -// TexCoordsIndex->ParameterName = FName("FIT_" + featureTable.Name + "_UV"); -// TexCoordsIndex->DefaultValue = 0.0f; -// TexCoordsIndex->MaterialExpressionEditorX = NodeX; -// TexCoordsIndex->MaterialExpressionEditorY = NodeY; -// AutoGeneratedNodes.Add(TexCoordsIndex); -// -// NodeX += IncrX; -// -// UMaterialExpressionMaterialFunctionCall* SelectTexCoords = -// NewObject( -// this->TargetMaterialLayer); -// SelectTexCoords->MaterialFunction = SelectTexCoordsFunction; -// SelectTexCoords->MaterialExpressionEditorX = NodeX; -// SelectTexCoords->MaterialExpressionEditorY = NodeY; -// -// SelectTexCoordsFunction->GetInputsAndOutputs( -// SelectTexCoords->FunctionInputs, -// SelectTexCoords->FunctionOutputs); -// SelectTexCoords->FunctionInputs[0].Input.Expression = TexCoordsIndex; -// AutoGeneratedNodes.Add(SelectTexCoords); -// -// FCustomInput& TexCoordsInput = -// FeatureTableLookup->Inputs.Emplace_GetRef(); -// TexCoordsInput.InputName = FName("TexCoords"); -// TexCoordsInput.Input.Expression = SelectTexCoords; -// -// NodeX += IncrX; -// -// // TODO: Should the channel mask be determined dynamically instead of at -// // editor-time like it is now? -// FeatureTableLookup->Code = -// "uint _czm_propertyIndex = asuint(FeatureIdTexture.Sample(FeatureIdTextureSampler, TexCoords)." + -// featureTable.Channel + ");\n"; -// -// FeatureTableLookup->MaterialExpressionEditorX = NodeX; -// FeatureTableLookup->MaterialExpressionEditorY = NodeY; -// } else { -// // Create material for vertex attributes -// -// UMaterialExpressionScalarParameter* AttributeIndex = -// NewObject( -// this->TargetMaterialLayer); -// AttributeIndex->ParameterName = FName("FA_" + featureTable.Name); -// AttributeIndex->DefaultValue = 0.0f; -// AttributeIndex->MaterialExpressionEditorX = NodeX; -// AttributeIndex->MaterialExpressionEditorY = NodeY; -// AutoGeneratedNodes.Add(AttributeIndex); -// -// NodeX += IncrX; -// -// UMaterialExpressionMaterialFunctionCall* SelectTexCoords = -// NewObject( -// this->TargetMaterialLayer); -// SelectTexCoords->MaterialFunction = SelectTexCoordsFunction; -// SelectTexCoords->MaterialExpressionEditorX = NodeX; -// SelectTexCoords->MaterialExpressionEditorY = NodeY; -// -// SelectTexCoordsFunction->GetInputsAndOutputs( -// SelectTexCoords->FunctionInputs, -// SelectTexCoords->FunctionOutputs); -// SelectTexCoords->FunctionInputs[0].Input.Expression = AttributeIndex; -// AutoGeneratedNodes.Add(SelectTexCoords); -// -// FCustomInput& TexCoordsInput = FeatureTableLookup->Inputs[0]; -// TexCoordsInput.InputName = FName("PropertyIndexUV"); -// TexCoordsInput.Input.Expression = SelectTexCoords; -// -// NodeX += IncrX; -// -// FeatureTableLookup->Code = -// "uint _czm_propertyIndex = round(PropertyIndexUV.r);\n"; -// -// FeatureTableLookup->MaterialExpressionEditorX = NodeX; -// FeatureTableLookup->MaterialExpressionEditorY = NodeY; -// } -// -// // Get the pixel dimensions of the first property, all the properties will -// // have the same dimensions since it is based on the feature count. -// if (featureTable.Properties.Num()) { -// const FPropertyDescription& property = featureTable.Properties[0]; -// FString propertyArrayName = createHlslSafeName(property.Name) + "_array"; -// -// FeatureTableLookup->Code += "uint _czm_width;\nuint _czm_height;\n"; -// FeatureTableLookup->Code += -// propertyArrayName + ".GetDimensions(_czm_width, _czm_height);\n"; -// FeatureTableLookup->Code += -// "uint _czm_pixelX = _czm_propertyIndex % _czm_width;\n"; -// FeatureTableLookup->Code += -// "uint _czm_pixelY = _czm_propertyIndex / _czm_width;\n"; -// } -// -// NodeX = SectionLeft; -// NodeY += IncrY; -// -// FeatureTableLookup->AdditionalOutputs.Reserve( -// featureTable.Properties.Num()); -// for (const FPropertyDescription& property : featureTable.Properties) { -// UMaterialExpressionTextureObjectParameter* PropertyArray = -// NewObject( -// this->TargetMaterialLayer); -// PropertyArray->ParameterName = -// FName("FTB_" + featureTable.Name + "_" + property.Name); -// PropertyArray->MaterialExpressionEditorX = NodeX; -// PropertyArray->MaterialExpressionEditorY = NodeY; -// AutoGeneratedNodes.Add(PropertyArray); -// -// FString propertyName = createHlslSafeName(property.Name); -// -// FCustomInput& PropertyInput = FeatureTableLookup->Inputs.Emplace_GetRef(); -// FString propertyArrayName = propertyName + "_array"; -// PropertyInput.InputName = FName(propertyArrayName); -// PropertyInput.Input.Expression = PropertyArray; -// -// FCustomOutput& PropertyOutput = -// FeatureTableLookup->AdditionalOutputs.Emplace_GetRef(); -// PropertyOutput.OutputName = FName(propertyName); -// FeatureTableLookup->Outputs.Add( -// FExpressionOutput(PropertyOutput.OutputName)); -// -// FString swizzle = ""; -// switch (property.Type) { -// case ECesiumPropertyType::Vec2: -// PropertyOutput.OutputType = ECustomMaterialOutputType::CMOT_Float2; -// swizzle = "rg"; -// break; -// case ECesiumPropertyType::Vec3: -// PropertyOutput.OutputType = ECustomMaterialOutputType::CMOT_Float3; -// swizzle = "rgb"; -// break; -// case ECesiumPropertyType::Vec4: -// PropertyOutput.OutputType = ECustomMaterialOutputType::CMOT_Float4; -// swizzle = "rgba"; -// break; -// // case ECesiumPropertyType::Scalar: -// default: -// PropertyOutput.OutputType = ECustomMaterialOutputType::CMOT_Float1; -// swizzle = "r"; -// }; -// -// FString componentTypeInterpretation = -// property.ComponentType == ECesiumPropertyComponentType::Float -// ? "asfloat" -// : "asuint"; -// -// FeatureTableLookup->Code += -// propertyName + " = " + componentTypeInterpretation + "(" + -// propertyArrayName + ".Load(int3(_czm_pixelX, _czm_pixelY, 0))." + -// swizzle + ");\n"; -// -// NodeY += IncrY; -// } -// -// FeatureTableLookup->OutputType = ECustomMaterialOutputType::CMOT_Float1; -// -// FeatureTableLookup->Code += -// "float _czm_propertyIndexF = _czm_propertyIndex;\n"; -// FeatureTableLookup->Code += "return _czm_propertyIndexF;"; -// -// NodeX = SectionLeft; -// } -// -// for (const FFeatureTextureDescription& featureTexture : -// this->FeatureTextures) { -// int32 SectionLeft = NodeX; -// int32 SectionTop = NodeY; -// -// UMaterialExpressionCustom* FeatureTextureLookup = -// NewObject(this->TargetMaterialLayer); -// FeatureTextureLookup->Inputs.Reset(2 * featureTexture.Properties.Num()); -// FeatureTextureLookup->Outputs.Reset(featureTexture.Properties.Num() + 1); -// FeatureTextureLookup->Outputs.Add(FExpressionOutput(TEXT("return"))); -// FeatureTextureLookup->bShowOutputNameOnPin = true; -// FeatureTextureLookup->Code = ""; -// FeatureTextureLookup->Description = -// "Resolve properties from " + featureTexture.Name; -// FeatureTextureLookup->MaterialExpressionEditorX = NodeX + 2 * IncrX; -// FeatureTextureLookup->MaterialExpressionEditorY = NodeY; -// AutoGeneratedNodes.Add(FeatureTextureLookup); -// -// for (const FFeatureTexturePropertyDescription& property : -// featureTexture.Properties) { -// UMaterialExpressionTextureObjectParameter* PropertyTexture = -// NewObject( -// this->TargetMaterialLayer); -// PropertyTexture->ParameterName = -// FName("FTX_" + featureTexture.Name + "_" + property.Name + "_TX"); -// PropertyTexture->MaterialExpressionEditorX = NodeX; -// PropertyTexture->MaterialExpressionEditorY = NodeY; -// AutoGeneratedNodes.Add(PropertyTexture); -// -// FString propertyName = createHlslSafeName(property.Name); -// -// FCustomInput& PropertyTextureInput = -// FeatureTextureLookup->Inputs.Emplace_GetRef(); -// FString propertyTextureName = propertyName + "_TX"; -// PropertyTextureInput.InputName = FName(propertyTextureName); -// PropertyTextureInput.Input.Expression = PropertyTexture; -// -// NodeY += IncrY; -// -// UMaterialExpressionScalarParameter* TexCoordsIndex = -// NewObject( -// this->TargetMaterialLayer); -// TexCoordsIndex->ParameterName = -// FName("FTX_" + featureTexture.Name + "_" + property.Name + "_UV"); -// TexCoordsIndex->DefaultValue = 0.0f; -// TexCoordsIndex->MaterialExpressionEditorX = NodeX; -// TexCoordsIndex->MaterialExpressionEditorY = NodeY; -// AutoGeneratedNodes.Add(TexCoordsIndex); -// -// NodeX += IncrX; -// -// UMaterialExpressionMaterialFunctionCall* SelectTexCoords = -// NewObject( -// this->TargetMaterialLayer); -// SelectTexCoords->MaterialFunction = SelectTexCoordsFunction; -// SelectTexCoords->MaterialExpressionEditorX = NodeX; -// SelectTexCoords->MaterialExpressionEditorY = NodeY; -// -// SelectTexCoordsFunction->GetInputsAndOutputs( -// SelectTexCoords->FunctionInputs, -// SelectTexCoords->FunctionOutputs); -// SelectTexCoords->FunctionInputs[0].Input.Expression = TexCoordsIndex; -// AutoGeneratedNodes.Add(SelectTexCoords); -// -// FCustomInput& TexCoordsInput = -// FeatureTextureLookup->Inputs.Emplace_GetRef(); -// FString propertyUvName = propertyName + "_UV"; -// TexCoordsInput.InputName = FName(propertyUvName); -// TexCoordsInput.Input.Expression = SelectTexCoords; -// -// FCustomOutput& PropertyOutput = -// FeatureTextureLookup->AdditionalOutputs.Emplace_GetRef(); -// PropertyOutput.OutputName = FName(propertyName); -// FeatureTextureLookup->Outputs.Add( -// FExpressionOutput(PropertyOutput.OutputName)); -// -// // Either the property is normalized or it is coerced into float. Either -// // way, the outputs will be float type. -// switch (property.Type) { -// case ECesiumPropertyType::Vec2: -// PropertyOutput.OutputType = ECustomMaterialOutputType::CMOT_Float2; -// break; -// case ECesiumPropertyType::Vec3: -// PropertyOutput.OutputType = ECustomMaterialOutputType::CMOT_Float3; -// break; -// case ECesiumPropertyType::Vec4: -// PropertyOutput.OutputType = ECustomMaterialOutputType::CMOT_Float4; -// break; -// // case ECesiumPropertyType::Scalar: -// default: -// PropertyOutput.OutputType = ECustomMaterialOutputType::CMOT_Float1; -// }; -// -// // TODO: should dynamic channel offsets be used instead of swizzle string -// // determined at editor time? E.g. can swizzles be different for the same -// // property texture on different tiles? -// FeatureTextureLookup->Code += -// propertyName + " = " + -// (property.Normalized ? "asfloat(" : "asuint(") + propertyTextureName + -// ".Sample(" + propertyTextureName + "Sampler, " + propertyUvName + -// ")." + property.Swizzle + ");\n"; -// -// NodeY += IncrY; -// } -// -// FeatureTextureLookup->OutputType = ECustomMaterialOutputType::CMOT_Float1; -// FeatureTextureLookup->Code += "return 0.0f;"; -// -// NodeX = SectionLeft; -// } -// -// NodeY = -IncrY; -// -// UMaterialExpressionFunctionInput* InputMaterial = nullptr; -//#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 0 -// for (UMaterialExpression* ExistingNode : -// this->TargetMaterialLayer->FunctionExpressions) { -//#else -// for (const TObjectPtr& ExistingNode : -// this->TargetMaterialLayer->GetExpressionCollection().Expressions) { -//#endif -// UMaterialExpressionFunctionInput* ExistingInputMaterial = -// Cast(ExistingNode); -// if (ExistingInputMaterial) { -// InputMaterial = ExistingInputMaterial; -// break; -// } -// } -// -// if (!InputMaterial) { -// InputMaterial = -// NewObject(this->TargetMaterialLayer); -// InputMaterial->InputType = -// EFunctionInputType::FunctionInput_MaterialAttributes; -// InputMaterial->bUsePreviewValueAsDefault = true; -// InputMaterial->MaterialExpressionEditorX = NodeX; -// InputMaterial->MaterialExpressionEditorY = NodeY; -// OneTimeGeneratedNodes.Add(InputMaterial); -// } -// -// NodeX += 4 * IncrX; -// -// UMaterialExpressionSetMaterialAttributes* SetMaterialAttributes = nullptr; -//#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 0 -// for (UMaterialExpression* ExistingNode : -// this->TargetMaterialLayer->FunctionExpressions) { -//#else -// for (const TObjectPtr& ExistingNode : -// this->TargetMaterialLayer->GetExpressionCollection().Expressions) { -//#endif -// UMaterialExpressionSetMaterialAttributes* ExistingSetAttributes = -// Cast(ExistingNode); -// if (ExistingSetAttributes) { -// SetMaterialAttributes = ExistingSetAttributes; -// break; -// } -// } -// -// if (!SetMaterialAttributes) { -// SetMaterialAttributes = NewObject( -// this->TargetMaterialLayer); -// OneTimeGeneratedNodes.Add(SetMaterialAttributes); -// } -// -// SetMaterialAttributes->Inputs[0].Expression = InputMaterial; -// SetMaterialAttributes->MaterialExpressionEditorX = NodeX; -// SetMaterialAttributes->MaterialExpressionEditorY = NodeY; -// -// NodeX += IncrX; -// -// UMaterialExpressionFunctionOutput* OutputMaterial = nullptr; -//#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 0 -// for (UMaterialExpression* ExistingNode : -// this->TargetMaterialLayer->FunctionExpressions) { -//#else -// for (const TObjectPtr& ExistingNode : -// this->TargetMaterialLayer->GetExpressionCollection().Expressions) { -//#endif -// UMaterialExpressionFunctionOutput* ExistingOutputMaterial = -// Cast(ExistingNode); -// if (ExistingOutputMaterial) { -// OutputMaterial = ExistingOutputMaterial; -// break; -// } -// } -// -// if (!OutputMaterial) { -// OutputMaterial = -// NewObject(this->TargetMaterialLayer); -// OneTimeGeneratedNodes.Add(OutputMaterial); -// } -// -// OutputMaterial->MaterialExpressionEditorX = NodeX; -// OutputMaterial->MaterialExpressionEditorY = NodeY; -// OutputMaterial->A = FMaterialAttributesInput(); -// OutputMaterial->A.Expression = SetMaterialAttributes; -// -// for (UMaterialExpression* AutoGeneratedNode : AutoGeneratedNodes) { -//#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 0 -// this->TargetMaterialLayer->FunctionExpressions.Add(AutoGeneratedNode); -//#else -// this->TargetMaterialLayer->GetExpressionCollection().AddExpression( -// AutoGeneratedNode); -//#endif -// // Mark as auto-generated. If the material is regenerated, we will look for -// // this exact description to determine whether it was autogenerated. -// // Completely open to suggestions of how else to mark custom information on -// // these assets :) -// AutoGeneratedNode->Desc = "AUTOGENERATED DO NOT EDIT"; -// } -// -// for (UMaterialExpression* OneTimeGeneratedNode : OneTimeGeneratedNodes) { -//#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 0 -// this->TargetMaterialLayer->FunctionExpressions.Add(OneTimeGeneratedNode); -//#else -// this->TargetMaterialLayer->GetExpressionCollection().AddExpression( -// OneTimeGeneratedNode); -//#endif -// } -// -// RemapUserConnections(this->TargetMaterialLayer, ConnectionRemap); -// -// // let the material update itself if necessary -// this->TargetMaterialLayer->PostEditChange(); -// -// // make sure that any static meshes, etc using this material will stop using -// // the FMaterialResource of the original material, and will use the new -// // FMaterialResource created when we make a new UMaterial in place -// FGlobalComponentReregisterContext RecreateComponents; -// -// // If this is a new material open the content browser to the auto-generated -// // material. -// if (!Overwriting) { -// FContentBrowserModule* pContentBrowserModule = -// FModuleManager::Get().GetModulePtr( -// "ContentBrowser"); -// if (pContentBrowserModule) { -// TArray AssetsToHighlight; -// AssetsToHighlight.Add(this->TargetMaterialLayer); -// pContentBrowserModule->Get().SyncBrowserToAssets(AssetsToHighlight); -// } -// } -// -// // Open updated material in editor. -// if (GEditor) { -// UAssetEditorSubsystem* pAssetEditor = -// GEditor->GetEditorSubsystem(); -// if (pAssetEditor) { -// pAssetEditor->OpenEditorForAsset(this->TargetMaterialLayer); -// IMaterialEditor* pMaterialEditor = static_cast( -// pAssetEditor->FindEditorForAsset(this->TargetMaterialLayer, true)); -// if (pMaterialEditor) { -// pMaterialEditor->UpdateMaterialAfterGraphChange(); -// } -// } -// } -//} -// -//#endif // WITH_EDITOR diff --git a/Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp b/Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp index 20a07cbbc..7b298625f 100644 --- a/Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp +++ b/Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp @@ -27,6 +27,7 @@ #include "Materials/MaterialExpressionTextureCoordinate.h" #include "Materials/MaterialExpressionTextureObjectParameter.h" #include "Materials/MaterialExpressionTextureProperty.h" +#include "Materials/MaterialExpressionVectorParameter.h" #include "Misc/PackageName.h" #include "Modules/ModuleManager.h" #include "Subsystems/AssetEditorSubsystem.h" @@ -133,6 +134,71 @@ void AutoFillPropertyTableDescriptions( } } +void AutoFillPropertyTextureDescriptions() { + // const TMap& featureTextures = + // UCesiumMetadataModelBlueprintLibrary::GetFeatureTextures(model); + + // for (const auto& featureTextureIt : featureTextures) { + // FFeatureTextureDescription* pFeatureTexture = + // this->FeatureTextures.FindByPredicate( + // [&featureTextureName = featureTextureIt.Key]( + // const FFeatureTextureDescription& existingFeatureTexture) { + // return existingFeatureTexture.Name == featureTextureName; + // }); + + // if (!pFeatureTexture) { + // pFeatureTexture = &this->FeatureTextures.Emplace_GetRef(); + // pFeatureTexture->Name = featureTextureIt.Key; + // } + + // const TArray& propertyNames = + // UCesiumFeatureTextureBlueprintLibrary::GetPropertyKeys( + // featureTextureIt.Value); + + // for (const FString& propertyName : propertyNames) { + // if (pFeatureTexture->Properties.FindByPredicate( + // [&propertyName](const FFeatureTexturePropertyDescription& + // existingProperty) { + // return propertyName == existingProperty.Name; + // })) { + // // We have already filled this property. + // continue; + // } + + // FCesiumPropertyTextureProperty property = + // UCesiumPropertyTextureBlueprintLibrary::FindProperty( + // featureTextureIt.Value, + // propertyName); + // FFeatureTexturePropertyDescription& propertyDescription = + // pFeatureTexture->Properties.Emplace_GetRef(); + // propertyDescription.Name = propertyName; + // propertyDescription.Normalized = + // UCesiumPropertyTexturePropertyBlueprintLibrary::IsNormalized( + // property); + + // switch ( + // UCesiumPropertyTexturePropertyBlueprintLibrary::GetComponentCount( + // property)) { + // case 2: + // propertyDescription.Type = ECesiumPropertyType::Vec2; + // break; + // case 3: + // propertyDescription.Type = ECesiumPropertyType::Vec3; + // break; + // case 4: + // propertyDescription.Type = ECesiumPropertyType::Vec4; + // break; + // // case 1: + // default: + // propertyDescription.Type = ECesiumPropertyType::Scalar; + // } + + // propertyDescription.Swizzle = + // UCesiumFeatureTexturePropertyBlueprintLibrary::GetSwizzle(property); + // } + //} +} + void AutoFillFeatureIdSetDescriptions( TArray& Descriptions, const FCesiumPrimitiveFeatures& Features, @@ -197,7 +263,7 @@ void UCesiumFeaturesMetadataComponent::AutoFill() { } const FCesiumModelMetadata& modelMetadata = pGltf->Metadata; - AutoFillPropertyTableDescriptions(this->PropertyTables, modelMetadata); + AutoFillPropertyTableDescriptions(this->ModelMetadata.PropertyTables, modelMetadata); TArray childComponents; pGltf->GetChildrenComponents(false, childComponents); @@ -215,73 +281,10 @@ void UCesiumFeaturesMetadataComponent::AutoFill() { UCesiumModelMetadataBlueprintLibrary::GetPropertyTables( modelMetadata); AutoFillFeatureIdSetDescriptions( - this->FeatureIdSets, + this->Features.FeatureIdSets, primitiveFeatures, propertyTables); } - - // const TMap& featureTextures = - // UCesiumMetadataModelBlueprintLibrary::GetFeatureTextures(model); - - // for (const auto& featureTextureIt : featureTextures) { - // FFeatureTextureDescription* pFeatureTexture = - // this->FeatureTextures.FindByPredicate( - // [&featureTextureName = featureTextureIt.Key]( - // const FFeatureTextureDescription& existingFeatureTexture) { - // return existingFeatureTexture.Name == featureTextureName; - // }); - - // if (!pFeatureTexture) { - // pFeatureTexture = &this->FeatureTextures.Emplace_GetRef(); - // pFeatureTexture->Name = featureTextureIt.Key; - // } - - // const TArray& propertyNames = - // UCesiumFeatureTextureBlueprintLibrary::GetPropertyKeys( - // featureTextureIt.Value); - - // for (const FString& propertyName : propertyNames) { - // if (pFeatureTexture->Properties.FindByPredicate( - // [&propertyName](const FFeatureTexturePropertyDescription& - // existingProperty) { - // return propertyName == existingProperty.Name; - // })) { - // // We have already filled this property. - // continue; - // } - - // FCesiumPropertyTextureProperty property = - // UCesiumPropertyTextureBlueprintLibrary::FindProperty( - // featureTextureIt.Value, - // propertyName); - // FFeatureTexturePropertyDescription& propertyDescription = - // pFeatureTexture->Properties.Emplace_GetRef(); - // propertyDescription.Name = propertyName; - // propertyDescription.Normalized = - // UCesiumPropertyTexturePropertyBlueprintLibrary::IsNormalized( - // property); - - // switch ( - // UCesiumPropertyTexturePropertyBlueprintLibrary::GetComponentCount( - // property)) { - // case 2: - // propertyDescription.Type = ECesiumPropertyType::Vec2; - // break; - // case 3: - // propertyDescription.Type = ECesiumPropertyType::Vec3; - // break; - // case 4: - // propertyDescription.Type = ECesiumPropertyType::Vec4; - // break; - // // case 1: - // default: - // propertyDescription.Type = ECesiumPropertyType::Scalar; - // } - - // propertyDescription.Swizzle = - // UCesiumFeatureTexturePropertyBlueprintLibrary::GetSwizzle(property); - // } - //} } } @@ -415,8 +418,10 @@ void GenerateNodesForFeatureIdSets( TArray& AutoGeneratedNodes, UMaterialFunctionMaterialLayer* TargetMaterialLayer, UMaterialFunction* GetFeatureIdsFromAttributeFunction, + UMaterialFunction* GetFeatureIdsFromTextureFunction, int32& NodeX, int32& NodeY) { + int32 SectionBeginX = NodeY; for (const FCesiumFeatureIdSetDescription& featureIdSet : Descriptions) { if (featureIdSet.Type == ECesiumFeatureIdSetType::None) { @@ -424,57 +429,68 @@ void GenerateNodesForFeatureIdSets( } if (featureIdSet.Type == ECesiumFeatureIdSetType::Texture) { - //UMaterialExpressionTextureObjectParameter* FeatureIdTexture = - // NewObject( - // TargetMaterialLayer); - //FeatureIdTexture->ParameterName = - // FName("FIT_" + featureTable.Name + "_TX"); - //FeatureIdTexture->MaterialExpressionEditorX = NodeX; - //FeatureIdTexture->MaterialExpressionEditorY = NodeY; - //AutoGeneratedNodes.Add(FeatureIdTexture); - - //FCustomInput& FeatureIdTextureInput = FeatureTableLookup->Inputs[0]; - //FeatureIdTextureInput.InputName = "FeatureIdTexture"; - //FeatureIdTextureInput.Input.Expression = FeatureIdTexture; - - //NodeY += IncrY; - - //UMaterialExpressionScalarParameter* TexCoordsIndex = - // NewObject( - // this->TargetMaterialLayer); - //TexCoordsIndex->ParameterName = FName("FIT_" + featureTable.Name + "_UV"); - //TexCoordsIndex->DefaultValue = 0.0f; - //TexCoordsIndex->MaterialExpressionEditorX = NodeX; - //TexCoordsIndex->MaterialExpressionEditorY = NodeY; - //AutoGeneratedNodes.Add(TexCoordsIndex); - - //NodeX += IncrX; - - //UMaterialExpressionMaterialFunctionCall* SelectTexCoords = - // NewObject( - // this->TargetMaterialLayer); - //SelectTexCoords->MaterialFunction = SelectTexCoordsFunction; - //SelectTexCoords->MaterialExpressionEditorX = NodeX; - //SelectTexCoords->MaterialExpressionEditorY = NodeY; - - //SelectTexCoordsFunction->GetInputsAndOutputs( - // SelectTexCoords->FunctionInputs, - // SelectTexCoords->FunctionOutputs); - //SelectTexCoords->FunctionInputs[0].Input.Expression = TexCoordsIndex; - //AutoGeneratedNodes.Add(SelectTexCoords); - - //FCustomInput& TexCoordsInput = - // FeatureTableLookup->Inputs.Emplace_GetRef(); - //TexCoordsInput.InputName = FName("TexCoords"); - //TexCoordsInput.Input.Expression = SelectTexCoords; - - //NodeX += IncrX; - - //// TODO: Should the channel mask be determined dynamically instead of - //// at editor-time like it is now? - //FeatureTableLookup->Code = "uint _czm_propertyIndex = - // asuint(FeatureIdTexture.Sample(FeatureIdTextureSampler, TexCoords) - // ." + featureTable.Channel + "); + UMaterialExpressionScalarParameter* TexCoordsIndex = + NewObject(TargetMaterialLayer); + TexCoordsIndex->ParameterName = + FName(featureIdSet.Name + MaterialTexCoordSuffix); + TexCoordsIndex->DefaultValue = 0.0f; + TexCoordsIndex->MaterialExpressionEditorX = NodeX; + TexCoordsIndex->MaterialExpressionEditorY = NodeY; + AutoGeneratedNodes.Add(TexCoordsIndex); + + UMaterialExpressionTextureObjectParameter* FeatureIdTexture = + NewObject( + TargetMaterialLayer); + FeatureIdTexture->ParameterName = + FName(featureIdSet.Name + MaterialTextureSuffix); + FeatureIdTexture->MaterialExpressionEditorX = NodeX; + FeatureIdTexture->MaterialExpressionEditorY = NodeY; + AutoGeneratedNodes.Add(FeatureIdTexture); + + NodeY += IncrY; + + NodeY += IncrY; + UMaterialExpressionVectorParameter* Channels = + NewObject(TargetMaterialLayer); + Channels->ParameterName = + FName(featureIdSet.Name + MaterialChannelsSuffix); + Channels->DefaultValue = FLinearColor(0, 0, 0, 0); + Channels->MaterialExpressionEditorX = NodeX; + Channels->MaterialExpressionEditorY = NodeY; + AutoGeneratedNodes.Add(Channels); + + NodeY += IncrY; + UMaterialExpressionScalarParameter* NumChannels = + NewObject(TargetMaterialLayer); + NumChannels->ParameterName = + FName(featureIdSet.Name + MaterialNumChannelsSuffix); + NumChannels->DefaultValue = 0.0f; + NumChannels->MaterialExpressionEditorX = NodeX; + NumChannels->MaterialExpressionEditorY = NodeY; + AutoGeneratedNodes.Add(NumChannels); + + NodeX += IncrX; + NodeY -= 2 * IncrY; + + UMaterialExpressionMaterialFunctionCall* GetFeatureIdsFromTexture = + NewObject( + TargetMaterialLayer); + GetFeatureIdsFromTexture->MaterialFunction = + GetFeatureIdsFromTextureFunction; + GetFeatureIdsFromTexture->MaterialExpressionEditorX = NodeX; + GetFeatureIdsFromTexture->MaterialExpressionEditorY = NodeY; + + GetFeatureIdsFromTextureFunction->GetInputsAndOutputs( + GetFeatureIdsFromTexture->FunctionInputs, + GetFeatureIdsFromTexture->FunctionOutputs); + GetFeatureIdsFromTexture->FunctionInputs[0].Input.Expression = + TexCoordsIndex; + GetFeatureIdsFromTexture->FunctionInputs[1].Input.Expression = + FeatureIdTexture; + GetFeatureIdsFromTexture->FunctionInputs[2].Input.Expression = Channels; + GetFeatureIdsFromTexture->FunctionInputs[3].Input.Expression = + NumChannels; + AutoGeneratedNodes.Add(GetFeatureIdsFromTexture); } else { // Handle implicit feature IDs the same as feature ID attributes UMaterialExpressionScalarParameter* TextureCoordinateIndex = @@ -502,7 +518,11 @@ void GenerateNodesForFeatureIdSets( TextureCoordinateIndex; AutoGeneratedNodes.Add(GetFeatureIdsFromAttribute); } + + NodeY += IncrY; } + + NodeX = SectionBeginX; } void GenerateNodesForPropertyTables( @@ -540,26 +560,24 @@ void GenerateNodesForPropertyTables( // FeatureTableLookup->MaterialExpressionEditorY = NodeY; // - // // Get the pixel dimensions of the first property, all the properties - // // will - // // have the same dimensions since it is based on the feature count. - // if (propertyTable.Properties.Num()) { - // const FCesiumPropertyTablePropertyDescription& property = - // propertyTable.Properties[0]; - // FString propertyArrayName = - // CesiumEncodedFeaturesMetadata::createHlslSafeName(property.Name) + - // "_array"; - - // GetPropertyValuesFunction->Code += "uint _czm_width;\nuint - // _czm_height; - // \n "; GetPropertyValuesFunction->Code += - // propertyArrayName + - // ".GetDimensions(_czm_width, _czm_height);\n"; - // GetPropertyValuesFunction->Code += - // "uint _czm_pixelX = _czm_propertyIndex % _czm_width;\n"; - // GetPropertyValuesFunction->Code += - // "uint _czm_pixelY = _czm_propertyIndex / _czm_width;\n"; - // } + // Get the pixel dimensions of the first property, all the properties + // will + // have the same dimensions since it is based on the feature count. + if (propertyTable.Properties.Num()) { + const FCesiumPropertyTablePropertyDescription& property = + propertyTable.Properties[0]; + FString propertyArrayName = + CesiumEncodedFeaturesMetadata::createHlslSafeName(property.Name) + + "_array"; + + GetPropertyValuesFunction->Code += "uint _czm_width;\nuint_czm_height;\n"; + GetPropertyValuesFunction->Code += + propertyArrayName + ".GetDimensions(_czm_width, _czm_height);\n"; + GetPropertyValuesFunction->Code += + "uint _czm_pixelX = _czm_propertyIndex % _czm_width;\n"; + GetPropertyValuesFunction->Code += + "uint _czm_pixelY = _czm_propertyIndex / _czm_width;\n"; + } // NodeX = SectionLeft; // NodeY += IncrY; @@ -763,7 +781,6 @@ void GenerateNodesForPropertyTextures( void UCesiumFeaturesMetadataComponent::GenerateMaterial() { ACesium3DTileset* pTileset = Cast(this->GetOwner()); - if (!pTileset) { return; } @@ -777,13 +794,14 @@ void UCesiumFeaturesMetadataComponent::GenerateMaterial() { "/CesiumForUnreal/Materials/MaterialFunctions/CesiumSelectTexCoords.CesiumSelectTexCoords"); UMaterialFunction* GetFeatureIdsFromAttributeFunction = LoadMaterialFunction( "/CesiumForUnreal/Materials/MaterialFunctions/CesiumGetFeatureIdsFromAttribute.CesiumGetFeatureIdsFromAttribute"); + UMaterialFunction* GetFeatureIdsFromTextureFunction = LoadMaterialFunction( + "/CesiumForUnreal/Materials/MaterialFunctions/CesiumGetFeatureIdsFromTexture.CesiumGetFeatureIdsFromTexture"); - if (!SelectTexCoordsFunction || !GetFeatureIdsFromAttributeFunction) { + if (!SelectTexCoordsFunction || !GetFeatureIdsFromAttributeFunction || + !GetFeatureIdsFromTextureFunction) { return; } - // TODO: make functions for feature ID texture - bool Overwriting = false; if (this->TargetMaterialLayer) { // Overwriting an existing material layer. @@ -793,7 +811,7 @@ void UCesiumFeaturesMetadataComponent::GenerateMaterial() { } else { UPackage* Package = CreatePackage(*PackageName); - // Create an unreal material asset + // Create an Unreal material layer UMaterialFunctionMaterialLayerFactory* MaterialFactory = NewObject(); this->TargetMaterialLayer = @@ -801,7 +819,7 @@ void UCesiumFeaturesMetadataComponent::GenerateMaterial() { UMaterialFunctionMaterialLayer::StaticClass(), Package, *MaterialName, - RF_Standalone | RF_Transactional, + RF_Public | RF_Standalone | RF_Transactional, NULL, GWarn); FAssetRegistryModule::AssetCreated(this->TargetMaterialLayer); @@ -821,15 +839,16 @@ void UCesiumFeaturesMetadataComponent::GenerateMaterial() { int32 NodeY = 0; GenerateNodesForFeatureIdSets( - this->FeatureIdSets, + this->Features.FeatureIdSets, AutoGeneratedNodes, TargetMaterialLayer, GetFeatureIdsFromAttributeFunction, + GetFeatureIdsFromTextureFunction, NodeX, NodeY); GenerateNodesForPropertyTables( - this->PropertyTables, + this->ModelMetadata.PropertyTables, AutoGeneratedNodes, TargetMaterialLayer, NodeX, @@ -837,7 +856,7 @@ void UCesiumFeaturesMetadataComponent::GenerateMaterial() { // GenerateNodesForPropertyTextures - // NodeY = -IncrY; + NodeY = -IncrY; UMaterialExpressionFunctionInput* InputMaterial = nullptr; #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 0 @@ -945,12 +964,12 @@ void UCesiumFeaturesMetadataComponent::GenerateMaterial() { #endif } - RemapUserConnections(this->TargetMaterialLayer, ConnectionRemap); + // RemapUserConnections(this->TargetMaterialLayer, ConnectionRemap); - // let the material update itself if necessary + // Let the material update itself if necessary this->TargetMaterialLayer->PostEditChange(); - // make sure that any static meshes, etc using this material will stop + // Make sure that any static meshes, etc using this material will stop // using the FMaterialResource of the original material, and will use the new // FMaterialResource created when we make a new UMaterial in place FGlobalComponentReregisterContext RecreateComponents; diff --git a/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp b/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp index d9b1f23da..05b09a276 100644 --- a/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp +++ b/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp @@ -610,7 +610,8 @@ static void updateTextureCoordinatesForFeatureIds( const EncodedFeatureIdTexture& encodedFeatureIDTexture = *encodedFeatureIDSet.texture; featuresMetadataTexcoordParameters.Emplace( - encodedFeatureIDSet.name + "_UV", + encodedFeatureIDSet.name + + CesiumEncodedFeaturesMetadata::MaterialTexCoordSuffix, updateTextureCoordinates( model, primitive, @@ -1772,32 +1773,6 @@ static void SetFeaturesMetadataParameterValues( UMaterialInstanceDynamic* pMaterial, EMaterialParameterAssociation association, int32 index) { - /** - * TODO: Write down this convention somewhere more permanent / accessible. - * - * The following is the naming convention for encoded metadata: - * - * Feature Id Textures: - * - Base: "FIT__"... - * - Texture: ..."TX" - * - Texture Coordinate Index: ..."UV" - * - Channel Mask: ..."CM" - * - * Feature Id Attributes: - * - Texture Coordinate Index (feature ids are encoded into UVs): - * "FA_" - * - * Feature Texture Properties: - * - Base: "FTX___"... - * - Texture: ..."TX" - * - Texture Coordinate Index: ..."UV" - * - Swizzle: ..."SW" - * - * Encoded Feature Table Properties: - * - Encoded Property Table: - * "FTB__" - */ - if (!encodePrimitiveFeaturesGameThreadPart(loadResult.EncodedFeatures)) { return; } @@ -1812,6 +1787,43 @@ static void SetFeaturesMetadataParameterValues( textureCoordinateSet.Value); } + for (EncodedFeatureIdSet& encodedFeatureIdSet : + loadResult.EncodedFeatures.featureIdSets) { + if (!encodedFeatureIdSet.texture) { + continue; + } + + EncodedFeatureIdTexture& texture = *encodedFeatureIdSet.texture; + + pMaterial->SetTextureParameterValueByInfo( + FMaterialParameterInfo( + FName(encodedFeatureIdSet.name + MaterialTextureSuffix), + association, + index), + texture.pTexture->pTexture.Get()); + + size_t numChannels = texture.channels.size(); + pMaterial->SetScalarParameterValueByInfo( + FMaterialParameterInfo( + FName(encodedFeatureIdSet.name + MaterialNumChannelsSuffix), + association, + index), + static_cast(numChannels)); + + std::vector channelsAsFloats{0.0f, 0.0f, 0.0f, 0.0f}; + for (size_t i = 0; i < numChannels; i++) { + channelsAsFloats[i] = static_cast(texture.channels[i]); + } + + FLinearColor channels; + pMaterial->SetVectorParameterValueByInfo( + FMaterialParameterInfo( + FName(encodedFeatureIdSet.name + MaterialChannelsSuffix), + association, + index), + channels); + } + /* for (const FString& featureTextureName : loadResult.EncodedMetadata.featureTextureNames) { EncodedFeatureTexture* pEncodedFeatureTexture = @@ -1842,64 +1854,6 @@ static void SetFeaturesMetadataParameterValues( } } }*/ - - // for (EncodedFeatureIdTexture& encodedFeatureIdTexture : - // loadResult.EncodedMetadata.encodedFeatureIdTextures) { - - // pMaterial->SetTextureParameterValueByInfo( - // FMaterialParameterInfo( - // FName(encodedFeatureIdTexture.baseName + "TX"), - // association, - // index), - // encodedFeatureIdTexture.pTexture->pTexture.Get()); - - // FLinearColor channelMask; - // switch (encodedFeatureIdTexture.channel) { - // case 1: - // channelMask = FLinearColor::Green; - // break; - // case 2: - // channelMask = FLinearColor::Blue; - // break; - // default: - // channelMask = FLinearColor::Red; - // } - - // pMaterial->SetVectorParameterValueByInfo( - // FMaterialParameterInfo( - // FName(encodedFeatureIdTexture.baseName + "CM"), - // association, - // index), - // channelMask); - - // const EncodedMetadataFeatureTable* pEncodedFeatureTable = - // gltfComponent.EncodedMetadata.encodedFeatureTables.Find( - // encodedFeatureIdTexture.featureTableName); - - // if (pEncodedFeatureTable) { - // SetMetadataFeatureTableParameterValues( - // *pEncodedFeatureTable, - // pMaterial, - // association, - // index); - // } - //} - - //// TODO: set parameter values for material functions - // for (const EncodedFeatureIdAttribute& encodedFeatureIdAttribute : - // loadResult.EncodedMetadata.encodedFeatureIdAttributes) { - // const EncodedMetadataFeatureTable* pEncodedFeatureTable = - // gltfComponent.EncodedMetadata.encodedFeatureTables.Find( - // encodedFeatureIdAttribute.featureTableName); - - // if (pEncodedFeatureTable) { - // SetMetadataFeatureTableParameterValues( - // *pEncodedFeatureTable, - // pMaterial, - // association, - // index); - // } - //} } static void loadPrimitiveGameThreadPart( @@ -2121,7 +2075,8 @@ static void loadPrimitiveGameThreadPart( pGltf->Metadata); PRAGMA_ENABLE_DEPRECATION_WARNINGS - pMesh->EncodedPrimitiveMetadata = std::move(loadResult.EncodedMetadata); + pMesh->EncodedFeatures = std::move(loadResult.EncodedFeatures); + pMesh->EncodedMetadata = std::move(loadResult.EncodedMetadata); pMaterial->TwoSided = true; diff --git a/Source/CesiumRuntime/Private/CesiumGltfPrimitiveComponent.h b/Source/CesiumRuntime/Private/CesiumGltfPrimitiveComponent.h index f56c2bd35..38dcb34d5 100644 --- a/Source/CesiumRuntime/Private/CesiumGltfPrimitiveComponent.h +++ b/Source/CesiumRuntime/Private/CesiumGltfPrimitiveComponent.h @@ -42,8 +42,15 @@ class UCesiumGltfPrimitiveComponent : public UStaticMeshComponent { FCesiumMetadataPrimitive Metadata_DEPRECATED; PRAGMA_ENABLE_DEPRECATION_WARNINGS + /** + * The encoded representation of the primitive's EXT_mesh_features extension. + */ + CesiumEncodedFeaturesMetadata::EncodedPrimitiveFeatures EncodedFeatures; + /** + * The encoded representation of the primitive's EXT_structural_metadata extension. + */ CesiumEncodedFeaturesMetadata::EncodedPrimitiveMetadata - EncodedPrimitiveMetadata; + EncodedMetadata; ACesium3DTileset* pTilesetActor; diff --git a/Source/CesiumRuntime/Public/CesiumEncodedMetadataComponent.h b/Source/CesiumRuntime/Public/CesiumEncodedMetadataComponent.h index 2ad9423ac..d2442f7cd 100644 --- a/Source/CesiumRuntime/Public/CesiumEncodedMetadataComponent.h +++ b/Source/CesiumRuntime/Public/CesiumEncodedMetadataComponent.h @@ -1,4 +1,4 @@ -// Copyright 2020-2021 CesiumGS, Inc. and Contributors +// Copyright 2020-2023 CesiumGS, Inc. and Contributors #pragma once @@ -13,29 +13,39 @@ #include "CesiumEncodedMetadataComponent.generated.h" +PRAGMA_DISABLE_DEPRECATION_WARNINGS + /** * @brief The GPU component type to coerce this property to. * */ UENUM() -enum class ECesiumPropertyComponentType : uint8 { Uint8, Float }; +enum class ECesiumPropertyComponentType_DEPRECATED : uint8 { + Uint8_DEPRECATED, + Float_DEPRECATED +}; /** * @brief The property type. */ UENUM() -enum class ECesiumPropertyType : uint8 { Scalar, Vec2, Vec3, Vec4 }; +enum class ECesiumPropertyType_DEPRECATED : uint8 { + Scalar_DEPRECATED, + Vec2_DEPRECATED, + Vec3_DEPRECATED, + Vec4_DEPRECATED +}; /** * @brief Describes how this feature table is accessed. Either through feature * id textures, feature id attributes, mixed, or neither. */ UENUM() -enum class ECesiumFeatureTableAccessType : uint8 { - Unknown, - Texture, - Attribute, - Mixed +enum class ECesiumFeatureTableAccessType_DEPRECATED : uint8 { + Unknown_DEPRECATED, + Texture_DEPRECATED, + Attribute_DEPRECATED, + Mixed_DEPRECATED }; // Note that these don't exhaustively cover the possibilities of glTF metadata @@ -43,6 +53,11 @@ enum class ECesiumFeatureTableAccessType : uint8 { // example, arbitrary size arrays and enums are excluded. Other un-encoded // types like strings will be coerced. +struct UE_DEPRECATED( + 5.0, + "CesiumEncodedMetadataComponent and its related description properties have been deprecated. Use CesiumEncodedFeaturesMetadata instead.") + FPropertyDescription; + /** * @brief Description of a feature table property that should be encoded for * access on the GPU. @@ -63,14 +78,15 @@ struct CESIUMRUNTIME_API FPropertyDescription { * */ UPROPERTY(EditAnywhere, Category = "Cesium") - ECesiumPropertyComponentType ComponentType = - ECesiumPropertyComponentType::Float; + ECesiumPropertyComponentType_DEPRECATED ComponentType = + ECesiumPropertyComponentType_DEPRECATED::Float_DEPRECATED; /** * @brief The property type. */ UPROPERTY(EditAnywhere, Category = "Cesium") - ECesiumPropertyType Type = ECesiumPropertyType::Scalar; + ECesiumPropertyType_DEPRECATED Type = + ECesiumPropertyType_DEPRECATED::Scalar_DEPRECATED; /** * @brief If ComponentType==Uint8, this indicates whether to normalize into a @@ -81,10 +97,15 @@ struct CESIUMRUNTIME_API FPropertyDescription { Category = "Cesium", Meta = (EditCondition = - "ComponentType==ECesiumPropertyComponentType::Uint8")) + "ComponentType==ECesiumPropertyComponentType_DEPRECATED::Uint8_DEPRECATED")) bool Normalized = false; }; +struct UE_DEPRECATED( + 5.0, + "CesiumEncodedMetadataComponent and its related description properties have been deprecated. Use CesiumEncodedFeaturesMetadata instead.") + FFeatureTableDescription; + /** * @brief Description of a feature table containing properties to be encoded * for access on the GPU. @@ -105,8 +126,8 @@ struct CESIUMRUNTIME_API FFeatureTableDescription { * id textures, feature id attributes, mixed, or neither. */ UPROPERTY(EditAnywhere, Category = "Cesium") - ECesiumFeatureTableAccessType AccessType = - ECesiumFeatureTableAccessType::Unknown; + ECesiumFeatureTableAccessType_DEPRECATED AccessType = + ECesiumFeatureTableAccessType_DEPRECATED::Unknown_DEPRECATED; /** * @brief If the AccessType==Texture, this string represents the channel of @@ -117,7 +138,7 @@ struct CESIUMRUNTIME_API FFeatureTableDescription { Category = "Cesium", Meta = (EditCondition = - "AccessType==ECesiumFeatureTableAccessType::Texture")) + "AccessType==ECesiumFeatureTableAccessType::Texture_DEPRECATED")) FString Channel; /** @@ -127,6 +148,11 @@ struct CESIUMRUNTIME_API FFeatureTableDescription { TArray Properties; }; +struct UE_DEPRECATED( + 5.0, + "CesiumEncodedMetadataComponent and its related description properties have been deprecated. Use CesiumEncodedFeaturesMetadata instead.") + FFeatureTexturePropertyDescription; + /** * @brief Description of a feature texture property that should be uploaded to * the GPU. @@ -152,7 +178,8 @@ struct CESIUMRUNTIME_API FFeatureTexturePropertyDescription { * @brief The property type. */ UPROPERTY(EditAnywhere, Category = "Cesium") - ECesiumPropertyType Type = ECesiumPropertyType::Scalar; + ECesiumPropertyType_DEPRECATED Type = + ECesiumPropertyType_DEPRECATED::Scalar_DEPRECATED; /** * @brief If ComponentType==Uint8, this indicates whether to normalize into a @@ -170,6 +197,11 @@ struct CESIUMRUNTIME_API FFeatureTexturePropertyDescription { FString Swizzle; }; +struct UE_DEPRECATED( + 5.0, + "CesiumEncodedMetadataComponent and its related description properties have been deprecated. Use CesiumEncodedFeaturesMetadata instead.") + FFeatureTextureDescription; + /** * @brief Description of a feature texture with properties that should be * uploaded to the GPU. @@ -191,6 +223,11 @@ struct CESIUMRUNTIME_API FFeatureTextureDescription { TArray Properties; }; +struct UE_DEPRECATED( + 5.0, + "CesiumEncodedMetadataComponent and its related description properties have been deprecated. Use CesiumEncodedFeaturesMetadata instead.") + FMetadataDescription; + /** * @brief Description of metadata from a glTF that should be uploaded to the * GPU for access in materials. @@ -232,37 +269,6 @@ class CESIUMRUNTIME_API UDEPRECATED_CesiumEncodedMetadataComponent GENERATED_BODY() public: -// /** -// * @brief This button can be used to pre-populate the description of metadata -// * to encode based on the existing metadata in the current tiles. -// * -// * Warning: Using Auto Fill may populate the description with a large amount -// * of metadata. Make sure to delete the properties that aren't relevant. -// */ -// UFUNCTION( -// CallInEditor, -// Meta = -// (DeprecatedFunction, -// DeprecationMessage = -// "CesiumEncodedMetadataComponent is deprecated. Use CesiumFeaturesMetadataComponent instead.")) -// void AutoFill(); -// -//#if WITH_EDITOR -// /** -// * @brief This button can be used to create a boiler-plate material layer that -// * exposes the requested metadata properties in the current description. The -// * nodes to access the metada will be added to TargetMaterialLayer if it -// * exists. Otherwise a new material layer will be created in the /Game/ -// * folder and TargetMaterialLayer will be set to the new material layer. -// */ -// UFUNCTION( -// CallInEditor, -// Meta = -// (DeprecatedFunction, -// DeprecationMessage = "CesiumEncodedMetadataComponent is deprecated. Use CesiumFeaturesMetadataComponent instead.")) -// void GenerateMaterial(); -//#endif - #if WITH_EDITORONLY_DATA /** * @brief This is the target UMaterialFunctionMaterialLayer that the @@ -271,7 +277,13 @@ class CESIUMRUNTIME_API UDEPRECATED_CesiumEncodedMetadataComponent * to the requested metadata. If this is left blank, a new material layer * will be created in the /Game/ folder. */ - UPROPERTY(EditAnywhere, Category = "EncodeMetadata") + UPROPERTY( + EditAnywhere, + Category = "EncodeMetadata", + Meta = + (DeprecatedProperty, + DeprecationMessage = + "CesiumEncodedMetadataComponent is deprecated. Use CesiumFeaturesMetadataComponent instead.")) UMaterialFunctionMaterialLayer* TargetMaterialLayer = nullptr; #endif @@ -285,7 +297,11 @@ class CESIUMRUNTIME_API UDEPRECATED_CesiumEncodedMetadataComponent UPROPERTY( EditAnywhere, Category = "EncodeMetadata", - Meta = (TitleProperty = "Name")) + Meta = + (TitleProperty = "Name", + DeprecatedProperty, + DeprecationMessage = + "CesiumEncodedMetadataComponent is deprecated. Use CesiumFeaturesMetadataComponent instead.")) TArray FeatureTables; /** @@ -294,6 +310,10 @@ class CESIUMRUNTIME_API UDEPRECATED_CesiumEncodedMetadataComponent UPROPERTY( EditAnywhere, Category = "EncodeMetadata", - Meta = (TitleProperty = "Name")) + Meta = + (TitleProperty = "Name", + DeprecatedProperty, + DeprecationMessage = + "CesiumEncodedMetadataComponent is deprecated. Use CesiumFeaturesMetadataComponent instead.")) TArray FeatureTextures; }; diff --git a/Source/CesiumRuntime/Public/CesiumFeaturesMetadataComponent.h b/Source/CesiumRuntime/Public/CesiumFeaturesMetadataComponent.h index 4765c6aeb..2e2a79ea2 100644 --- a/Source/CesiumRuntime/Public/CesiumFeaturesMetadataComponent.h +++ b/Source/CesiumRuntime/Public/CesiumFeaturesMetadataComponent.h @@ -293,7 +293,7 @@ class CESIUMRUNTIME_API UCesiumFeaturesMetadataComponent * @brief This button can be used to create a boiler-plate material layer that * exposes the requested metadata properties in the current description. The * nodes to access the metadata will be added to TargetMaterialLayer if it - * exists. Otherwise a new material layer will be created in the /Game/ + * exists. Otherwise a new material layer will be created in the /Content/ * folder and TargetMaterialLayer will be set to the new material layer. */ UFUNCTION(CallInEditor, Category = "Cesium") @@ -308,39 +308,20 @@ class CESIUMRUNTIME_API UCesiumFeaturesMetadataComponent * to the requested metadata. If this is left blank, a new material layer * will be created in the /Game/ folder. */ - UPROPERTY(EditAnywhere, Category = "Cesium|EncodedMetadata") + UPROPERTY(EditAnywhere, Category = "Cesium") UMaterialFunctionMaterialLayer* TargetMaterialLayer = nullptr; #endif - // Note: Here, we avoid wrapping the feature tables and feature textures - // inside a FMetadataDescription to avoid further complicating the details - // panel UI for editing the hierarchy. - /** - * Description of the feature ID sets available from the - * EXT_mesh_features on a glTF's primitives. + * Description of the EXT_mesh_features in the visible glTF primitives across + * the tileset. */ - UPROPERTY( - EditAnywhere, - Category = "Cesium|Features", - Meta = (TitleProperty = "Name")) - TArray FeatureIdSets; + UPROPERTY(EditAnywhere, Category = "Cesium") + FCesiumPrimitiveFeaturesDescription Features; /** - * @brief Descriptions of property tables to upload to the GPU. + * @brief Descriptions of the EXT_structural_metadata in the visible glTF models across the tileset. */ - UPROPERTY( - EditAnywhere, - Category = "Cesium|Metadata", - Meta = (TitleProperty = "Name")) - TArray PropertyTables; - - ///** - // * @brief Descriptions of feature textures to upload to the GPU. - // */ - // UPROPERTY( - // EditAnywhere, - // Category = "Cesium|Metadata", - // Meta = (TitleProperty = "Name")) - // TArray FeatureTextures; + UPROPERTY(EditAnywhere, Category = "Cesium") + FCesiumModelMetadataDescription ModelMetadata; };