Craters On Projectile impact (using UProceduralMeshComponent)

Hello everyone

After finishing section 04, I had the idea of using my new C++ knowledge (thanks Ben :slight_smile: ) to recreate some functionality with C++, that I once made with Blueprint.

Blueprint project:

#Challenge

  • Recreate Mesh generation functionality with C++
  • make Terrain deform on projectile impact

I have nothing to show yet, but decided to start this topic because I thought some of you might like to join the challenge and try it themselves. :wink:
I willl link my github repo once I’ve got something.

Starterguide on using the ProceduralMeshComponent:
https://wiki.unrealengine.com/Procedural_Mesh_Component_in_C%2B%2B:Getting_Started

#Update 01
After some fiddling I was able to recreate the mesh generation and there was one thing that really suprised me…


The performance from BP vs. C++ is not that different at first glance the real performance killer is the provided engine function called:

UKismetProceduralMeshLibrary::CalculateTangentsForMesh(Vertices, Triangles, UV, OUT Normals, OUT Tangents)

generating 100 *100 Quads in C++ without that function takes 50ms. With the function 950ms!
The Blueprint equivalent takes about 110ms without and 1150ms with calculating tangents.
So if you don’t calculate the tangents, c++ is more than 2x faster, but with the function it is almost the same.

But still it doesn’t really bother me. The procedural mesh terrain I have in mind is alot like the official landscape with it’s components and section size.
I think I can get away with a section size of 100m100m (5050 quads, single quad 2m).

Whenever a projectiles hits the ground in most cases only 1 section has to be updated (2 or 4 if it happens to hit the borders) so it shouldn’t really matter how many of those sections you generate.

I hope you could understand what I was talking about :smiley:

If you want to take a deeper look to my nonsense: https://github.com/Minaosis/04_BattleTank/commit/56489f9935980ae9e8f1151919541cb7eaa4a61a

#Update 02

creating craters on hit works now.

The terrain in this video is made out of 256 sections (64 x 64 Vertices/ Section).
With a quadsize of 1m this makes the terrain 1km x 1km big.

Performance is already pretty good, considering the size of the terrain but there are some things that can be further optimized.

  • Reduce number of drawn triangles with a LOD system
  • dynamically deactivate section collision if playerpawn, ai or projectiles not in range
  • hide sections that are not visible to the player

Privacy & Terms