To access the tutorials in ArcGIS CityEngine, click Help > Download Tutorials and Examples. After choosing a tutorial or example, the project is automatically downloaded and added to your workspace.
In this tutorial, you will analyze how to split a façade to create a rule template more intuitively, import more detailed façade elements and edit the CGA template for advanced façade creation. To start with the basics of facade creation, see Tutorial 13a: Facade Wizard—Basic facade creation
In this example, you will load an image file into the Facade Wizard to create a facade rule template. Later, you will create a simple mass model building rule and trigger the previously generated facade rule.
Facade analysis and rule creation
The original facade texture file you will be using is an advanced facade:

It has a set of difficulties that you will encounter often when creating more complex facades with the Facade Wizard.
Most of the time, when using the Facade Wizard, it is necessary to carefully study the facade details, such as the number of window subdivisions, repetitions in ornamental details, or uneven floor heights, to find the best way to split up the structure. It is recommended that you take time to think about this strategically.
In the following scheme, you can see one possible approach toward the creation of the main facade subdivision:
- Green—Single tile, nonrepetitive
- Blue—Repetitive tile (x or y)
- Red—Nested repetitive tile (tileable in x and y)
- Yellow—Rule symmetry (will be linked in the Rule refinement section)
The main facade structure includes an analysis of single splits, repetitive splits, and rule symmetry:
- Click New > CityEngine Scene > to create a new scene and name it MassModel_Advanced.cej.
- Open the Facade Wizard window.
- Click the New Facade from Image button
and browse to the AdvancedFacade.tif file.
- Set the region width to 20.
Create single splits with split types
To allow the facade to increase in size and have the texture repeat, you will add the single and repetitive splits and define splits as absolute or floating. The sequence of splits shown in the image below are intentional to ensure that the split types (absolute and floating) are set vertically.
- Use the X Split and Y Split tools to add single splits (shown as blue lines) to the facade. Immediately after each split, hover over the new region to see the blue highlight. Use the up and down arrow keys to cycle through and assign the split type (shown as yellow dashed and solid lines) for each.
- Use the Shift key to snap new splits on the same axis as previous splits.
- Change the split type as needed by hovering over the regions and pressing the up or down arrow keys again.
- After the absolute and floating split types are set, you can now split the remaining top floor regions:
- Do the same for the ground floor regions as shown below:
Note:
The right vertical upper floor is not split intentionally to be solved later in this tutorial using rule relinking.
Understanding split types
The yellow lines represent the split type. It is important that you define split types correctly as either absolute or floating.
Absolute – The region dimensions are unchangeable, and regions will only scale proportionately to different sized facades. A repeat of the region set to absolute will only generate when the exact dimensions required for a new region to be repeated are satisfied in the direction of the original single split. To ensure proper tiling of the facade, designate components requiring a fixed value when scaled as absolute splits.
- X Splits with an absolute split type are represented with a horizontal solid yellow line on a highlighted region.
- Y Splits with an absolute split type are represented with a vertical solid yellow line on a highlighted region.
Floating- The region dimensions are changeable and scale to fit different sized facades. A repeat of a region set to floating is not contingent on the exact dimensions of the original split. It can stretch and scale to fit the facade in the direction of the original single split. The floating split also corresponds to the tilde symbol (~) in CGA code.
- X Splits with a floating split type are represented with a horizontal dashed yellow line on a highlighted region:
- Y Splits with a floating split type are represented with a vertical dashed yellow line on the highlighted region:
No split type – The region dimensions are a remainder of the original image import dimensions. Rescaling the facade will stretch the texture without any dynamic adjustment in either direction.
- No split type assigned is represented with no lines on the highlighted region:
Repetitive splits
The following splits are repetitive splits that define which parts of the facade are repeated to adapt to any facade size.
- With your single splits and absolute or floating values already assigned in the last section, use the X Repeat tool
to create the following vertical splits.
- Ensure that the upper floor windows will scale vertically to different facade dimensions, the windows assigned a floating split type requires another step:
- Enable the Y Repeat tool
.
- Hover over each of the four windows until you see the beam spanning across the top framed by the red repeat lines as seen below.
- While hovering, click once for each of these window beams.
You will not see a resulting split line, this is expected.
- Enable the Y Repeat tool
- To further detail the geometry, split each of the blue regions into unique components. As you progress, these splits will automatically be repeated in the red areas. See the following detailed images to help guide your split sequence.
A special case is the ground floor, where there is an arc. Split this exactly at the sides of the arc, so you can insert an asset in the next part of this tutorial.
- Hover over those areas to see how the repeated windows have updated.
Set the region width
Next, you will redefine the total facade size by defining the width of one window. At the beginning of this part of the tutorial, you defined the full facade size in the Set Region Width pop-up. But since you are not sure if this value was correct and are more familiar with sizes of windows than complete facades, you will set a new value.
- Right-click the window split and choose Set Region Width.
- Enter an appropriate size, such as 1.2 meters.
- Use the Z Adjust tool to edit the depth values to give the facade a volumetric appearance. Push windows back a little and ledges forward. You can also move forward the triangular and trapezoid ornamental decor.
- Click the Save Rules and Textures for Current Facade button
to create your rule file.
It is recommended that you create a second copy with a unique name in case you want to revert your facade generated CGA rule file to this stage later.
Note:
A right-click in the Facade Wizard window allows you to enable the Immediate Save and Generate for Selected Shapes. If this is enabled, you will not get the save rule file window to select and change file names and create copies from within the Facade Wizard.
Refine rules
You may ask now how you should proceed with this rule? Since a rule file from the Facade Wizard is constructed for facades, you can only assign it to vertical surfaces. So you will create a simple mass model rule on which you can test it.
- In the Navigator window, right-click on the rules folder in the tutorial project and click New > CGA Rule file.
- Name this new rule MassModel.cga and expand the CGA Editor window.
- Create an attribute, name it buildingHeight, and give it a value of 25.
- To import the facade template file (gen_Facade_AdvancedFacade.cga) you just created, right-click in the CGA Editor window, choose Add Import from the context menu and browse to find it. Alternatively, drag the CGA file from the Navigator window into the CGA Editor window to see the same result.
- Create a rule named Lot with an extrude command. Use the previously generated buildingHeight attribute for the extrusion value.
- After the extrusion, add a component split that splits off all side faces.
- Assign the Facade rule of the facade template file you imported. In your sample, this is gen_Facade_AdvancedFacade.Facade. You will get the following mass model rule file:
import gen_Facade_AdvancedFacade: "gen_Facade_AdvancedFacade.cga" attr buildingHeight = 25 Lot--> extrude(buildingHeight) comp(f){ side : gen_Facade_AdvancedFacade.Facade }
- Click File > Save all in the main menu.
- In the Viewport window, use the shape creation tools to create a footprint shape 10 x 20 meters.
- Assign the MassModel.cga rule to that footprint shape and press Ctrl+G to generate the model.
- With the model selected, use the Transform Scale tool
to alter the shape and see the facade change proportionately.
The facade template is used directly, and the rule adapts to the new lot's geometry and the predefined extrusion height of 25 meters.
To see the desired results provided in this tutorial project, open the FacadeWizard_3_Advanced.cej file in your scene folder and the MassModel_Advanced_tutorial_part_1.cga in the rules folder.
Note:
This rule imports the gen_AdvancedFacade_tutorial_part_1.cga rule for your reference.Relink rules
In the following image, you can see those parts (in yellow) that you left without further detailing beforehand. Now, you will use CGA and the Model Hierarchy window to relink the specific subrules from the facade templates to fill in the missing parts in the yellow areas.
- Click Window > Model Hierarchy and select the building model.
- Click Inspect Model on the Model Hierarchy toolbar.
The model turns slightly transparent after you enter the Inspect Model mode.
- Click the shape node you want to replace: the right vertical part of the facade, highlighted in yellow in the previous image. This selects the shape in the Model Hierarchy window.
Note:
Use the set of visualization buttons in the Model Hierarchy window to easily visualize and isolate the facade sections. As you select different components of the model hierarchy tree, the CGA Editor window interactively highlights the coinciding section of the rule that supports each composition.
With this vertical section of the facade selected, right-click in the Model Hierarchy window and choose Collapse Others to simplify the view by collapsing parts of the shape tree that are not selected.
- Select the parent shape node and double-click it.
The Facade template rule responsible for creating this shape node in the CGA Editor window gets highlighted. The selected rule creates three facade parts: left, middle, and right.
- Replace the facade rule on the right with the one from the left. In this case, replace Facade__1_3_3 with Facade__1_3_1.
Original:
Facade__1_3 --> split(x, noAdjust) { 2.68: Facade__1_3_1 | ~10.62: Facade__1_3_2 | 2.66: Facade__1_3_3 }
Modified:
Facade__1_3 --> split(x, noAdjust) { 2.68: Facade__1_3_1 | ~10.62: Facade__1_3_2 | 2.66: Facade__1_3_1 }
The right part of the facade now uses the same rule as the left. The now-unused rule Facade__1_3_3 can be deleted, since it is no longer needed.
Before relinking:
After relinking:
Note:
You may need to refresh your scene or regenerate the model to see the changes.
Now, do the same for the yellow part near the entrance and replace the leftmost tile with the one to the right of the entry – as shown in the image at the beginning of this tutorial section. The result should show shorter windows on the right side of the upper floors and an arched window without an awning on the left side of the ground floor.
The final model appears after generating it again:
To see the desired results provided by this tutorial project folder, open the FacadeWizard_4_Advanced.cej file in your scene folder and the MassModel_Advanced_tutorial_part_2.cga in the rules folder. Note that this rule imports the gen_AdvancedFacade_tutorial_part_2.cga rule for your reference.
LODs and asset insertion
You've now covered the basic creation of facade templates in the Facade Wizard window. You will now explore how you can use CGA and the Model Hierarchy window to enhance the quality of the default Facade Wizard rules.
This last part of the Facade Wizard tutorial discusses the following two topics:
- Levels of detail (LOD)
- Inserting assets in facade templates
Levels of detail
Since the creation of 3D cities can generate very large datasets, which often require careful management of resources, advanced users may sometimes choose to create different models of the same building with varying levels of complexity.
For example, if a building is directly in front of the camera, all the details should be visible, while a building that is far away from the camera (or may not be visible) should have as few details as possible but still be recognizable in its basic form. The process of creating different models of the same object and using them according to the distance to the camera is widely known in the field of computer graphics as creating levels of detail (LOD).
The rule files created by the Facade Wizard show that there is already a default LOD system implemented. The top of the CGA file (seen in the CGA Editor window) contains an explanation of the default values.
Note:
CityEngine can create different LODs but does not have a system implemented for direct camera-proximity-based switching of the models.attr LOD = 2
# LOD 0 generates the original texture
# LOD 1 generates flat splits
# LOD 2 generates splits with depth as defined in Facade Wizard
The following image shows the application of all three predefined LODs, shown on the base of the rule that was created in the previous part of this tutorial. Note that the difference between LODs 1 and 2 is small but significant: LOD 1 generates only a plane that is split up and ignores all Z Adjust edits, while LOD 2 generates the volumetric representation with textured cubic objects, incorporating the Z Adjust edits.
To create LOD 3 you will need to insert some additional assets to add the necessary detail as seen below:
These LODs look very similar but, when you zoom in, the differences in detail are clear. This is important to consider based on how the model will be experienced. The following examples demonstrate this:
Low LOD (0)
2D facade representation with image scaling to provide a simplistic representation:
Med – Low LOD (1)
2D facade representation with splits:
Med LOD (2)
Punctuating general facade components to provide a sense of depth:
High LOD (3)
Detailing of specific facade components providing a sense of depth and architectural style:
Tip:
If a Facade Wizard rule template is imported in other CGA rules (for example, as done in the MassModel.cga file from the last part of the tutorial), the LOD attribute must also be initialized in the primary CGA file --> attr LOD = 2.
To create LOD 3, the goal is to use a combination of shape highlighting in the model hierarchy, code highlighting in CGA, and the insertion of custom-made assets.
Edit assets
First, edit your MassModel.cga file.
- Add an LOD attribute and set the value to 3.
attr LOD = 3 attr buildingHeight = 25 import gen_Facade_AdvancedFacade:"gen_Facade_AdvancedFacade.cga" Lot--> extrude(buildingHeight) comp(f) { side : gen_Facade_AdvancedFacade.Facade }
After studying the facade's ornaments, you can introduce the following assets:
- tympanon.obj
- triangularPediment.obj
- squarePediment.obj
- entryArc.obj
- Starting with the triangular pediment asset, open the gen_Facade_AdvancedFacade.cga rule in the CGA Editor window.
- Add a new rule for the triangular pediment asset at the bottom.
insertTriangularPedimentAsset --> case LOD ==3 : Shape t(0, 0, '1) s('1, '1, 0.25) i("triangularPediment.obj") projectUV(0) Asset else : Shape
For LOD 3, load the obj asset; t() and s() place and scale the asset correctly; projectUV() will overlay the facade texture on the asset.
- Add similar rules for the other three assets.
insertSquarePedimentAsset --> case LOD ==3 : Shape t(0, 0, '1) s('1, '1, 0.25) i("squarePediment.obj") projectUV(0) Asset else : Shape insertArcEntryAsset --> case LOD ==3 : t(0, 0, -0.35) s('1, '1, 0.5) i("entryArc.obj") projectUV(0) Asset else : Shape addTympanonAsset --> case LOD ==3 : t(0, 0, '1) i("tympanon.obj") projectUV(0) Asset else : Shape
Note:
The entryArc.obj and tympanon.obj assets replace the geometry of the existing shape, while the triangularPediment.obj and squarePediment.obj assets are placed on top of the existing shapes. The main code difference in the rules is the first shape in the rules.
Insert assets
Now you will find the correct terminal shapes from which you can link to the new rules and insert the assets, as shown in the image below.
- Select the building and go to Inspect Model mode.
- Select the shape where the asset is to be inserted.
- In Model Hierarchy window, double-click the selected shape.
The facade template rule responsible for creating this shape node in the CGA Editor window is highlighted.
Facade__1_3_1_2_2_2 --> case LOD <= 1: setupProjection(0, scope.xy, '8.0953, '19.2869, '-0.1945, '-11.3296) projectUV(0) else: setupProjection(0, scope.xy, '8.0953, '19.2869, '-0.1945, '-11.3296) t(0, 0, -0.2) s('1, '1, 0.2) i("builtin:cube") projectUV(0) insertTriangularPedimentAsset
The facade appears as follows before asset insertion:
- In the second case, at the end of the existing rule, add the insertTriangularPedimentAsset rule to trigger asset insertion.
The facade appears as follows after asset insertion:
- Repeat the steps to insert this asset at other positions in the facade, and for the other assets to create LOD 3.
Remove roof elements
The last step is to remove the outer elements on the roof.
- Use the Inspect Model mode to find the rule and replace the outer split parts with NIL.
Facade__1_5 --> split(x, noAdjust) { 2.68: NIL | ~10.62: Facade__1_5_2 | 2.66: NIL }
- Delete the unused Facade__1_5_1 and Facade__1_5_3 rules.
After you have linked all necessary rules, update the LOD attribute in the inspector and try all different LOD’s that you have created using the Facade Wizard. For LOD 3 the generated facade will look like this:
The poly counts in this example (facades only):
- LOD 0 = 4
- LOD 1 = 1288
- LOD 2 = 6616
- LOD 3 = 9654
To view the desired results provided by this tutorial project folder, open the FacadeWizard_5_Advanced.cej file in your scene folder and the MassModel_Advanced_tutorial_part_3.cga in the rules folder. Note that this rule imports the gen_AdvancedFacade_tutorial_part_3.cga rule for your reference.
You’ve now created a facade rule that you can assign, alter the level of detail and dynamically scale for various 3D building templates.
When working with 2D facades, you may also consider exploring the image cropping and resizing capabilities of the Crop Image tool.