Announcement

Collapse
No announcement yet.

Mitigating compile times with procedural worlds

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

    Mitigating compile times with procedural worlds

    Edit:

    So it looks like the short of it is that UE4 does not deal too well with getting and setting location for instanced meshes as well as I was hoping. This is something I can bypass by applying my placement logic before a tile is placed instead of trying to update it. Makes it a bit harder to iterate through the logic with a single loop but compile times are down to a few seconds. This however is a bit of a limitation as I was hoping to make updates to tile locations during run time on a large scale, however I am thinking I can still get this to work if I can break up the tiles within designation arrays at world gen so I mitigate the amount of tiles I would need to iterate through instead of going through the entire list during runtime.



    Hey everyone,
    I'm experiencing issues with long compile times on logic that creates a basic world when ran.
    I don't believe my hardware is the issue. Im running I5 with 16GB of ram and all my project files, assets, and the UE4 install are all on a SDD. I have also edited the config file to use multiple cores. The only thing I notice hardware wise is that my system is only using 4GB of RAM and only 25% of my CPU when compiling and not more.

    Since I don't think its my hardware I think it may be the logic I'm using and was hoping I could get some input on how to improve my it.

    When the program is ran it will create a flat world composing of only of 400000 tiles in a 200X200 Grid. The tiles are an instance static mesh root of an actor I have that is running the logic. They 200X200 in size as well and they do have a bit of depth and collision enabled to allow for physics with high velocity objects.
    This only takes 10 seconds to compile and is what I would expect. However I then perform logic to elevate tiles to create a pyramid shape landscape. After that I then replace some of the tiles with instances off "instance static mesh component" within the same actor that contains the tile instanced static mesh. When I try to compile with this logic enabled it then takes well over 2 hours to compile.

    To get the pyramid shape I have some logic that randomly generates several coordinates in descending width and height. I use these coordinates to create logical squares that box in tiles located within the bounds. Now to check to see if a tile is within the bounds of one of the squares I have to iterate through every tile, get it's location and then compare it to the coordinates to check to see if it is within the bounds. Since this is an instance static mesh the only way I can seem to do this is just get the count of my instances and then iterate through every tile based off the index created by the count. If a tile is identified within one of the logical squares it then goes up in height equal to its width (200). At this same time a random number of tiles that were moved are replaced with instances of another "instanced static mesh" to change the tile to something physically different. The tile replacement requires the removal of the old tile and creation of the new instanced static mesh component. This happens for every layer of squares until the tip of the pyramid is created. There is also some logic that randomizes the tip of the pyramid, giving it a randomly curvature as it reached the tip.

    Does this sound like something that would normally take a long time to compile? Is my logic faulty and are there much easier ways to do this? Does it sound like I am using Instanced Static Meshes correctly?

    I would greatly appreciate any input you may have.
    Last edited by MTree; 06-22-2015, 11:16 AM.

    #2
    Click image for larger version

Name:	miniexample.png
Views:	1
Size:	922.5 KB
ID:	1080206

    Here is a visual example of the same logic, but on a much smaller scale and creating an inverted pyramid. This is a 40X50. Some of the random generated features are not visible at this small of scale, but you can see that certain tiles are replaced with "walls". The trick I use to determine which tiles to delete is rather simple approach. Since I only want to delete the tiles I know that will change I do a 4 coordinate to get the outer edge and designate these as tiles to be replaced with walls. The designate is a rather odd mechanic, but I'm simply setting them to a specific height I use a token to delete them. Which means I have to iterate through all of the instances again. This is a lot of logic to perform on a 200X200, but it seems like there is not much you can do with instanced static mesh components. I would assume trying to do this with non instanced meshes would make matters worse but I haven't tested this yet. My understanding of instances static meshes were efficient for mass usage, but at the loss of some accessibility to single out a specific instance.

    Comment


      #3
      By compile, you mean pressing the "Compile Button" in the editor, or do you mean generating your world?

      Your 200x200 grid of meshes is truly flat? Does it have any kind of features that are calculated? Just doing math for some vectors and spawning 40,000 actors should be almost instant. If you are hitting play and it takes 10 seconds from that point, some of that may be the editor firing things up.

      How much actual work is being done to generate your pyramid? I can generate somewhat realistic continents on 5000 tiles, taking around 2 billion iterations, in about 25 seconds. If you are just making a pyramid shape with some minor features that should be pretty quick.
      Map Generator 1.0
      Map Generator 2.0
      Map Generator 3.0

      Comment


        #4
        Hey Zeustiak, thanks for the response.

        I responded to the points of your post.

        Originally posted by Zeustiak View Post
        By compile, you mean pressing the "Compile Button" in the editor, or do you mean generating your world?

        Both, I have my world gen logic on the constructor of an actor that I have spawned in the world. So every time I press the compile button it compiles and is generating the world.


        Originally posted by Zeustiak View Post
        Your 200x200 grid of meshes is truly flat?
        The face of each tile is flat, but does have depth. The first world step of the world gen is to create a flat world of these tiles. This only takes a few seconds to perform by itself.


        Originally posted by Zeustiak View Post
        Does it have any kind of features that are calculated?
        Yes features such as height of the tile and several checks to randomize wall tiles. I go into this more in depth in my posts above.


        Originally posted by Zeustiak View Post
        Just doing math for some vectors and spawning 40,000 actors should be almost instant.
        I receive this behavior as well, its only when Iterate through my instanced static mesh components to move/replace them does it tak

        Originally posted by Zeustiak View Post
        If you are hitting play and it takes 10 seconds from that point, some of that may be the editor firing things up.
        Since the world gen is happening during the compile then no real logic is occurring when I press play, in which i experience no delay what so ever.


        Originally posted by Zeustiak View Post
        How much actual work is being done to generate your pyramid?
        I go more in depth of the process step by step in my above posts.

        Comment

        Working...
        X