-
Notifications
You must be signed in to change notification settings - Fork 5
Creating new regions
This article will demonstrate how to create a mod expanding the world of Phantom Brigade. It'll cover the recommended workflow for creating the 3D landscape, configuring the landscape in the SDK, extending the province database to place your landscape in the world and setting up a mod utilizing the AssetBundle system to sideload your assets. Make sure to read the Creating asset mods article before proceeding.
You will need the following software installed to follow along:

Before we get to setting up the mod, we need to learn the parts that regions (provinces) in PB are built from. Let's start with the visual assets and go over the data (configs) later. As covered in Creating asset mods, the assets will be located in the Assets/User/ folder. The highest level asset is a Prefab with a special component called OverworldLandscapeRoot:

The OverworldLandscapeRoot component provides a number of references to the landscape system. They include the main terrain mesh (3D model of the playable area), the skirt mesh (3D model of the background area extending to horizon), textures (albedo, normal, splat map) and some optional values. With the data from this component, the landscape system can display the terrain to players at runtime.
Let's take a closer look at the two 3D models:

Finally, let's take a look at the textures. The main textures used by majority of landscapes are:

- Main texture (usually named
tex_color_out):- Usually an 8-bit RBGA PNG with 2048x2024px resolution
- Unity import settings:
Defaulttype,sRGBon - RGB stores albedo color
- A stores the water mask
- Splat texture (usually named
tex_splat_out):- Usually an 8-bit RBG PNG with 1024x1024px resolution
- Unity import settings:
Defaulttype,sRGBoff - R stores mask of flat areas
- G stores mask of slopes
- B stores mask of smooth areas like snow
- Optional normal texture (usually named
tex_detail_normal):- Usually an 8-bit RBG PNG with 2048x2048px resolution
- Unity import settings:
Normal maptype - RGB stores a tangent normal map
Now that we know what assets we need (meshes and textures), we can look into ways to make them using external software like Gaea 2. Once we're done with the assets, we'll return to the SDK to continue setting up the landscape.

The assets for the terrains can be created in any 3D software such as Blender, but we recommend using Gaea 2: it is the software that was used for built-in terrains in Phantom Brigade and it produces highly realistic results with minimal setup. The free version is limited to 1024x1024px exports, but it should be sufficient modding purposes. You can download Gaea 2 here.
This tutorial will cover the specifics of using Gaea 2 to generate terrains for Phantom Brigade. We recommend getting familiar with the fundamentals of Gaea 2 (like camera navigation, general UI, basics of node use) before continuing this tutorial. Check out the Learning portal on their official website, look up quick start tutorials on YouTube (such as this one). You can also check official templates installed with Gaea 2 for inspiration.
Let's go over setting up a Gaea 2 project file. There's a number of details that we need to get right to get the exports in the right place and to get the results matching built-in terrains. Start by selecting File > New option and choose a folder for your project. Make sure to set up the project within the SDK folder, under Assets/Users/. For example, create Assets/Users/mod_landscape_02, like so:

Choose a filename matching the folder name:

With the project created and open, go to the project build settings (Project > Build Settings) and change Build destination to <FileLocation>\Build\. Make sure File overwrite mode is set to Overwrite:

Next, go to the Terrain tab of project settings, set Width to 16834 and set Height to 2048:

Finally, check the terrain resolution on top of the main window. If you're using the free version, set it to 1024x1024, otherwise set it to 2048x2048.

With the initial setup done, let's create a very minimal node graph. Our goal here is to learn what it takes to generate all the necessary assets, so we'll keep the node graph simple and focus on its outputs, not on producing a particularly complex terrain. You can always extend the graph later to give it a more intricate shape and texture.
Quick reminder: you can select a node and press
Fto force Gaea to render it in the viewport. If you can't see the output of a given node, make sure you're not focusing another node, select the one you want to see and pressF. You can exit focus mode by pressingFagain.
To start, create a simple Mountain node. Click the Autolevel button at the bottom to make the mountain span 100% of height range of the terrain. Set its scale to 0.25 to leave some flat ground for players to drive on. Then, add another node called Rugged: it will be a layer that adds visual interest to the flat area around the mountain. The graph should look like this:

