Hi, for my spline based road system I am adding lots of small meshes, there are about 150’000 in total for the whole road system.
The mesh itself is quite simple with 264 triangles at LOD 0 going down to 32 triangles for the final LOD
I’m getting abot 20FPS in PIE and Stat Unit shows GPU 49ms when playing in the editor.
This I could understand given the number of spline meshes involved, as there would be a horrendous number of draw calls, if it weren’t for the fact that I have culling set at 10’000, so there are only a small number of meshes being drawn at any one time. None of the processor cores are getting maxed out and the GPU is running at about 20% in Task Manager
Is there anything fundamentaly wrong with the code I’m using within BeginPlay?
USplineMeshComponent *splineMesh = NewObject<USplineMeshComponent>(this);
splineMesh->RegisterComponent();
splineMesh->CreationMethod = EComponentCreationMethod::UserConstructionScript;
splineMesh->SetForwardAxis(ESplineMeshAxis::X);
splineMesh->SetMobility(EComponentMobility::Type::Static);
UStaticMesh* RoadMesh = LoadObject<UStaticMesh>(nullptr, TEXT("StaticMesh'/Game/Meshes/RoadMeshes/10m_straight.10m_straight'"));
splineMesh->SetStaticMesh(RoadMesh);
splineMesh->SetCullDistance(10000);
UMaterialInterface* RoadMat = LoadObject<UMaterialInterface>(nullptr, TEXT("MaterialInstanceConstant'/Game/Meshes/RoadMeshes/curb_Inst.curb_Inst'"));
UMaterialInterface* PavementMat = LoadObject<UMaterialInterface>(nullptr, TEXT("MaterialInstanceConstant'/Game/Meshes/RoadMeshes/pavement_Inst.pavement_Inst'"));
UMaterialInterface* CurbMat = LoadObject<UMaterialInterface>(nullptr, TEXT("MaterialInstanceConstant'/Game/Meshes/RoadMeshes/Roadmaterial_Inst.Roadmaterial_Inst'"));
splineMesh->SetMaterial(0, RoadMat);
splineMesh->SetMaterial(1, PavementMat);
splineMesh->SetMaterial(2, CurbMat);
splineMesh->SetStartAndEnd(splinePointLocation, splinePointTangent, splinePointLocation2, splinePointTangent2);
splineMesh->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
splineMesh->AttachToComponent(Splines[RoadNumber], FAttachmentTransformRules::FAttachmentTransformRules(EAttachmentRule::KeepRelative, true));
A_SplineMesh.Add(splineMesh);
Stat GPU result from the console
Because I’m culling the meshes at such a short distance I would have expected a decent framerate in the 60fps range