Virtual Texture and Procedural Mesh

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!:slight_smile: