diff --git a/CHANGES.md b/CHANGES.md index c97be091c..33b3fb3f2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ##### Fixes :wrench: - Fixed a bug that prevented `UCesiumPrimitiveFeaturesBlueprintLibrary::GetPrimitiveFeatures` from retrieving the features of instanced meshes. +- Removed `bHasKhrTextureTransform` from `FCesiumFeatureIdSetDescription` and `FCesiumPropertyTexturePropertyDescription`. This will not break any existing materials generated by `UCesiumFeaturesMetadataComponent`; instead, it will always generate additional nodes to handle the `KHR_texture_transform` extension if present. ### v2.21.0 Preview for Unreal Engine 5.7 - 2025-11-17 diff --git a/Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp b/Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp index 79aa5e7f9..6f44a316c 100644 --- a/Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp +++ b/Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp @@ -256,13 +256,6 @@ void AutoFillPropertyTextureDescriptions( propertyIt.Value); property.PropertyDetails.bHasDefaultValue = !UCesiumMetadataValueBlueprintLibrary::IsEmpty(defaultValue); - - auto maybeTextureTransform = propertyIt.Value.getTextureTransform(); - if (maybeTextureTransform) { - property.bHasKhrTextureTransform = - (maybeTextureTransform->status() == - CesiumGltf::KhrTextureTransformStatus::Valid); - } } } } @@ -316,19 +309,6 @@ void AutoFillFeatureIdSetDescriptions( PropertyTables[propertyTableIndex]; pDescription->PropertyTableName = getNameForPropertyTable(propertyTable); } - - if (type == ECesiumFeatureIdSetType::Texture) { - FCesiumFeatureIdTexture featureIdTexture = - UCesiumFeatureIdSetBlueprintLibrary::GetAsFeatureIDTexture( - featureIDSet); - auto maybeTextureTransform = - featureIdTexture.getFeatureIdTextureView().getTextureTransform(); - if (maybeTextureTransform) { - pDescription->bHasKhrTextureTransform = - (maybeTextureTransform->status() == - CesiumGltf::KhrTextureTransformStatus::Valid); - } - } } } @@ -1210,33 +1190,28 @@ UMaterialExpressionMaterialFunctionCall* GenerateNodesForFeatureIdTexture( Channels->MaterialExpressionEditorY = NodeY; AutoGeneratedNodes.Add(Channels); - // KHR_texture_transform parameters - UMaterialExpressionVectorParameter* TransformScaleOffset = nullptr; - UMaterialExpressionVectorParameter* TransformRotation = nullptr; - - if (Description.bHasKhrTextureTransform) { - TransformScaleOffset = - NewObject(TargetMaterialLayer); - TransformScaleOffset->ParameterName = - FName(SafeName + MaterialTextureScaleOffsetSuffix); - TransformScaleOffset->DefaultValue = {1, 1, 0, 0}; - TransformScaleOffset->MaterialExpressionEditorX = NodeX; - TransformScaleOffset->MaterialExpressionEditorY = NodeY + 1.25 * Incr; - AutoGeneratedNodes.Add(TransformScaleOffset); + // Parameters to handle KHR_texture_transform if present. + UMaterialExpressionVectorParameter* TransformScaleOffset = + NewObject(TargetMaterialLayer); + TransformScaleOffset->ParameterName = + FName(SafeName + MaterialTextureScaleOffsetSuffix); + TransformScaleOffset->DefaultValue = {1, 1, 0, 0}; + TransformScaleOffset->MaterialExpressionEditorX = NodeX; + TransformScaleOffset->MaterialExpressionEditorY = NodeY + 1.25 * Incr; + AutoGeneratedNodes.Add(TransformScaleOffset); - MaximumParameterSectionX = FMath::Max( - MaximumParameterSectionX, - Incr * GetNameLengthScalar(TransformScaleOffset->ParameterName)); + MaximumParameterSectionX = FMath::Max( + MaximumParameterSectionX, + Incr * GetNameLengthScalar(TransformScaleOffset->ParameterName)); - TransformRotation = - NewObject(TargetMaterialLayer); - TransformRotation->ParameterName = - FName(SafeName + MaterialTextureRotationSuffix); - TransformRotation->DefaultValue = {0, 1, 0, 1}; - TransformRotation->MaterialExpressionEditorX = NodeX; - TransformRotation->MaterialExpressionEditorY = NodeY + 2.5 * Incr; - AutoGeneratedNodes.Add(TransformRotation); - } + UMaterialExpressionVectorParameter* TransformRotation = + NewObject(TargetMaterialLayer); + TransformRotation->ParameterName = + FName(SafeName + MaterialTextureRotationSuffix); + TransformRotation->DefaultValue = {0, 1, 0, 1}; + TransformRotation->MaterialExpressionEditorX = NodeX; + TransformRotation->MaterialExpressionEditorY = NodeY + 2.5 * Incr; + AutoGeneratedNodes.Add(TransformRotation); NodeX += MaximumParameterSectionX + Incr; @@ -1251,16 +1226,14 @@ UMaterialExpressionMaterialFunctionCall* GenerateNodesForFeatureIdTexture( UMaterialExpressionAppendVector* AppendScaleOffset = nullptr; - if (Description.bHasKhrTextureTransform) { - AppendScaleOffset = - NewObject(TargetMaterialLayer); - AppendScaleOffset->MaterialExpressionEditorX = NodeX; - AppendScaleOffset->MaterialExpressionEditorY = - TransformScaleOffset->MaterialExpressionEditorY; - AppendScaleOffset->A.Connect(0, TransformScaleOffset); - AppendScaleOffset->B.Connect(4, TransformScaleOffset); - AutoGeneratedNodes.Add(AppendScaleOffset); - } + AppendScaleOffset = + NewObject(TargetMaterialLayer); + AppendScaleOffset->MaterialExpressionEditorX = NodeX; + AppendScaleOffset->MaterialExpressionEditorY = + TransformScaleOffset->MaterialExpressionEditorY; + AppendScaleOffset->A.Connect(0, TransformScaleOffset); + AppendScaleOffset->B.Connect(4, TransformScaleOffset); + AutoGeneratedNodes.Add(AppendScaleOffset); NodeY -= 1.75 * Incr; NodeX += 1.25 * Incr; @@ -1281,15 +1254,12 @@ UMaterialExpressionMaterialFunctionCall* GenerateNodesForFeatureIdTexture( FeatureIdTexture; GetFeatureIdsFromTexture->FunctionInputs[2].Input.Expression = NumChannels; GetFeatureIdsFromTexture->FunctionInputs[3].Input.Expression = AppendChannels; - - if (Description.bHasKhrTextureTransform) { - GetFeatureIdsFromTexture->FunctionInputs[4].Input.Connect( - 0, - AppendScaleOffset); - GetFeatureIdsFromTexture->FunctionInputs[5].Input.Connect( - 0, - TransformRotation); - } + GetFeatureIdsFromTexture->FunctionInputs[4].Input.Connect( + 0, + AppendScaleOffset); + GetFeatureIdsFromTexture->FunctionInputs[5].Input.Connect( + 0, + TransformRotation); AutoGeneratedNodes.Add(GetFeatureIdsFromTexture); @@ -2044,84 +2014,79 @@ void GenerateNodesForPropertyTexture( MaximumPropertyDataSectionX = NodeX + 2 * Incr; NodeX = BeginSectionX; - if (Property.bHasKhrTextureTransform) { - PropertyDataSectionY += 1.25 * Incr; - - UMaterialExpressionVectorParameter* TransformRotation = - NewObject(TargetMaterialLayer); - TransformRotation->ParameterName = - FName(FullPropertyName + MaterialTextureRotationSuffix); - TransformRotation->DefaultValue = {0, 1, 0, 1}; - TransformRotation->MaterialExpressionEditorX = NodeX; - TransformRotation->MaterialExpressionEditorY = PropertyDataSectionY; - AutoGeneratedNodes.Add(TransformRotation); - - UMaterialExpressionVectorParameter* TransformScaleOffset = - NewObject(TargetMaterialLayer); - TransformScaleOffset->ParameterName = - FName(FullPropertyName + MaterialTextureScaleOffsetSuffix); - TransformScaleOffset->DefaultValue = {1, 1, 0, 0}; - TransformScaleOffset->MaterialExpressionEditorX = NodeX; - TransformScaleOffset->MaterialExpressionEditorY = - PropertyDataSectionY + Incr; - AutoGeneratedNodes.Add(TransformScaleOffset); - - UMaterialExpressionAppendVector* AppendScale = - NewObject(TargetMaterialLayer); - AppendScale->MaterialExpressionEditorX = - NodeX + Incr * (0.5 + GetNameLengthScalar( - TransformScaleOffset->ParameterName)); - AppendScale->MaterialExpressionEditorY = - TransformRotation->MaterialExpressionEditorY; - AppendScale->A.Connect(1, TransformScaleOffset); - AppendScale->B.Connect(2, TransformScaleOffset); - AutoGeneratedNodes.Add(AppendScale); - - UMaterialExpressionAppendVector* AppendOffset = - NewObject(TargetMaterialLayer); - AppendOffset->MaterialExpressionEditorX = - AppendScale->MaterialExpressionEditorX; - AppendOffset->MaterialExpressionEditorY = - TransformScaleOffset->MaterialExpressionEditorY; - AppendOffset->A.Connect(3, TransformScaleOffset); - AppendOffset->B.Connect(4, TransformScaleOffset); - AutoGeneratedNodes.Add(AppendOffset); - - MaximumPropertyDataSectionX = FMath::Max( - MaximumPropertyDataSectionX, - AppendOffset->MaterialExpressionEditorX + Incr - NodeX); - PropertyDataSectionY += 1.25 * Incr; - - UMaterialExpressionMaterialFunctionCall* TransformTexCoords = - NewObject( - TargetMaterialLayer); - TransformTexCoords->MaterialFunction = - FunctionLibrary.TransformTexCoords; - TransformTexCoords->MaterialExpressionEditorX = - SelectTexCoords->MaterialExpressionEditorX + Incr * 1.5; - TransformTexCoords->MaterialExpressionEditorY = - SelectTexCoords->MaterialExpressionEditorY; - - FunctionLibrary.TransformTexCoords->GetInputsAndOutputs( - TransformTexCoords->FunctionInputs, - TransformTexCoords->FunctionOutputs); - // For some reason, Connect() doesn't work with this input... - TransformTexCoords->FunctionInputs[0].Input.Expression = - SelectTexCoords; - TransformTexCoords->FunctionInputs[0].Input.OutputIndex = 0; - TransformTexCoords->FunctionInputs[1].Input.Connect( - 0, - TransformRotation); - TransformTexCoords->FunctionInputs[2].Input.Connect(0, AppendScale); - TransformTexCoords->FunctionInputs[3].Input.Connect(0, AppendOffset); - AutoGeneratedNodes.Add(TransformTexCoords); - - TexCoordsInputFunction = TransformTexCoords; - - MaximumPropertyDataSectionX = FMath::Max( - MaximumPropertyDataSectionX, - TransformTexCoords->MaterialExpressionEditorX + Incr * 1.5); - } + PropertyDataSectionY += 1.25 * Incr; + + // Parameters to handle KHR_texture_transform, if present. + UMaterialExpressionVectorParameter* TransformRotation = + NewObject(TargetMaterialLayer); + TransformRotation->ParameterName = + FName(FullPropertyName + MaterialTextureRotationSuffix); + TransformRotation->DefaultValue = {0, 1, 0, 1}; + TransformRotation->MaterialExpressionEditorX = NodeX; + TransformRotation->MaterialExpressionEditorY = PropertyDataSectionY; + AutoGeneratedNodes.Add(TransformRotation); + + UMaterialExpressionVectorParameter* TransformScaleOffset = + NewObject(TargetMaterialLayer); + TransformScaleOffset->ParameterName = + FName(FullPropertyName + MaterialTextureScaleOffsetSuffix); + TransformScaleOffset->DefaultValue = {1, 1, 0, 0}; + TransformScaleOffset->MaterialExpressionEditorX = NodeX; + TransformScaleOffset->MaterialExpressionEditorY = + PropertyDataSectionY + Incr; + AutoGeneratedNodes.Add(TransformScaleOffset); + + UMaterialExpressionAppendVector* AppendScale = + NewObject(TargetMaterialLayer); + AppendScale->MaterialExpressionEditorX = + NodeX + Incr * (0.5 + GetNameLengthScalar( + TransformScaleOffset->ParameterName)); + AppendScale->MaterialExpressionEditorY = + TransformRotation->MaterialExpressionEditorY; + AppendScale->A.Connect(1, TransformScaleOffset); + AppendScale->B.Connect(2, TransformScaleOffset); + AutoGeneratedNodes.Add(AppendScale); + + UMaterialExpressionAppendVector* AppendOffset = + NewObject(TargetMaterialLayer); + AppendOffset->MaterialExpressionEditorX = + AppendScale->MaterialExpressionEditorX; + AppendOffset->MaterialExpressionEditorY = + TransformScaleOffset->MaterialExpressionEditorY; + AppendOffset->A.Connect(3, TransformScaleOffset); + AppendOffset->B.Connect(4, TransformScaleOffset); + AutoGeneratedNodes.Add(AppendOffset); + + MaximumPropertyDataSectionX = FMath::Max( + MaximumPropertyDataSectionX, + AppendOffset->MaterialExpressionEditorX + Incr - NodeX); + PropertyDataSectionY += 1.25 * Incr; + + UMaterialExpressionMaterialFunctionCall* TransformTexCoords = + NewObject( + TargetMaterialLayer); + TransformTexCoords->MaterialFunction = FunctionLibrary.TransformTexCoords; + TransformTexCoords->MaterialExpressionEditorX = + SelectTexCoords->MaterialExpressionEditorX + Incr * 1.5; + TransformTexCoords->MaterialExpressionEditorY = + SelectTexCoords->MaterialExpressionEditorY; + + FunctionLibrary.TransformTexCoords->GetInputsAndOutputs( + TransformTexCoords->FunctionInputs, + TransformTexCoords->FunctionOutputs); + // For some reason, Connect() doesn't work with this input... + TransformTexCoords->FunctionInputs[0].Input.Expression = SelectTexCoords; + TransformTexCoords->FunctionInputs[0].Input.OutputIndex = 0; + TransformTexCoords->FunctionInputs[1].Input.Connect(0, TransformRotation); + TransformTexCoords->FunctionInputs[2].Input.Connect(0, AppendScale); + TransformTexCoords->FunctionInputs[3].Input.Connect(0, AppendOffset); + AutoGeneratedNodes.Add(TransformTexCoords); + + TexCoordsInputFunction = TransformTexCoords; + + MaximumPropertyDataSectionX = FMath::Max( + MaximumPropertyDataSectionX, + TransformTexCoords->MaterialExpressionEditorX + Incr * 1.5); PropertyDataSectionY += 0.8 * Incr; } diff --git a/Source/CesiumRuntime/Private/EncodedFeaturesMetadata.cpp b/Source/CesiumRuntime/Private/EncodedFeaturesMetadata.cpp index 67189f2d8..c8996ce80 100644 --- a/Source/CesiumRuntime/Private/EncodedFeaturesMetadata.cpp +++ b/Source/CesiumRuntime/Private/EncodedFeaturesMetadata.cpp @@ -718,9 +718,7 @@ EncodedPropertyTexture encodePropertyTextureAnyThreadPart( property); } - if (pDescription->bHasKhrTextureTransform) { - encodedProperty.textureTransform = property.getTextureTransform(); - } + encodedProperty.textureTransform = property.getTextureTransform(); } return encodedPropertyTexture; diff --git a/Source/CesiumRuntime/Public/CesiumFeaturesMetadataDescription.h b/Source/CesiumRuntime/Public/CesiumFeaturesMetadataDescription.h index f0fe787e2..a36fcca60 100644 --- a/Source/CesiumRuntime/Public/CesiumFeaturesMetadataDescription.h +++ b/Source/CesiumRuntime/Public/CesiumFeaturesMetadataDescription.h @@ -53,16 +53,6 @@ struct CESIUMRUNTIME_API FCesiumFeatureIdSetDescription { UPROPERTY(EditAnywhere, Category = "Cesium") ECesiumFeatureIdSetType Type = ECesiumFeatureIdSetType::None; - /** - * Whether this feature ID set contains a KHR_texture_transform glTF - * extension. Only applicable if the feature ID set is a feature ID texture. - */ - UPROPERTY( - EditAnywhere, - Category = "Cesium", - Meta = (EditCondition = "Type == ECesiumFeatureIdSetType::Texture")) - bool bHasKhrTextureTransform = false; - /** * The name of the property table that this feature ID set corresponds to. */ @@ -186,13 +176,6 @@ struct CESIUMRUNTIME_API FCesiumPropertyTexturePropertyDescription { */ UPROPERTY(EditAnywhere, Category = "Cesium") FCesiumMetadataPropertyDetails PropertyDetails; - - /** - * Whether this property texture property contains a KHR_texture_transform - * glTF extension. - */ - UPROPERTY(EditAnywhere, Category = "Cesium") - bool bHasKhrTextureTransform = false; }; /**