# Virtual Texture and Procedural Mesh

**URL:** <https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227>\
**Category:** Asset Creation\
**Tags:** Virtual-Texturing, procedural-mesh-comp, spline-mesh-componen, unreal-engine, question\
**Created:** [March 13, 2021, 2:11pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227 "2021-03-13T14:11:25Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Konata\_Yuki](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Konata\_Yuki](https://forums.unrealengine.com/u/Konata_Yuki)\
**Post date:** [March 13, 2021, 2:11pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/1 "2021-03-13T14:11:25Z")

</div>

Hello,

Does anyone know how Procedurally created Meshes can draw a Virtual Texture?

I have created an example in ContentExamples. The appearance of the static mesh and the procedural mesh should be projected onto the underlying surface see pic1

 ![332345-pic1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/c/4/fc48df5a3e04d5497f365612e70040899da5c3f6.jpeg)

.

It seems that it only works for static mesh.  
But it works for the splines meshes in the Landscape tool. (see pic2)

I hope someone can help. 🙂

 ![332347-pic2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/9/1/d91755eeb17081016f4a552a8d4a792842bd107c.jpeg)

---

<div class="post-metadata">

**Author:** ![DrHippoDev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DrHippoDev](https://forums.unrealengine.com/u/DrHippoDev)\
**Post date:** [March 29, 2021, 6:12am UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/2 "2021-03-29T06:12:56Z")

</div>

Would love the answer to this as well!

---

<div class="post-metadata">

**Author:** ![Konata\_Yuki](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Konata\_Yuki](https://forums.unrealengine.com/u/Konata_Yuki)\
**Post date:** [August 20, 2021, 4:53pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/3 "2021-08-20T16:53:56Z")

</div>

Good evening Epic,  
is there a solution or maybe an update of the engine to solve the problem?

---

<div class="post-metadata">

**Author:** ![gstyczen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gstyczen](https://forums.unrealengine.com/u/gstyczen)\
**Post date:** [November 28, 2021, 2:30pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/4 "2021-11-28T14:30:03Z")

</div>

Ahh shoot. I was wondering why it doesn’t work.

---

<div class="post-metadata">

**Author:** ![Czochcio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Czochcio](https://forums.unrealengine.com/u/Czochcio)\
**Post date:** [November 29, 2021, 7:24am UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/5 "2021-11-29T07:24:39Z")

</div>

UProceduralMeshComponents is using “Dynamic draw pipeline” while Virtual Texture is created in “Static Draw pipeline”.  
In order to make runtime virtual textures working with UProceduralMeshComponent it would need to have following function implemented just for RVT:

virtual void DrawStaticElements(FStaticPrimitiveDrawInterface\* PDI)

I came across same problem and solved it by creating my own UProceduralMeshComponent with addition of DrawStaticElements method and it works just fine. In my case i’m not modyfing mesh very often so performance is good.

---

<div class="post-metadata">

**Author:** ![Czochcio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Czochcio](https://forums.unrealengine.com/u/Czochcio)\
**Post date:** [November 29, 2021, 7:25am UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/6 "2021-11-29T07:25:48Z")

</div>

UProceduralMeshComponents is using “Dynamic draw pipeline” while Virtual Texture is created in “Static Draw pipeline”.  
In order to make runtime virtual textures working with UProceduralMeshComponent it would need to have following function implemented just for RVT:

virtual void DrawStaticElements(FStaticPrimitiveDrawInterface\* PDI)

I came across same problem and solved it by creating my own UProceduralMeshComponent with addition of DrawStaticElements method and it works just fine. In my case i’m not modyfing mesh very often so performance is good.

Here is example of code to this DrawStaticElements method:

```
virtual void DrawStaticElements(FStaticPrimitiveDrawInterface* PDI)
{
	if( RuntimeVirtualTextures.Num() == 0 )
	{
		return;
	}
	const FRYCProcMeshProxySection* Section = Sections[0];
	UMaterialInterface* SectionMat = Section->Material;
	check(SectionMat);

	FMeshBatch MeshBatch;
	MeshBatch.LODIndex = 0;
	MeshBatch.SegmentIndex = 0;

	MeshBatch.VertexFactory = &MeshVertexBuffersSection->VertexFactory;
	MeshBatch.Type = PT_TriangleList;

	MeshBatch.LODIndex = 0;
	MeshBatch.SegmentIndex = 0;

	MeshBatch.bDitheredLODTransition = !IsMovable() && Section->Material->GetRenderProxy()->GetMaterialInterface()->IsDitheredLODTransition();

	MeshBatch.bRenderToVirtualTexture = true;
	MeshBatch.MaterialRenderProxy = Section->Material->GetRenderProxy();
	MeshBatch.RuntimeVirtualTextureMaterialType = (int32)ERuntimeVirtualTextureMaterialType::BaseColor_Normal_Specular;
	MeshBatch.ReverseCulling = IsLocalToWorldDeterminantNegative();

	MeshBatch.DepthPriorityGroup = SDPG_World;
	MeshBatch.bCanApplyViewModeOverrides = false;

	MeshBatch.Elements.Empty(1);
	FMeshBatchElement BatchElement;
	BatchElement.IndexBuffer = &MeshIndexBuffersSection->IndexBuffer;
	BatchElement.FirstIndex = 0;
	BatchElement.NumPrimitives = MeshIndexBuffersSection->IndexBuffer.Indices.Num() / 3;
	BatchElement.MinVertexIndex = 0;
	BatchElement.MaxVertexIndex = MeshVertexBuffersSection->VertexBuffers.PositionVertexBuffer.GetNumVertices() - 1;		
	MeshBatch.Elements.Add(BatchElement);
	
	PDI->DrawMesh(MeshBatch, FLT_MAX);
	
}
```

---

<div class="post-metadata">

**Author:** ![Czochcio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Czochcio](https://forums.unrealengine.com/u/Czochcio)\
**Post date:** [December 1, 2021, 11:22am UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/7 "2021-12-01T11:22:45Z")

</div>

I think i got answer for your question as I got stuck with same problem. Seems That Runtime virtual texturing is processed in “StaticPipeline” while UProceduralMeshComponent only useded "DynamicPipeline.

Just to tell where it is in the code - UProceduralMeshComponent prepares FMeshBatch in GetDynamicMeshElements - as it was created to support dynamic geometry. In order to get UProceduralMeshComponent working with RVT we would need to have function :

virtual void DrawStaticElements(FStaticPrimitiveDrawInterface\* PDI)

implemented in UProceduralMeshComponent mesh to get it working for virtualTextures - and used only for virtual textures or there is need to add virutal textures for dynamic geometry.

If we get DrawStaticElements implemented for UProceduralMeshComponent there are two options we dont change geometry or we get performance hit.

I can give you my implementation of this method - as my own UProceduralMeshComponent is used for procedural static geometry and i’m using single section:

```
virtual void DrawStaticElements(FStaticPrimitiveDrawInterface* PDI)
{
	const FRYCProcMeshProxySection* Section = Sections[0];
	UMaterialInterface* SectionMat = Section->Material;
	check(SectionMat);

	FMeshBatch MeshBatch;
	MeshBatch.LODIndex = 0;
	MeshBatch.SegmentIndex = 0;

	MeshBatch.VertexFactory = &MeshVertexBuffersSection->VertexFactory;
	MeshBatch.Type = PT_TriangleList;

	MeshBatch.LODIndex = 0;
	MeshBatch.SegmentIndex = 0;

	MeshBatch.bDitheredLODTransition = !IsMovable() && Section->Material->GetRenderProxy()->GetMaterialInterface()->IsDitheredLODTransition();
	MeshBatch.bWireframe = false;
	MeshBatch.CastShadow = false;
	MeshBatch.bUseForDepthPass = false;
	MeshBatch.bUseAsOccluder = false;
	MeshBatch.bUseForMaterial = false;		
	MeshBatch.bRenderToVirtualTexture = true;
	MeshBatch.MaterialRenderProxy = Section->Material->GetRenderProxy();
	MeshBatch.RuntimeVirtualTextureMaterialType = (int32)ERuntimeVirtualTextureMaterialType::BaseColor_Normal_Specular;
	MeshBatch.ReverseCulling = IsLocalToWorldDeterminantNegative();

	MeshBatch.DepthPriorityGroup = SDPG_World;
	MeshBatch.bCanApplyViewModeOverrides = false;

	MeshBatch.Elements.Empty(1);
	FMeshBatchElement BatchElement;
	//BatchElement.PrimitiveUniformBuffer = GetUniformBuffer();
	BatchElement.IndexBuffer = &MeshIndexBuffersSection->IndexBuffer;
	BatchElement.FirstIndex = 0;
	BatchElement.NumPrimitives = MeshIndexBuffersSection->IndexBuffer.Indices.Num() / 3;
	BatchElement.MinVertexIndex = 0;
	//BatchElement.IndexBuffer = CurrentIndexBuffer;
	//BatchElement.NumPrimitives = NumPrimitives;
	BatchElement.MaxVertexIndex = MeshVertexBuffersSection->VertexBuffers.PositionVertexBuffer.GetNumVertices() - 1;		
	MeshBatch.Elements.Add(BatchElement);
	
	PDI->DrawMesh(MeshBatch, FLT_MAX);
	
}

```

Hope that this helps!🙂

---

<div class="post-metadata">

**Author:** ![ibrahim.pinar1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ibrahim.pinar1](https://forums.unrealengine.com/u/ibrahim.pinar1)\
**Post date:** [May 30, 2022, 3:37pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/8 "2022-05-30T15:37:13Z")

</div>

could you please explain a bit more about what is needed to make this work? UProceduralMeshComponent does not overload this DrawStaticElements function, so where does it come from and how do i make sure it gets used? also it seems that the code you posted contains a bit more custom stuff, like the FRYCProcMeshProxySection for example. is this also necessary?

---

<div class="post-metadata">

**Author:** ![Czochcio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Czochcio](https://forums.unrealengine.com/u/Czochcio)\
**Post date:** [June 1, 2022, 2:24pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/9 "2022-06-01T14:24:22Z")

</div>

Hi,

Yes, so UProceduralMeshComponent doesnt have this element as UProceduralMeshComponent is representation of Procedural Mesh in GameThread.  
Rendering stuff in which you are interested in is defined in FProceduralMeshSceneProxy - which is representaition on Rendering Thread. Code for it should be available in .cpp file of UProceduralMeshComponent.  
FProceduralMeshSceneProxy extends FPrimitiveSceneProxy and this one has DrawStaticElements method.

Now there are two options - you can modify engine and recompile it to have modified version of Procedural Mesh Component or you can create (copy) procedural mesh component and modify it so it supports virtual texturing using code I’ve placed.

In the code I’ve placed you are right there is FRYCProcMeshProxySection as I’ve created my own procedural mesh component. The one I’ve created is based on ProceduralMeshComponent but modified. In order to made my code work with Procedural Mesh Component you would just need to change FRYCProcMeshProxySection to FProcMeshProxySection as FProcMeshProxySection is used internally by Procedural Mesh Component.

Hope that this helps.

---

<div class="post-metadata">

**Author:** ![ibrahim.pinar1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ibrahim.pinar1](https://forums.unrealengine.com/u/ibrahim.pinar1)\
**Post date:** [June 6, 2022, 2:16pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/10 "2022-06-06T14:16:08Z")

</div>

Thank you for your reply.  
Are you telling me that I should copy the whole ProceduralMeshComponent code, in the FProceduralMeshSceneProxy implementation override the DrawStaticElements method, and then use the new copied component instead of making a component that inherits from it?  
I am unfortunately not very familiar with rendering or how it works in unreal, but i would really like to get this working.

---

<div class="post-metadata">

**Author:** ![USERf7f7c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@USERf7f7c](https://forums.unrealengine.com/u/USERf7f7c)\
**Post date:** [June 14, 2022, 9:52am UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/11 "2022-06-14T09:52:43Z")

</div>

Thanks Czochcio, I modified the code like this . It’s worked for me

[0001-UProceduralMeshSceneComponent-support-draw-in-virtua.patch](https://forums.unrealengine.com/uploads/short-url/lSnU0VVdAYQLBk4qmPnVeA1Y09e.patch) (3.0 KB)

```cpp
	virtual void DrawStaticElements(FStaticPrimitiveDrawInterface* PDI) override
	{
		if (RuntimeVirtualTextures.Num())
		{
			for (const FProcMeshProxySection* Section : Sections)
			{
				UMaterialInterface* SectionMat = Section->Material;
				check(SectionMat);

				FMeshBatch MeshBatch;
				MeshBatch.LODIndex = 0;
				MeshBatch.SegmentIndex = 0;

				MeshBatch.VertexFactory = &Section->VertexFactory;
				MeshBatch.Type = PT_TriangleList;

				MeshBatch.LODIndex = 0;
				MeshBatch.SegmentIndex = 0;

				MeshBatch.bDitheredLODTransition = !IsMovable() && Section->Material->GetRenderProxy()->GetMaterialInterface()->IsDitheredLODTransition();
				MeshBatch.bWireframe = false;
				MeshBatch.CastShadow = false;
				MeshBatch.bUseForDepthPass = false;
				MeshBatch.bUseAsOccluder = false;
				MeshBatch.bUseForMaterial = false;
				MeshBatch.bRenderToVirtualTexture = true;
				MeshBatch.MaterialRenderProxy = Section->Material->GetRenderProxy();
				MeshBatch.RuntimeVirtualTextureMaterialType = (int32)ERuntimeVirtualTextureMaterialType::BaseColor_Normal_Specular;
				MeshBatch.ReverseCulling = IsLocalToWorldDeterminantNegative();

				MeshBatch.DepthPriorityGroup = SDPG_World;
				MeshBatch.bCanApplyViewModeOverrides = false;

				MeshBatch.Elements.Empty(1);
				FMeshBatchElement BatchElement;
				BatchElement.IndexBuffer = &Section->IndexBuffer;
				BatchElement.FirstIndex = 0;
				BatchElement.NumPrimitives = Section->IndexBuffer.Indices.Num() / 3;
				BatchElement.MinVertexIndex = 0;
				BatchElement.MaxVertexIndex = Section->VertexBuffers.PositionVertexBuffer.GetNumVertices() - 1;
				MeshBatch.Elements.Add(BatchElement);

				PDI->DrawMesh(MeshBatch, FLT_MAX);
			}
		}
	}

```

---

<div class="post-metadata">

**Author:** ![sweet2k4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sweet2k4](https://forums.unrealengine.com/u/sweet2k4)\
**Post date:** [February 2, 2023, 1:03pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/12 "2023-02-02T13:03:31Z")

</div>

Is it possible to do the same for meshes generated by geometry script in ue5?

---

<div class="post-metadata">

**Author:** ![sweet2k4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sweet2k4](https://forums.unrealengine.com/u/sweet2k4)\
**Post date:** [February 2, 2023, 11:34pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/13 "2023-02-02T23:34:08Z")

</div>

I ended up converting the generated mesh (Geometry script) to a runtime static mesh. That works with RVT. just pass the Target Mesh to this this function:

```auto
 UStaticMesh* UGeoConverter::DynamicToStaticMesh(const UDynamicMesh* DynamicMesh, const FName Name)
{
	// Create a new static mesh with unique name
	const UWorld* World = DynamicMesh->GetWorld();
	UStaticMesh* StaticMesh = NewObject<UStaticMesh>(World->GetCurrentLevel(), Name, RF_Transient);

	// Get the static mesh source model
	FStaticMeshSourceModel& SrcModel = StaticMesh->AddSourceModel();
	SrcModel.BuildSettings.bRecomputeNormals = false;

	FMeshDescription MeshDescription;
	FStaticMeshAttributes StaticMeshAttributes(MeshDescription);
	StaticMeshAttributes.Register();

	const FDynamicMesh3* Mesh = DynamicMesh->GetMeshPtr();

	FDynamicMeshToMeshDescription Converter;
	Converter.Convert(Mesh, MeshDescription);
	
	// Build the static mesh render data, one FMeshDescription* per LOD.
	TArray<const FMeshDescription*> MeshDescriptionPtrs;
	MeshDescriptionPtrs.Emplace(&MeshDescription);
	StaticMesh->BuildFromMeshDescriptions(MeshDescriptionPtrs);
	
	return StaticMesh;
}

```

You also need to include some modules  
“GeometryFramework” “StaticMeshDescription”, “MeshDescription”, “MeshConversion”

---

<div class="post-metadata">

**Author:** ![lls6862070](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lls6862070](https://forums.unrealengine.com/u/lls6862070)\
**Post date:** [March 17, 2023, 2:57pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/14 "2023-03-17T14:57:08Z")

</div>

[Test\_UE5\_006\_20230317.zip](https://forums.unrealengine.com/uploads/short-url/rC7jE6LXJHp2oh3PAdR6G5jBvdS.zip) (883.0 KB)  
I tried doing the same with the mesh generated by the geometry script in the ue5 runtime, but it had no effect when running or packaging the runtime

```auto
	virtual void FPlottingDynamicMeshSceneProxy::DrawStaticElements(FStaticPrimitiveDrawInterface* PDI) override
{
	if (RuntimeVirtualTextures.Num())
	{
		TArray<FMeshRenderBufferSet*> Buffers;
		GetActiveRenderBufferSets(Buffers);
		for (const FMeshRenderBufferSet* Buffer : Buffers)
		{
			UMaterialInterface* BufferMat = Buffer->Material;
			check(BufferMat);

			FMeshBatch MeshBatch;
			MeshBatch.LODIndex = 0;
			MeshBatch.SegmentIndex = 0;

			MeshBatch.VertexFactory = &Buffer->VertexFactory;
			MeshBatch.Type = PT_TriangleList;

			MeshBatch.LODIndex = 0;
			MeshBatch.SegmentIndex = 0;

			MeshBatch.bDitheredLODTransition = !IsMovable() && Buffer->Material->GetRenderProxy()->GetMaterialInterface()->IsDitheredLODTransition();
			MeshBatch.bWireframe = false;
			MeshBatch.CastShadow = false;
			MeshBatch.bUseForDepthPass = false;
			MeshBatch.bUseAsOccluder = false;
			MeshBatch.bUseForMaterial = false;
			MeshBatch.bRenderToVirtualTexture = true;
			MeshBatch.MaterialRenderProxy = Buffer->Material->GetRenderProxy();
			MeshBatch.RuntimeVirtualTextureMaterialType = (int32)ERuntimeVirtualTextureMaterialType::BaseColor_Normal_Specular;
			MeshBatch.ReverseCulling = IsLocalToWorldDeterminantNegative();

			MeshBatch.DepthPriorityGroup = SDPG_World;
			MeshBatch.bCanApplyViewModeOverrides = false;

			MeshBatch.Elements.Empty(1);
			FMeshBatchElement BatchElement;
			BatchElement.IndexBuffer = &Buffer->IndexBuffer;
			BatchElement.FirstIndex = 0;
			BatchElement.NumPrimitives = Buffer->IndexBuffer.Indices.Num() / 3;
			BatchElement.MinVertexIndex = 0;
			BatchElement.MaxVertexIndex = Buffer->StaticMeshVertexBuffer.GetNumVertices() - 1;
			MeshBatch.Elements.Add(BatchElement);

			PDI->DrawMesh(MeshBatch, FLT_MAX);
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![lls6862070](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lls6862070](https://forums.unrealengine.com/u/lls6862070)\
**Post date:** [March 19, 2023, 9:50am UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/15 "2023-03-19T09:50:27Z")

</div>

Solved, the code RuntimeVirtualTextureMaterialType is the same as the scene.

```auto
MeshBatch.RuntimeVirtualTextureMaterialType = (int32)ERuntimeVirtualTextureMaterialType::BaseColor_Normal_Roughness;

```

---

<div class="post-metadata">

**Author:** ![lls6862070](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lls6862070](https://forums.unrealengine.com/u/lls6862070)\
**Post date:** [March 20, 2023, 7:37am UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/16 "2023-03-20T07:37:28Z")

</div>

I modified it a little bit to fit the runtime conversion.

```auto
void URuntimeToolBPLibrary::DynamicToStaticMesh(const UDynamicMesh* DynamicMesh, const FName Name, UStaticMesh*& StaticMesh)
{
	if (DynamicMesh == nullptr)
		return;

	const UWorld* World = DynamicMesh->GetWorld();
	UStaticMesh* LocalStaticMesh = NewObject<UStaticMesh>(World->GetCurrentLevel(), Name, RF_Transient);

	LocalStaticMesh->bAllowCPUAccess = true;
	LocalStaticMesh->bSupportGpuUniformlyDistributedSampling = true;

	LocalStaticMesh->SetLightingGuid();

	FMeshDescription MeshDescription;
	FStaticMeshAttributes StaticMeshAttributes(MeshDescription);
	StaticMeshAttributes.Register();

	const FDynamicMesh3* Mesh = DynamicMesh->GetMeshPtr();

	FDynamicMeshToMeshDescription Converter;
	Converter.Convert(Mesh, MeshDescription);

	TArray<const FMeshDescription*> MeshDescriptionPtrs;
	MeshDescriptionPtrs.Emplace(&MeshDescription);

	UStaticMesh::FBuildMeshDescriptionsParams mdParams;
	//mdParams.bBuildSimpleCollision = true;
	mdParams.bFastBuild = true;
	mdParams.bAllowCpuAccess = true;
	mdParams.bCommitMeshDescription = true;

	LocalStaticMesh->BuildFromMeshDescriptions(MeshDescriptionPtrs, mdParams);

	FStaticMeshRenderData* LocalStaticMeshRenderData = LocalStaticMesh->GetRenderData();
	FStaticMeshLODResources* LocalStaticMeshLODResources = const_cast<FStaticMeshLODResources *>(LocalStaticMeshRenderData->GetCurrentFirstLOD(0));
	if (LocalStaticMeshLODResources && LocalStaticMeshLODResources->Sections.Num() > 0)
	{
		for (int i = 0; LocalStaticMeshLODResources->Sections.Num() > i; i++)
		{
			LocalStaticMeshLODResources->Sections[i].MaterialIndex = 0;
		}
	}

	StaticMesh = LocalStaticMesh;
}

```

---

<div class="post-metadata">

**Author:** ![maluko1750](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@maluko1750](https://forums.unrealengine.com/u/maluko1750)\
**Post date:** [June 25, 2025, 3:36pm UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/17 "2025-06-25T15:36:59Z")

</div>

I’ve been struggling to get this to work properly. Is there any chance you could share the .cpp and .h files for your custom ProceduralMeshComponent?

---

<div class="post-metadata">

**Author:** ![jjacques](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jjacques/32/682933_2.png) [@jjacques](https://forums.unrealengine.com/u/jjacques)\
**Post date:** [August 17, 2025, 11:25am UTC](https://forums.unrealengine.com/t/virtual-texture-and-procedural-mesh/480227/18 "2025-08-17T11:25:39Z")

</div>

just need to copy dynamic mesh to a static mesh

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/6/7f62203c885243e4ce1e5d2ed69773e66ed0c43a.png)
