While setting up func_godot I found the documentation very overwhelming as a beginner - everything you need is there, but it’s not laid out in a step by step easy to follow process.

The following is a personal guide that I made if I ever have to set up a project again.

Table of Contents

Required files

The following resources are required:

yay -Syyu godot trenchbroom-bin

Getting Started

Setting up Godot

Before setting up TrenchBroom you must first set up the plugin - since it will generate files required for TrenchBroom.

  1. Create a new Godot project and copy the addons folder from your Func Godot release into the project root
  2. Navigate to “Project” > “Project Settings” > “Plugins” and enable the plugin
  3. Create the folders trenchbroom & trenchbroom/textures in your project root
  4. Open res://addons/func_godot/func_godot_local_config.tres and set the following fields:
    • Fgd Output Folder: This is where the custom TrenchBroom game definition will live. Set the value to something like this:
      • /home/user/.TrenchBroom/games/demo where “user” is your username and “demo” is the name of your project.
    • TrenchBroom Game Config Folder: This should be exactly the same as “Fgd Output Folder”
    • Map Editor Game Path: Set this path to the “TrenchBroom” folder in your Godot Project:
      • /home/user/Developer/demo-godot/trenchbroom
  5. Click “Export Func Godot Settings” - It looks like a toggle, but it’s actually a button.

  1. Right-click the trenchbroom folder in your project root and “Create New” > “Resource”
  2. Create a new FuncGodotFGDFile and save it in the trenchbroom folder as “primary_fgd.tres”
  3. Set the “Base FGD File” value to res://addons/func_godot/fgd/func_godot_fgd.tres

  1. Open res://addons/func_godot/func_godot_default_map_settings.tres and set the following:
    • Entity Fgd: Set this to the FGD we created earlier
      • i.e. res://trenchbroom/primary_fgd.tres
    • Base Texture Dir: Set this to your map texture directory.
      • i.e. res://trenchbroom/textures to keep map textures separate to game textures

  1. Next open res://addons/func_godot/game_config/trenchbroom/func_godot_tb_game_config.tres and set the following:
    • Game Name: The folder name you wrote in “Fgd Output Folder”
      • i.e. Demo
  2. Click “Export File”

Configuring TrenchBroom

  1. Open TrenchBroom and click “New map…”
  2. Click “Open preferences…”
  3. Your games name should be listed in the games list - select it
  4. Set the game path to the res://trenchbroom/ folder in your Godot project root
    • i.e. /home/user/Developer/demo/trenchbroom
  5. Click “Apply” the “Ok”
  6. Select your game from the right hand list then click “Ok”
  7. Save the newly created map to your Godot project
    • i.e. /home/user/Developer/demo/maps/

Compiling the map in Godot

  1. Back in Godot create a new 3D scene and save it
    • i.e. res://scenes/main.tscn
  2. Add a FuncGodotMap node to this scene
  3. Set the “Local Map File” to the map you just saved
    • i.e. res://maps/
  4. Click Build in the toolbar - You should see the default TrenchBroom cube as a mesh in Godot

Adding Textures

I use a site like AmbientCG for quick textures - I’ll be using this brick texture in 4K as an example

  1. Copy your texture jpg into res://trenchbroom/textures
    • If your texture comes with normals, ao, roughness, displacements etc do the following:
      1. Create a folder with the same name as the root texture
        • res://trenchbroom/textures/bricks
      2. Copy the files into this folder with the following naming convention:
        • bricks_ao.jpg - Ambient occlusion
        • bricks_roughness.jpg - Roughness
        • bricks_displacement.jpg - Displacement
        • bricks_normal.jpg - Normal maps
  2. In Godot select all your imported textures in the file browser
  3. Click “Import” at the top & ensure “mode” is “VRAM uncompressed”
  4. Click “Re-import”

  1. Inside TrenchBroom press F5 or “File” > “Reload Texture Collections”
  2. You should now be able to apply the texture to brushes in TrenchBroom
    • With 4k textures - I usually set the scale to 0.05

  1. Back in Godot - Select your FuncGodotMap node and click “Build” & “Unwrap UV2”. You should now see your texture applied.
    • You can confirm all your materials applied correctly by checking the generated .tres file in your textures folder
      • i.e .res://trenchbroom/textures/bricks.tres

Custom Entities

Jumping over into a different project (configured the same way), you may want to place entities such as lights, enemies, the player, etc. in your map via TrenchBroom. This can be quite complex however I have figured out the following

Placing Scenes via TrenchBroom

  1. Create the folder res://TrenchBroom/entities
  2. Right-click and “Create New” > “Resource”
  3. Create a FuncGodotFGDPointClass and name it after your entity
  4. Set the following values:
    • Scene
      • Scene File: The scene you want to create
        • i.e. character.tscn
    • Entity Definition
      • Class Name: The name of the entity in TrenchBroom
      • Description: The description of the entity in TrenchBroom
      • Meta Properties: The size and colour of the entity in TrenchBroom

  1. Open res://TrenchBroom/primary_fgd.tres
  2. Under “Entity Definitions” add your new .tres file
  3. Click “Export File”
  4. In TrenchBroom, ensure the entities mod is enabled in the “Map” tab and press F6 or “File” > “Reload Entity Definitions” to reload entities

  1. Back in Godot re-build your map and your entity should be present

Placing nodes via TrenchBroom

Placing nodes like lights via TrenchBroom is a bit more complicated (I havent figured it out). But it’s 100% possible & I’ve seen it done in the Discord. Once I have done it myself I will document the process here.

There are examples in this GitHub Repo which seem to work.

© 2024 Pfych 🏳️‍⚧️