Next, let's combine both features we made into one terrain. Create a Combine node and connect Mountain and Rugged to it. This is a very common operation and you can speed it up by simply dragging from one Out port to another Out port. To keep things simple, keep Ratio at 0.50, keep blend mode at Blend and just add Autolevel at the bottom to keep the terrain tall. If you're interested in more precise mixing, try Hypotenuse and other blend modes later on:

Next, let's add an EasyErosion node and connect the Combine output port to it. Our goal here is to go through each common node type, so particular settings do not matter, but Simple mode on EasyErosion is a quick way to get an appealing eroded terrain. If you're interested in fine tuning erosion, consider Erosion2 node. The graph should look like this once you're done:

Next, let's add a Rivers node to the chain. Rivers are a great way to break up the landscapes: water catching the light makes the terrain much more believable and stops it from looking like a matte plastic model. The specific settings do not matter for now:

Next, we need to set up portals. As the graph grows, you will have a large number of places that need the height of the terrain or depth of the water as inputs. You can keep dragging connection lines between outputs and inputs, but the graph can quickly start looking like spaghetti and will become harder to read. The portals are essentially variables. You can turn any output port into a named variable and make any input port read that variable, resulting in a much neater graph.
To start, create Adjust nodes (shortcut fx) connected to the Out node and Depth outputs of the Rivers node (toggle Autolevel on the Adjust node connected to Depth to make it a useful 0-1 mask for water). Once these Adjust nodes are created, select them, press F2 to rename them and name them Height and RiverDepth respectively. The variable names are based on the name of the node they start at, so naming them is an important step. Once the names are set up, select each node, press P to enter portal menu and press Convert to Portal > Out to turn the output node into a portal (variable):

If everything was done right, you should see this in your graph, with Out ports of both nodes lit up to indicate they've been turned into portals:

Next, let's move onto texturing this landscape. To start, create a TextureBase node. It provides a foundation for painting that other color nodes can rely on. To make the node work, you'll need to give it terrain height as an input. Select the node, press P, choose Connect to Portal > In and you're done:

Next, create a SatMap node linking to the TextureBase node. SatMaps are a powerful way to color your terrain: they use a lookup table that can turn a grayscale mask into color resembling real-world satellite images. Focus the SatMaps node with F and play with the different options until you find the right look. You can also adjust settings in the TextureBase if you'd like to adjust with how how much influence different features like erosion flows or ridges have on the color.

The next step is blending your colors. Let's keep it simple and simply blend your SatMap based color with a fixed color for the rivers. Create a Mixer node: this is a powerful tool for compositing different colors, similar to layer menu in Photoshop. Connect the In input port to your SatMap (this is similar setting the Background layer in Photoshop). Press P and connect the Terrain input port to the Height portal variable you created earlier.
The mixer starts with a single layer as an example. Select that layer in the mixer inspector. Set its masking mode to None (not Height or Slope). In the graph, create a Constant node, set it to Color mode and give it a dark blue color. Connect that Constant to Layer 1 input port on the mixer. Finally, select the mixer, press P and connect the Layer 1 Mask input port to the RiverDepth portal variable you've created earlier. You should get a result that looks like this, with rivers overlaid on top of your original colors.

You can keep creating more TextureBase + SatMap nodes and can keep adding layers to the mixer to create very complex looks. The mixer allows you to quickly mask layers by slope and height, so it's easy to set up differently colored cliff faces, greenery in the low lying areas, snow capped peaks etc. But we'll move on to the last type of texture treatment for now: adding ambient occlusion.
Create an AO node. Use the P to give it Height portal variable as input. Create a Combine done and combine the output port of the mixer with the output port of the AO node. Set Combine node mode to Multiply. You should end up with something like this:

With base color, water color and shadows in place, you have a very respectable looking terrain that can be expanded into a much more complex graph later on. For now, we need to move on to setting up export nodes. The graph you should end up with by this point would look like this:

We're in the final stretch now. All that's left is to export the landscape we have in Gaea 2 into usable files.
Let's start with the main texture. We need to export an image with terrain color in the RGB channels and water mask in the A channel. To do that, simply connect your last Combine node to a new RGBSplit node (splitting your color from RGB into R+G+B). Next, add a Splat node to the chain and connect R+G+B outputs to it. The Splat node lets you construct 4-channel RGBA images, and all that's left is to fill the last channel: press P, select Connect to Portal > In 4 (input alpha) and choose RiverDepth as the connected portal variable. Connect a new Adjust node to the output of Splat and name it tex_color. Press F3 while selecting it to mark it for export: you should see a yellow save icon appear in the corner. If everything is set up right, your graph should look like this:

Next, let's set up the mask for detail texturing. As mentioned higher up, we need to put flat areas into R, slopes into G and smooth areas like snow into B. Let's skip the third channel and keep things simple for now. Create a new Slope node (which outputs a mask for a given range of angles) and use ``Connect to Portal > InwithHeight` variable we created earlier. Configure the `Slope` node to something like 0-8 degree range, with falloff around 15 degrees, creating a map of relatively flat areas, like on the image below:

Next, create an RGBMerge node to set up a three channel image. Plug the output of Slope into R. Create a new Adjust node, toggle Invert on it and connect the result to G. Finally, create a Constant node with a value of 0 - we don't have any snow or sand, so that mask can stay empty for now. Plug the result into a new Adjust node, name it tex_splat and press F3 to mark it for export:

Finally, lets tackle exporting the mesh and a detail normal map. Gaea 2 provides nodes to generate both, but it's important to get their settings right so that the terrain looks right within Phantom Brigade. Start by creating a Mesher node, rename it to mesh and press F3 to mark it for export. Configure the following values in it:
- Format:
OBJ - Scale:
Normalized - Topology:
Tris - Vertices per side:
256 - Artifact reduction:
None - Create normals:
On - Create UVs:
On - UV origin:
Bottom Left - Create walls:
Off - Center pivot:
On

Next, create a TextureBaker node and connect it to the Out port of the mesh node. Set Generate normals to On. Rename the node tex_detail and press F3 to mark it for export.

Open the Build tab in the bottom right corner of the graph. You should see 4 nodes marked for export alongside their names and formats. Make sure every export is set to PNG16 format. If you did everything correctly, you should see something like this and you are ready to export your terrain!

With the graph complete, you can start the export. Press the green Build button on top of the Build tab and confirm you'd like to start the export process. This will open a new command line window and might take a few minutes depending on your hardware. Sticking to 1024x1024px export resolution can massively speed up export, so it might be a good idea to try that resolution first.

If everything works well, you should see the exported files under Assets/User/[landscape name]/Build. It's almost time to return to Unity!

The 3D model of the playable area generated by Gaea needs to be optimized, and we need a second 3D model of a background extending to the horizon. Both of these steps can be completed in minutes using the Blender script we include in the SDK. First, launch Blender and open the scene located in Tools/Art/terrain_processor_v1.blend:

Press the Run button (►) in the Text Editor window at the bottom of the screen. You should see a tool panel open up in the top right corner of the viewport. Select the mesh.obj exported by Gaea by into the Build folder by clicking the folder icon next to the path field. Then click Export:

If everything was done correctly, you should see two new FBX files in the Build folder:


Time to finally return to the SDK! Launch the SDK project. If it was opened all this time, press Ctrl+R to make it scan the User folder for new assets. You should see all the textures and 3D models we created through the Project tab:

Select each of the assets you created one by one, and change their import settings to be sure everything is set up correctly:
- Main texture (
tex_color_out.png):Defaulttype,sRGBon - Splat texture (
tex_splat_out.png):Defaulttype,sRGBoff - Normal texture (
tex_detail_normal.png):Normal maptype - Main model (
terrain.fbx):Read/write enabledon - Skirt model (
terrain_skirt.fbx):Read/write enabledon - Make sure to click
Applyin the bottom right corner of the Inspector for each asset after changing their import settings
Next, create a Prefab in the root folder of your terrain, above Builds. Create an empty GameObject in the scene, add the OverworldLandscapeRoot component to it and drag it into the root folder for your terrain in Project view.
Keep the prefab selected in Project view (not scene view) and drag the 3 textures and two models into the reference slots on the OverworldLandscapeRoot component. You can click the small lock icon in the top right corner of the Inspector to lock its selection. Press Ctrl+S and File > Save Project to save your changes. You should end up with references looking like this:

Once all references are set up, it's time for the moment of truth. Enter a unique key into the Key field on the prefab (mod_landscape_02) in case of this tutorial and click Inject to Landscape Manager. If everything was set up correctly, you should finally see your terrain in the Unity Scene view!

With the assets finally working and with the SDK now aware of your new landscape model, you can move to creating the configs for your new province. It's time to create a new mod. If you aren't sure how to make a mod project or modify configs, check the following tutorials first:
Click Setup config editing to copy the Configs folder from the SDK into your mod project and unlock access to database editors. Start by navigating to DataModel/Collections/Overworld/ProvinceLandscapes, enable Filter in the Inspector and enter a key for an existing landscape. We recommend t4_plains as a starting point. Once you see it in search results, click Duplicate:

Enter a new name in the editable field on top of the t4_plains_00 (the duplicate you created). The new name should match your asset, so it should read mod_landscape_02 in our case. Click Rename to confirm.

Filter for mod_landscape_02 on top of the inspector, open the mod_landscape_02 in the search results. Set Asset key on top of the config to mod_landscape_02 (if it's not in the dropdown, paste it via right click menu and make sure you clicked Inject to Landscape Manager in the previous step.

Click Save data on top of the database inspector, then click Select on top of your config. The button will switch to Deselect and you should see your landscape in the Scene view: but this time, with a lot of visual indicators overlaid on top. If you don't see any indicators, make sure that Gizmos button in the top right corner of Scene view is on:

Next, click Generate gen. points. This will create general purpose spawn points that the game can use to spawn missions, patrols and events. Play with Spawn normal intensity setting to restrict spawns on slopes (we recommend value of 0.95 or 0.97) and Spawn height settings to restrict how high and low points can appear. Watch for Scene view every time you click Generate to see how the settings get applied:

Finally, it's time to adjust the special spawn points. There are 4 main types, which should already be present on the config since you duplicated an existing landscape. Simply select them in the inspector or click the colored circles in Scene view. The points will conform to landscape as you move them around, so if any points date back from an original duplicated terrain, make sure to at least wiggle each one around a bit (to avoid any points underground).
-
borderare arrival points, should be placed near the edge of playable area -
border_exitis the exit point, should be placed relatively close to centermidpoint` is the boss spawn, should be placed relatively close to center -
poiare spawns for question mark events, could be placed in scenic (but flat and accessible) locations out of the way of the payer

