Basic Iteration

This tutorial takes you through the process of building iterative procedures, that-is, repeatedly invoking a procedure to create more content.

Prerequisites

  • This uses the Custom Asset tutorial, so please make sure you are using a project where you've already followed that tutorial.

Primary Goals

  • Basic iteration
    • Recursively invoking a procedure from itself
    • Testing the end condition
    • Accumulating all the generated content

Secondary Goals

  • Parameterisation by quantity
  • Using Notes to group and document procedures
  • Using Comments to explain operator use
  • Groundwork for the following demo

Instructions

Create the procedure

  1. Open the Apparance Editor and create a new procedure Test.Block Stack (Named Block Stack and in the Test category).
  2. Add the Shiny Cube procedure to your new procedure (as you would any other operator, but dragged from the Procedure panel instead).
  3. Use it's Where? input as the first procedure input (drag out to the left side).
  4. Add an integer greater-than operator (GreaterThanI) connected to an If operator for switching content (IfSeg).
  5. Add a Merge operator (Merge2) to accumulate the current block into the generated stack.
  6. Add a frame offset operator (Offset) to place each new block on top of the previous one (Z shift by 1x the current block size)
  7. Add an integer subtract (SubI) to reduce the count each iteration.
  8. Wire everything up as shown below, taking the output of the If as the only procedure output and the Cube/Offset frame and GT/sub integer inputs as the inputs (Cube and Count respectively).
  9. Now comes the fun part; drag the Shiny Cube procedure from the Procedure panel and place it inside itself. Wiring up as shown.
  10. Configure the Count input to acept a range of values:
    1. Select the Count input to access it's properties.
    2. Click the Metadata button next to the description field.
    3. In the expanded UI you can now configure its editing behaviour.
    4. Click the Ranged checkbox, leave the default min/max at 0 and 100 for now.
  11. Save the procedure by clicking the Save button or Ctrl+S.

Tip
Content is passed around in Apparance using a data type called Model Segment as it refers to a specific part of the accumulated content or geometry built so far. Generally you can just treat this as a 'content pipe' that feeds the overall procedure output. It is represented in the Apparance Editor with white wires

Place the procedure

  1. Back in Unreal, drag in a new Apparance Entity and set it to use the Test.Block Stack procedure.
  2. Set the Cube parameter size to 1 x 1 x 0.1 (to squash it)
  3. Dial up the Count parameter to create your block stack

Extras

Optionally you can document the procedure a little by:

  1. Grouping the recursive part of the graph with a Note.
    1. Marquee select the three operators with LMBdrag.
    2. Group together using Group with note in the RMBcontext menu.
    3. Resize/rearrange the note by LMBdouble-clicking on it.
    4. Change the note text by LMBdouble-clicking on it a second time. (click off it to finish).
  2. Adding a comment to the greater-than operator to explain what it is doing:
    1. Select the > operator
    2. In the property panel notice the faint 'Comment' field at the top, below the description and above the input list.
    3. Enter a comment such as "are there any more?"
    4. The property appears normal and the comment text now appears above the operator in the node graph.

Procedure

Your procedure should look something like this:

Next Steps

Note
This tutorial has set the groundwork for the following Introducing Variation tutorial that you may want to follow next.