Tutorial 19: VFX workflows with Alembic

To access the tutorials in CityEngine, click Help > Download Tutorials and Examples. After choosing a tutorial or example, the project is automatically downloaded and added to your workspace.

Introduction

This tutorial demonstrates a number of VFX-related workflows based on the Alembic exporter. Three examples are provided: Houdini with Mantra, Maya with VRay, and Katana with RenderMan as downstream tools to process and render your Alembic city model. To complete this tutorial in full, you are required to install SideFX Houdini (Apprentice or higher), Autodesk Maya (2018) with VRay, The Foundry Katana (3.x), and Pixar RenderMan 22 for Katana. You can also skip parts if one of these tools is not available.

Note:

These workflow tutorials are just one way of transferring models into DCC tools. Consider adapting these examples to suit your custom pipeline. There is no guarantee that these examples contain the most efficient workflows for your specific pipeline.

Export from CityEngine to Houdini

In this section, you will export a single building as Alembic and map its material parameters to the Houdini Mantra renderer.

Export from CityEngine

  1. Open vfx_workflows.cej, save it as vfx_workflows_part1.cej, and generate the default models with CityEngine.
  2. Click the Skyline camera bookmark.
    Skyline
  3. Open the Waterfront camera bookmark to go to the tutorial building with the green tone.
    Waterfront
  4. Ramp up the level of detail to make it more compelling by setting the Level_of_Detail attribute to High in the Inspector.
    Waterfront with detail
  5. Click File > Export Models > Alembic to export the model to Alembic (use the default settings); for example, export the file to part1_waterfront_building.abc. You are exporting only a single building at this point to demonstrate how the whole pipeline works.

    Choose format for model export window
    Alembic settings
    Note:

    The CityEngine Alembic exporter will attach the material properties to the Alembic <polymesh>/.userProperties compound property node. For details about the layout of the Alembic node tree, refer to the diagram in Export ABC (Alembic).

Import to Houdini

  1. Start Houdini and open the prepared Houdini scene in the tutorial project subdirectory, workflows/cityengine_alembic_workflow_v1.hipnc.
  2. Select the abc subnode inside the AbcCityEngine node and browse to the part1_waterfront_building.abc file.
    abc subnode in Houdini
    Alembic file in Houdini
  3. In the Houdini viewport, press F to focus on the building model.

    Its bounding box representation appears.

    Focus model in Houdini
    Note:

    Houdini shows a bounding box for all Alembic leaf meshes. It does not yet show representations of intermediate Alembic nodes.

  4. In the abc parameter inspector, switch the Display As field between Full Geometry and Bounding Box.
    Full geometry
    Note:

    The Houdini scene is not set up to assign material attributes to the preview in the Houdini OpenGL viewport. This could be done similarly to the Mantra materials in step 7 below.

  5. In Render View, set the camera to Scene View 1 and click Render.
    Render view

    Next you'll take a detailed look at the material assignment.

  6. Select the abc node, go to the Geometry Spreadsheet tab, and filter for primitives in the primitive mode.

    Houdini displays the CityEngine material attributes in a JSON structure in the abc_userProperties column.

    Geometry Spreadsheet
  7. Keep the Geometry Spreadsheet tab open and select the abcJSON node.

    It contains a bit of Python code to separate the JSON block into individual primitive attributes.

    Geometry spreadsheet JSON

    Finally, the ce_to_mantra nodes use the Houdini material override feature to override the base material settings with primitive attributes. You can customize this and map more of the CityEngine material properties to Mantra materials.

Work with instances in Houdini

Complete the following steps to learn instancing and postexport editing of a scene in Houdini.

  1. In CityEngine, open vfx_workflows.cej again and save it as vfx_workflows_part2.cej.
  2. Click the Parthenon Gardens camera bookmark and turn off the terrain layer visibility.
    Parthenon Gardens

    Notice how the same tree models and also the temple parts (for example, the columns) are reused a number of times.

  3. Using the top view, select the temple and a few trees around it and export the file to part2_parthenon_gardens.abc.
    Parthenon Gardens top view
  4. In Houdini, save a copy of the Houdini tutorial scene and load the part2_parthenon_gardens.abc file.
  5. Select the Alembic node, and press F to focus the camera on the new content.

    You see the bounding box representation of the exported scene.

    Parthenon with bounding box

    You can see how each asset instance is visible as an individual bounding box and how the Alembic exporter preserved the instance information of the trees. This allows you to do basic editing on each instance.

  6. If you do not like the tree blocking the view of the temple in the camera setup, adjust the camera, move the render tab into its own window, and start the render. See the full image.
    Parthenon with trees
  7. Set up a split viewport with a top view to select the trees you want to remove.
    Select trees
  8. Move the trees out of the way. See the full image.
    Parthenon with trees removed

Import into Maya and render with VRay

This section demonstrates how to populate the materials of a VRayProxy at render time from the source Alembic file using a VRay posttranslation Python script.

Beta:

This part is still in beta as there is an unsolved problem regarding texture coordinates.

  1. Open vfx_workflows.cej and save it as vfx_workflows_part3.cej.
  2. To export a section of the waterfront to Alembic, use the Waterfront camera bookmark.

    Alternatively, you can also use the provided Maya scene and set the path to the Alembic file in the "mesh" VRay proxy node. Adjust the path in the post-translation script in any case.

  3. In Maya, to import the Alembic file as VRayProxy, click Create > VRay > Import proxy.
  4. In the outliner, select the new mesh object and press F to focus it.

    You will see an approximated version of the final model. VRay randomly removes triangles until it meets its preview triangle limit.

    Maya import Alembic model
  5. Check the Use full names option in the attribute editor for mesh_vraymesh.
    Maya use full names
  6. Copy and paste the Python snippet in Tutorial_19_VFX_Workflows/workflows/maya_vray/vray_post_translate_py_snippet.txt into the VRay render settings Post Translation Python Script field. Make sure to adapt the path to the location of the Tutorial 19: VFX Alembic workflow CityEngine project.
    Maya posttranslation
  7. Click render (with VRay).

    The following image shows the final render of the whole scene. See the full image.

    Maya VRay full scene