With all the points in place, you are pretty much done with the landscape config! The last remaining piece is creating a province config. The landscape config defines the physical content of a province (model, spawn points, etc.) while a province config defines higher level information: where the province is on the world map, what tags affecting its campaign placement does it have, what is its name and description, etc.
Duplicate and existing province config from region 1, e.g. province_g1_01. Rename it to province_g1_mod_02 or something else matching your previous configs. Verify the tags look correct, adjust the Map Position (the inspector will visualize the position you choose on the world map), enter the description and name. Make sure to click Save data and Save text

We assume you've already completed the Creating asset mods tutorial. Simply edit the mod definition to use an Asset Bundle, name it with any name (like my_mod_landscapes), and reference the top level Prefab assets you made in the Files section of the bundle definition.
Important note: Phantom Brigade 2.0 might not successfully load Asset Bundles with landscapes. Please update to 2.1 or use the playtest build to complete this step.
And with that, you're completely done! You can export the mod and give it a go in the game. The game will scan all loaded Asset Bundles on startup and will automatically register any Prefabs with the OverworldLandscapeRoot component into the landscape system (under the key you fill into the Key field on each prefab). The landscape and province configs are sideloaded using the standard Config Overrides system - the SDK should just detect new and modified files and include those configs into the exported mod. Likewise, all of the text you enter in the province DB should end up in LocalizationEdits export folder.
Integrating a province into region one (g1) makes the province easy to test, since you can immediately see it on the world map and quickly reach it from Quick Start. You can use the ow.combat-skip-with-prog-increase console command to quickly skip combat. You can also use ow.load-landscape console command to force load any landscape (not a province, just the landscape).

We can't wait to see what worlds you create!
This wiki is a work in progress. Please make sure to check the built-in tutorials within the SDK or the modding articles on the game wiki to supplement this page. If you get stuck or experience a bug, please don't hesitate to ask questions in the #phantom-modding channel of the official Discord server. We can't wait to see what you create!