This article's documentation is for Source 2. Click here for more information.

Source 2/Docs/Modeling/Exporting a mesh from Blender: Difference between revisions

From Valve Developer Community
< Source 2‎ | Docs‎ | Modeling
Jump to navigation Jump to search
(Added category to the page, added shortpagetitle template)
(Update example images to be in blender 4.5+)
 
(20 intermediate revisions by 11 users not shown)
Line 1: Line 1:
{{Note|This guide was created for Blender 2.79b. It should be updated once Blender 2.8 becomes the new official version.}}
{{Source 2 topicon}}
{{LanguageBar|title = Exporting a mesh from Blender to Source 2}}


== Introduction ==
This tutorial explains how to export a non-animated prop from {{Blender|4}} to {{Source 2|4}}. 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.


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 [[File:Blender 16.png|(icon)|link=]] [https://www.blender.org/download/ '''blender.org/download'''] or on [https://store.steampowered.com/app/365670/Blender/ Steam] for free.
 
If you don't have Blender installed on your computer, you can download it from [[File:Blender 16.png|(icon)|link=]] [http://www.blender.org/download '''blender.org/download'''] for free.


== Units setup ==
== Units setup ==


Before you start working on your mesh, make sure 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.
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.
 
 
[[File:Blender units setup.png]]


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.


{{Note|Blender 2.79b converts inches to feet as soon as something is larger than 12 inches. This makes comparing the size of objects between Blender and Hammer a bit difficult. This behaviour has changed in Blender 2.8, where the units stay in inch, no matter the size of an object. Due to this problem it’s easier to work in generic units.}}
[[File:Blender 4.0 Units Setup.png]]


==  Mesh scale and orientation ==
==  Mesh scale and orientation ==


We’ll use the default Suzanne monkey head as an example prop for this tutorial. Add it to you 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.
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.


{{Note|The amount of scaling is relative to the distance between your mouse cursor and the object. The closer your cursor is to the object when you press S, the higher the scale factor. If you have problems scaling the monkey head, move your mouse cursor farther away from it before you press S.}}
{{Note|The amount of scaling is relative to the distance between your mouse cursor and the object. The closer your cursor is to the object when you press S, the higher the scale factor. If you have problems scaling the monkey head, move your mouse cursor farther away from it before you press S.}}
Line 27: Line 24:
Your mesh should be facing south in Blender to be aligned properly with Hammer's coordinates, which the monkey head does by default.
Your mesh should be facing south in Blender to be aligned properly with Hammer's coordinates, which the monkey head does by default.


[[File:Blender 4.0 Mesh Scale And Orientation.png]]


[[File:Blender suzanne size.png]]
With your mesh selected Right-Click within the 3D Viewport and click Shade Smooth to change Suzanne to smooth shading.
 
 
Open the 3D viewport’s left menu with T and click Smooth to change Suzanne to smooth shading.
 
 
[[File:Blender shading smooth.png]]


[[File:Blender 4.0 Set Shade Smooth.png]]


== Material setup ==
== Material setup ==
=== Adding two materials ===
=== 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.
[[File:Blender cycles.png]]


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.
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.


 
[[File:Blender 4.0 Material Setup 1.png]]
[[File:Blender new material.png]]
 


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.
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.


 
[[File:Blender 4.0 Material Setup 2.png]]
[[File:Blender add material.png]]
 


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.
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.
Line 68: Line 52:
{{Note|Make sure to spell FBX_vmatPath with the right capitalizations. This property is case sensitive and does not export correctly if the capitalizations are wrong.}}
{{Note|Make sure to spell FBX_vmatPath with the right capitalizations. This property is case sensitive and does not export correctly if the capitalizations are wrong.}}


 
[[File:Blender 4.0 Material Custom Property.png]]
[[File:Blender material custom properties.png]]
 


Repeat the same steps for the blue material, but change the value to materials/models/props_items/blue.
Repeat the same steps for the blue material, but change the value to materials/models/props_items/blue.
Line 78: Line 60:
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.
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.


 
[[File:Blender 4.0 Assigning Materials.png]]
[[File:Blender material color.png]]
 


== Mesh export ==
== Mesh export ==
Line 86: Line 66:
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.
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.
   
   
 
[[File:Blender 4.0 Mesh Export.png]]
[[File:Blender fbx export.png]]
 


{| class="wikitable"
{| class="wikitable"
Line 109: Line 87:


== Conclusion ==
== Conclusion ==
With your FBX exported to the right folder you're ready to import your prop into Hammer. Check out the [[Dota_2_Workshop_Tools/Model_Editor/How_To|Model Editor]] tutorial to find out how. If you need help creating your materials, the [[Dota_2_Workshop_Tools/Materials|material creation tutorials]] will help you getting started.
With your FBX exported to the right folder you're ready to import your prop into Hammer. Check out the [[Dota 2 Workshop Tools/Model Editor/How To|Model Editor]] tutorial to find out how. If you need help creating your materials, the [[Dota 2 Workshop Tools/Materials|material creation tutorials]] will help you getting started.
 
{{shortpagetitle}}
[[Category: SteamVR]]

Latest revision as of 05:16, 6 September 2025

English (en)中文 (zh)Translate (Translate)

This tutorial explains how to export a non-animated prop from Blender Blender to Source 2 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 (icon) 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.

Blender 4.0 Units Setup.png

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.

Note.pngNote:The amount of scaling is relative to the distance between your mouse cursor and the object. The closer your cursor is to the object when you press S, the higher the scale factor. If you have problems scaling the monkey head, move your mouse cursor farther away from it before you press S.

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.

Blender 4.0 Mesh Scale And Orientation.png

With your mesh selected Right-Click within the 3D Viewport and click Shade Smooth to change Suzanne to smooth shading.

Blender 4.0 Set Shade Smooth.png

Material setup

Adding two materials

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.

Blender 4.0 Material Setup 1.png

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.

Blender 4.0 Material Setup 2.png

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.

Note.pngNote:Make sure to spell FBX_vmatPath with the right capitalizations. This property is case sensitive and does not export correctly if the capitalizations are wrong.

Blender 4.0 Material Custom Property.png

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.

Blender 4.0 Assigning Materials.png

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.

Blender 4.0 Mesh Export.png

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.