Control level of detail with Katana and RenderMan

This part of the tutorial requires an installation of Katana 3.x and RenderMan for Katana 22 or later.

CityEngine: Control level of detail with an attribute layer

In this tutorial section, you will create a high-quality rendering of the Skyline camera bookmark view in RenderMan for Katana.

  1. In CityEngine, open vfx_workflows.cej again and save it as vfx_workflows_part4.cej.
  2. Select the Skyline camera bookmark and maximize the viewport by pressing Spacebar.

    Assuming a wide-angle screen, your result will be similar to the image below.

    Skyline

    The CGA rules used in this tutorial are inherited from the Example NYC2259 2015.0 and contain a level of detail (LOD) switch; in other words, there is more detail contained in the rules than generated by default.

  3. Optionally, select a few shapes in the foreground and set the level-of-detail attribute to High.

    level-of-detail - Lowlevel-of-detail - High
    Low LODHigh LOD

    Instead of exporting all models with a high LOD, you can control the level-of-detail attribute with a map.

  4. In the scene editor, go to the Maps layer group and change the visibility of the Level of Detail layer. Zoom out to see the LOD more clearly.
    LOD map

    The gray level controls the level-of-detail attribute as follows:

    Brightness levellevel-of-detailPlants representation

    0 .. 0.3

    Low

    Fan

    0.3 .. 0.6

    Medium

    Fan

    0.6 .. 1.0

    High

    Realistic

    The Level of Detail layer contains a mapLODOverride attribute to enable or disable the influence of the map.
  5. Set mapLODOverride to -1.0 to activate the map for all shapes.
  6. To test the LOD map, select all shapes of the New Development layer and click Generate or press Ctrl+G.

    You can see the models in the map in terms of LOD.

    Note:

    The visibility of the Level of Detail layer does not affect its influence on the level-of-detail attribute. You can hide the Level of Detail layer again to see the other layers better.

    Generate LOD map
    Note:

    An important aspect of working with high LODs is not to overuse the Generate button. Generating too much geometry in the viewport will eventually slow CityEngine to a stop. The CityEngine exporter will generate (or regenerate) any selected shapes or models regardless of whether those have already been generated in the viewport. So the recommended workflow is to pregenerate a few selected parts of the model, and then select the required scene objects and export all.

  7. Export all your models to Alembic. Select the layers, click File > Export Models, and save the file as part4_vfx_workflow.abc.

    This will take a couple of minutes to produce an approximately 1 GB Alembic file with approximately 41 Mio polygons.

  8. Run the provided Python script Tutorial_19_VFX_Workflows/scripts/textureConversion.py to convert the exported textures to a RenderMan-compatible texture formats (the script defaults to EXR). Open the script and press F9 to run it.

    It prints its progress in the Python console of CityEngine.

Render the scene in Katana with RenderMan

  1. In Katana, open the example project file Tutorial_19_VFX_Workflows/workflows/katana/ ce_abc_workflow_v2.katana.

    The node graph consists of these main building blocks:

    • Alembic input: The CityEngine_Model is of type Alembic_In_Prman and reads the exported Alembic file. The Store_AbcRoot node is used to remember the Alembic file name in the scene graph.

    Katana with CityEngine model
    • Shading network: Here is a Katana NetworkMaterial node with a RenderMan PxrSurface shader. The shader reads two texture maps ( diffuseMap and opacityMap) and mixes in a diffuse color. Below, you will control these three material attributes with values from the CityEngine Alembic file.
    Katana with shading network
    • The OpScript node OpScript_MapCityEngineMaterialProperites is using a Lua script to connect the Alembic user properties (in other words, CityEngine materials) with the RenderMan shading network attributes.
    Katana with opscript node
  2. Next, set up the Alembic file from the Export to Houdini section above:
    1. In the node graph, select the CityEngine_Model and set abcAsset to the part1_waterfront_building.abc file.
    2. In the scene graph, expand the graph to /root/world/geo/asset/CityEngineRoot and select CityEngineRoot.
    3. In the viewer, click Look through camera > .../camera. Press F.

      You see the bounding box of the CityEngine model (in other words, the top level of the Alembic file).

    4. Press P to render the scene.

      You see the RenderMan output in the monitor.

      Waterfront render
    5. In the scene graph, expand the tree below CityEngineRoot and observe how the individual building components become visible in the viewer.

      This keeps the Katana viewer interactive for heavy scenes.

      Waterfront render expanded

    Now it is time to render the whole scene.

  3. Repeat the previous step with the previously exported part4_lod_control.abc file. Expand the scene graph to only one level below CityEngineRoot.

    After a few minutes' loading time, you see the bounding boxes of the grid level.

    1. In CityEngine, export the heightmap and water layers to part4_terrain.abc, assign it in the node CityEngine_Terrain, and connect the node to the merge node. Optionally, export the temple landmark to Alembic and connect it with the prepared "CityEngine_Landmark" import node.
    2. Repeat step 3 with the previously exported part4_lod_control.abc file. Expand the scene graph to only one level below City/CityEngineRoot.
      You will see the following bounding boxes of the grid level:
      Waterfront render whole scene
  4. Click Render and allow RenderMan to run. See the full image.
    Render whole scene result