Exporting a mesh from Blender to Source 2
This tutorial explains how to export a non-animated prop from Blender to Source 2. While basic knowledge of Blender's tools is helpful, even new users should be able to follow all steps easily. You'll learn how to set up the right scaling for your prop, how to assign materials in a way that's readable for Hammer and what settings to use for exporting.
If you don't have Blender installed on your computer, you can download it from blender.org/download or on Steam for free.
Units setup
Before working on your mesh, ensure Blender’s scene units are set up correctly. To do so, switch to the Scene tab in the Properties menu and choose either the Inches preset or set the length to None.
If you set the length to none, add a cube, which will be 6 Blender Units big. That is equal to 10 Hammer Units. So if you want to make a prop that is almost exactly 64 Hammer Units big, then you have to do a 6:10 ratio, the larger number being the Hammer Unit. So 64 x 3/5 = 38.4. This means that the prop in Blender has to be 38.4 Blender Units big. This could be useful if you would like to make props that are almost a perfect size.
Mesh scale and orientation
We’ll use the default Suzanne monkey head as an example prop for this tutorial. Add it to your scene by pressing Shift+A → Mesh → Monkey. You can check the size by opening the 3D viewport’s right menu by pressing N and taking a look at the dimensions in the Transform category. For this tutorial we’ll scale up Suzanne until the Z size is roughly 6.5 feet or 78 inch/generic units. To do so, press S and move your cursor away from the monkey head to scale it up. Confirm with the left mouse button.
Apply the mesh’s scaling by pressing Ctrl+A → Rotation and Scale. Make a habit of always applying scaling and rotation before exporting a mesh to Hammer.
Your mesh should be facing south in Blender to be aligned properly with Hammer's coordinates, which the monkey head does by default.
Open the 3D viewport’s left menu with T and click Smooth to change Suzanne to smooth shading.
Material setup
Adding two materials
First, switch your renderer to Cycles in Blender’s header. This is not needed to create materials - however, as the Blender Renderer will be discontinued in the future and has been removed from Blender 2.8 you should switch it to Cycles, so you can continue working on old props seamlessly when updating to the new Blender version.
We will create two different materials, a red and a blue one. Navigate to the Material tab in the Properties and click on New to create a new material.
Click on the + icon to create a new empty material slot. Select this slot and press the big new button again to create a second material. Rename the materials to red and blue.
The material name you enter here is not relevant or tied to the material name used by Hammer. But for the sake of consistency it is advised to use the same material name as in the engine.
Material properties
Hammer can’t read the materials unless you add a so called Custom Property to them that points to the correct material name and path used in Hammer.
Select the red material. For this tutorial we’re going to assume that you have created a material called red.vmt in the folder “materials/models/props_items” of your project with Hammer’s material editor. If you didn't, thats fine too. You can create the materials after finishing this tutorial. There's a link in this article's conclusion that will help you to do so.
There’s a Custom Properties category in the material menu. If you can’t see the big Add button in it, click the Custom Properties text to expand it. Make sure your red material is selected and click the Add button. A new property with the Property Name prop and Property Value of 1 will be created. Click the Edit button and change the name to FBX_vmatPath and the value to materials/models/props_items/red.
Repeat the same steps for the blue material, but change the value to materials/models/props_items/blue.
Assigning materials
Choose a Viewport Color in the Settings category of both materials. Switch to Edit Mode by pressing Tab and assign the two materials to different faces by using the Assign button in the material editor.
Mesh export
Click on File → Export → FBX to export you mesh as FBX. For this tutorial we’ll assume that you project has a models\props_items\fbx\ folder.
Selected Objects | Tick this box if your scene contains more than one prop. Make sure to select the right prop before opening the export dialogue. |
Apply Scalings | Choose FBX All. |
Forward / Up | This does not seem to affect the mesh’s orientation in Hammer. For the sake of consistency with Hammer’s coordination system it’s set to X Forward and Z Up. |
Custom Properties | Make sure to tick this box or your materials will not be recognized in Hammer. |
You can safely ignore the tabs Geometries, Armatures and Animation for regular props. Enter a prop name in the upper toolbar and click on Export FBX in the upper right to export your mesh.
If you'd like to save your settings as a preset, click on the + button to the right side of the Operator Presets list and enter a name. You can select the new preset by clicking on the Operator Presets button. Remember to always select the preset before exporting in a new Blender session, as the selected preset is reset when Blender is closed.
Conclusion
With your FBX exported to the right folder you're ready to import your prop into Hammer. Check out the Model Editor tutorial to find out how. If you need help creating your materials, the material creation tutorials will help you getting started.