Search Unity

Procedural Generation - Additive or Subtractive?

Discussion in 'Scripting' started by Xepherys, Feb 3, 2014.

  1. Xepherys

    Xepherys

    Joined:
    Sep 9, 2012
    Posts:
    204
    So, I'm working on scripting a procedurally generated 2D labyrinth. I've considered both of the following options, but am curious which would be the most efficient from a resource perspective. Any insight would be tremendously helpful.

    Option #1 - Generate an area, subtract backwards from an endpoint to the startpoint and wall off areas accordingly.

    Option #2 - Generate the successful path, adding iterative paths for additional dimension, and build additively throughout.


    In other words, in option one it would be similar to starting with a solid block of stone and carving the path from end to start, with some additional side paths to flesh it out.

    The second option would be to start with a blank slate (a void), generate the solution path, build out form there, then enclose it.

    It seems like the second option would allow for more uniqueness (not being generated within a particular boundary of coordinates). But the first seems like, because of having boundaries, it may keep constraints more regular and be less resource intensive.

    Any thoughts?
     
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Frankly, I'm not seeing the difference between the two, because in both case, you won't generate a mesh out of that; that would be very expensive for very little result.

    Option 1 or 2, you'll probably end up instantiating prefabs of corridor pieces. In both case, you generate a right path, then fill the missing space with false paths. It will always end up as values in a 2D or 3D tables, therefore limited by that table's size.