Search Unity

Random mesh deformation with quads

Discussion in 'Scripting' started by Kequc, Nov 6, 2018.

  1. Kequc

    Kequc

    Joined:
    Oct 23, 2015
    Posts:
    21
    I have a small game under development that generates a wide flat low poly 3d island made of vertexes all 1m apart. All with hard edges. This so far is fantastic however it's formed perfectly and is devastatingly smooth.

    I think it would be more interesting to deform each vertex by a very small amount in all three directions. To introducea bit more of a human looking or natural aesthetic.

    My island is mostly made up of quads, and so randomly moving each vertex doesn't work, as the individual quads themselves would be deformed. If you could imagine I still want hard edges, no curved surfaces. But it is very easy to make a quad which is not a flat shape.

    Where two opposite verticies are higher than their neighbours for example.

    My question is, how can I add random deformation to my grid of verticies, while retaining each quad and triangle's individual flatness.

    Will I need to convert my whole island into triangle's to pull this off? What is the ideal arrangement or pattern for them? Is there a mathematical formula I can use in conjunction with quads?

    Thank you for your help. I'm posting from mobile right now, I will return and add a screenshot later if it would be helpful. Any and all suggestions or thoughts are appreciated!
     
  2. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    565
    I highly recommend the Irregularity tutorial on the Catlike Coding website. I have made procedural worlds with hexagonal and voronoi grid nodes, and really enjoy the process of creating them. I'd be interested in seeing your results :)

    Additionally, the following links are also appropriate for similar projects:
    https://catlikecoding.com/unity/tutorials/hex-map/
    https://www.reddit.com/r/proceduralgeneration/comments/99028e/island_generation_process_video/
    http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
     
    Xepherys likes this.
  3. Kequc

    Kequc

    Joined:
    Oct 23, 2015
    Posts:
    21
    Here are some screenshots of what I am working with.

    https://imgur.com/a/v94oDOS

    You can see I have an island generating. The sand layer is missing because it makes it a little bit easier to see, this is just the rock formation. Each layer is individual and as you can see can be removed individually, because during gameplay you are navigating up and down through layers.

    You can see what I mean by the "quads" I mentioned... It's rendered basically as minimally as possible with as few vertexes I can reasonably expect to reason out. I'm sure some really difficult optimisation could be possible but since I want to add some slight distortion to each of these vertexes it's ultimately going to get more complex.

    The options I'm considering for breaking up my quads are as follows.

    https://imgur.com/a/jY7ukQB

    I don't think the second one is possible, given some of the shapes I need to produce I'm pretty sure at the very least I need to have the full diagonal divisions. The first option is definitely going to add a lot of complexity to the mesh, is it something that once distorted would look pretty good?

    Thank you for your links, you had on hand. Interesting articles. I don't feel like I'm doing anything quite that complex, and with the structure of my game I definitely need to keep at least the basics of a real grid. The design I'm working toward is grid based.
     
  4. Kequc

    Kequc

    Joined:
    Oct 23, 2015
    Posts:
    21
    In order to not complicate things more than they need to be I thought I'd try first at simply making every face a set of 2 triangles. I figure out whether the slice needs to face left or right and if neither then I choose randomly. I built a matrix of all possible vertex locations and perturb them a small amount.

    That looks quite good enough I think, I like how I can choose how much I want the effect. There are a lot more vertices in the mesh but at least it isn't as much as cutting them into 4 would be.

    https://imgur.com/a/BXF3kaK

    "Perturbing" is a term a like quite a bit now.

    I'm going to stick with this solution for now, I'll work on texturing and so on in the future so that it doesn't look so metallic for example. It's possible I'll want a flat surface so I'll only perturb the x and z axis. Thanks for your help! More comments are welcome.