Announcement

Collapse
No announcement yet.

4.8.3 Mesh generation

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    4.8.3 Mesh generation

    Hey guys,

    Recently I worked with C ++ code generating planets from bubbles (truncated octahedrons).
    Click image for larger version

Name:	Truncated_octahedra_small.png
Views:	1
Size:	122.7 KB
ID:	1159295

    Here is my result.
    Click image for larger version

Name:	truncated_hexagon_planet.jpg
Views:	1
Size:	406.2 KB
ID:	1159293

    I generate only front faces so it's quite well oprtimized. Inside view:
    Click image for larger version

Name:	inside.jpg
Views:	1
Size:	128.2 KB
ID:	1159294

    What do You think about this idea? I have also implemented point gravity and character moves fine around the planets.

    Unfortunatally I have some problems with mesh update. For small planets it works really well. All bubbles can be changed to any ID (material) and color. With increasing planet size performance suffer.

    For planet 80x80x160 = 1024000 update takes 2 seconds. It cannot be stand anymore because game freezes.
    Firstly I thought that every section from CreateMeshSection function are independent so I tried to use many sections. Right now I know it doesn't matter because every time mesh change it regenerates whole mesh.

    My question is how can I get better respond to mesh changes. Should I use more mesh objects?
    mesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("ProceduralMesh"));

    Thanks

    #2
    For my game, I'm running the updates in chunks to keep it somewhat performant. During runtime you really don't end up with situations where you'd need to make changes to hundreds of meshes at once most likely so it's also probably ok if it takes a second since you only really incur that cost at load. You could also probably do this work in another thread so it doesn't block the game loop if you want to, but that's a bit above my understanding. I think Rama has a good tutorial on it on the wiki. https://wiki.unrealengine.com/Multi-...Threads_in_UE4
    Last edited by Hyperloop; 08-12-2015, 12:13 PM.
    Trevor Lee

    Comment


      #3
      Problem is not to generate data which takes 0.2 sec. Problem is to run function provided with 4.8.3 version.
      CreateMeshSection took ~3s and it's getting worse for bigger planets.
      Only way is to generate separate meshes and update them when needed.

      I probably could use Threads and instances meshes like buffer not slowing down game but in most cases i just need to update mesh quick (add/remove only a few faces).

      for 80 size (40x40x80)
      GenerateBubble in 0.025000
      CreateMeshSection in 0.581000

      for 160 size (80x80x160)
      GenerateBubble in 0.151000
      CreateMeshSection in 3.090000
      Last edited by Tefel; 08-12-2015, 12:51 PM.

      Comment


        #4
        What does the CreateMeshSection do?
        Does it only mean "mesh->CreateMeshSection(0, Vertices, Triangles, Normals, UVs, VertexColors, Tangents, false);" or do you do something additional to that? Like calculating the array (vertices)...

        Anyway, as other said, partition your space into chunks. So that your planet would consist of many 32by32by32 chunks instead of a huge one. At worst case (checkerboard) it can't exceed 32768 blocks.
        It seems you are already removing faces that are obscured.
        I wouldn't generate physics for the visual mesh either, as there are better ways to fake it.

        As of the idea, it's great. Maybe you can smooth the terain with some slanted bubbles.
        Similar to the way a cube system would: http://i1041.photobucket.com/albums/.../Sculpt_02.png

        Comment


          #5
          Yeah CreateMeshSection update whole mesh so it's like generating mesh from nothing.
          I already divide my 3d space into parts so my calculations are ok and I update only dirty part after change.
          Anyway I still need several meshes because I cannot work with only one. There is no support for face updating. Only way to do it is just update entire mesh. I just wanted to convince myself. Thx

          Similar to the way a cube system would: http://i1041.photobucket.com/albums/.../Sculpt_02.png
          These are cubes with only 6 directions. Making spherical planets can be problematic except if You make the game like planet^3.

          OK So I decided to divide space into chunks (4x4x4) 64 total for planet.
          GenerateBubble in 0.001000
          CreateMeshSection in 0.007000
          Times are great. Everything works. Even if I need to update many chunks at once.
          Last edited by Tefel; 08-12-2015, 06:51 PM.

          Comment


            #6
            Originally posted by Tefel View Post
            These are cubes with only 6 directions. Making spherical planets can be problematic except if You make the game like planet^3.
            I meant similarly, not the same way. Just that a picture was hard to find.
            So I made one
            Click image for larger version

Name:	357bb3a531.png
Views:	1
Size:	24.3 KB
ID:	1083693

            The yellow one shows just how many nice cutting lines there are.
            By using such cut out sub shapes, you could smooth the bumps to a minimum.
            At least that was the hunch I had.

            Comment


              #7
              Yeah that's cool. then surfaces can be completely flat and I can make game like TTD I'll think about it

              Anwyay I think "bubble" shape is great too. I can build very nice worlds from it. I never see it was used before.
              It's easier to use, needs less memory and I can shrink it even more.

              Comment


                #8
                Have you tried creating Instanced Static Mesh from the Procedural Mesh once it has been created?

                -
                I'm going to try, thought it may work in this situation.

                -
                I checked it out, and it works on the basis as other mesh. Using the UBodySetup which acts as the collision mesh in-game, you may be able to export the Mesh then Instance that for better performance. -- It seems theoretically possible. Could be problems attempting this. I'll try it if I get time if you don't.
                Last edited by PeterLNewton; 08-15-2015, 01:49 PM.

                Comment


                  #9
                  Why would I ever want to create instances of procedurally generated mesh?

                  Before I started with mesh generation I tested mesh instances. Performance was good but right now when I show only front faces it is even better. Problem was exactly the same - removing / adding instances was taking some time. I needed to create more and more instanced static mesh components. Right now I make many of Procedural mesh components. Performance suffer a little bit but I really need to be able to quickly modify generated mesh.
                  Last edited by Tefel; 08-15-2015, 07:00 PM.

                  Comment


                    #10
                    OK. so here is my final work. I just uploaded video for You guys.
                    https://www.youtube.com/watch?v=PLzu-nCjhA8

                    Comment


                      #11
                      That looks freaking fantastic. I desperately want to play that game.

                      Comment

                      Working...
                      X