Destinations/Importing Tutorial: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
= Importing an FBX into Workshop tools  =
= Importing an FBX into Workshop tools  =


In this tutorial, we will walk through importing an FBX with animations and textures, and run them through the Model and material editor.
In this tutorial, we will walk through importing an FBX with animations and textures, and run them through the Model and Material editor.


 
* Export Model in FBX format from authoring package (Autodesk's Maya in this case).
* Export Model, in FBX format, from authoring package (Autodesk's Maya in this case).
* Export animations as FBX files.
* Export animations, as FBX files.
* Import model into model editor.
* Import model into model editor.
* Import animations into model editor.
* Import animations into model editor.
Line 12: Line 11:
== Authoring the model ==
== Authoring the model ==


* In the case of this Turret model from Portal2, Maya was used to build the model and the animtions, textures were assigned to the meshes within Maya.
* In the case of this Turret model from Portal2, Maya was used to build the model and the animations. Maya was also used to assign textures to the meshes.


[[Image:01_turret_pic.png|thumb|256px|right|caption| A Turret yesterday.]]
[[Image:01_turret_pic.png|thumb|256px|right]]


* Source2 only deals with skeletal animation.  You cannot animate meshes or a group of meshes by themselves, you must either skin the geometry to a skeleton, or you can just parent geometry underneath the relevant bone.
* Source2 only deals with skeletal animation.  You cannot animate meshes or a group of meshes by themselves, you must either skin the geometry to a skeleton, or you can just parent geometry underneath the relevant bone.
Line 20: Line 19:
* This model has 4 animations, and uses 4 textures.
* This model has 4 animations, and uses 4 textures.


[[Image:02 turret textures.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:02 turret textures.png|thumb|512px|left]]


{{clr}}
{{clr}}
Line 26: Line 25:
== Exporting FBX ==
== Exporting FBX ==


* Exporting the model and materials.
* Exporting the model and materials (from Maya).
** Upon Exporting, there are many options in the FBX exporter, make sure Deformed Models and skins, are checked.
** Upon Exporting, there are many options in the FBX exporter, make sure '''Deformed Models''' and '''Skins''' are checked.
** You can export this FBX wherever you like, when you pull it into the workshop tools the importer will generate the correct directory structure.
** You can export this FBX wherever you like. When you pull it into the workshop tools the importer will generate the correct directory structure.


[[Image:03_deformations.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:03_deformations.png|thumb|512px|left]]
{{clr}}
{{clr}}


* Embed Media is the option that will include the assigned textures, and package them into the FBX files, so check this.
* Make sure to check '''Embed Media''' as well - this will include the assigned textures and package them into the FBX files.


[[Image:05_embedmedia.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:05_embedmedia.png|thumb|512px|left]]
{{clr}}
{{clr}}


* In this case the four animations were authored in four separte Maya files, so there is an FBX exported for each animation, for now export these animation FBXs to the same place you exported the model FBX.  You only need the skeleton in this export, but it's ok to export the model too.  make sure you UNCHECK the embed media box if you do, so you don't have duplicate textures.
* In this case the four animations were authored in four separate Maya files, so there is an FBX exported for each animation. For, now export these animation FBXs to the same place you exported the model FBX.   
* You only need the skeleton in this export, but it's ok to export the model too.  If you do export the model as well, make sure you UNCHECK the embed media box, so you don't have duplicate textures.


[[Image:03_animations.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:03_animations.png|thumb|512px|left]]
{{clr}}
{{clr}}


== Importing into Workshop tools ==
== Importing into Workshop tools ==


* If you havn't already, create a new addon where your model with be used.
* If you haven't already, create a new addon where your model will be used.


[[Image:06_new_addon.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:06_new_addon.png|thumb|512px|left]]
{{clr}}
{{clr}}


* Once created, hit the 'Launch Tools' button.  this will bring up the asset browser, if this is a new addon it will be empty apart form the soundevents file.
* Once created, click the 'Launch Tools' button.  This will bring up the asset browser - if this is a new addon it will be empty apart from the soundevents file.


[[Image:07_asset_browser.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:07_asset_browser.png|thumb|512px|left]]
{{clr}}
{{clr}}


* Open the model editor, this is where we will import the FBX.
* Open the Model Editor, this is where we will import the FBX.
[[Image:09_launch_modeleditor.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:09_launch_modeleditor.png|thumb|512px|left]]
{{clr}}
{{clr}}


* Under file, select 'create New mesh from file'
* Under file, select 'create New mesh from file'


[[Image:08-5_dnew_mesh_from_file.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:08-5_dnew_mesh_from_file.png|thumb|512px|left]]
{{clr}}
{{clr}}


* This will bring up a warning about the directory structure. click ok to let the tools create the directory structure for you.
* This will bring up a warning about the directory structure. Click ok to let the tools create the directory structure for you.
It creates a folder under the addon name you gave, for instance, steamapps\common\destinations\content\steamtours_addons\portal_turret\models,  it also create a materials directory and unpacks the textures there.
*It creates a folder under the addon name you gave, for instance: steamapps\common\destinations\content\steamtours_addons\portal_turret\models. It also create a materials directory and unpacks the textures there.


[[Image:07-5_importfbx.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:07-5_importfbx.png|thumb|512px|left]]
{{clr}}
{{clr}}


** You are almost there, but you just need to  create the folder all the file s assocoated with this model will live under, No upper case letters, spaces or symbols, only lower case letters, numbers and underscores.  This seems unnessessary, but if you had lots of different models in your addon adding this named folder for each model would help keep thing tidy.  You have to right click the window, create a new folder and name it. Here is called turret_model, select it and hit [Select folder]
* You are almost there, but you just need to  create the folder all the files associated with this model will live under. This folder cannot use upper case letters, spaces or symbols - only lower case letters, numbers and underscores.  (This may seem unnecessary, but if you have many different models in your addon, adding this named folder for each model definitely helps keep things tidy).  You have to right click the window, create a new folder and name it. Here it is called turret_model, select it and click  [Select folder]


[[Image:08_directory_fun.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:08_directory_fun.png|thumb|512px|left]]
{{clr}}
{{clr}}


== Model Editor ==
== Model Editor ==


* Clicking Ok opens your model in the model editor.  Under UI you will find the outliner and the Property editor if they are not up by default.
* Clicking OK opens your model in the model editor.  If the Outliner and Property editor are not up by default, you can find them in the UI menu.


[[Image:11_model_in_editor.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:11_model_in_editor.png|thumb|680px|left]]
{{clr}}
{{clr}}


* If all has gone well, you will see the model with all it's textures.  The skeleton and the materials will be displayed in the outliner.  You may run into a situation where the model is made out of glowy wireframes, this is most likely a problem with the FBX export.
* If all has gone well, you will see the model with all its textures.  The skeleton and the materials will be displayed in the outliner.  You may run into a situation where the model is made out of glowy wireframes, this is most likely a problem with the FBX export. Make sure you have followed the preceding steps correctly.




== Adding animations ==
== Adding animations ==
* Before we import them into the tools, we must copy the animation FBXs to the same directory under models you created earlier, steamtours_addons\portal_turret\models\turret_models.
* Before we import them into the tools, we must copy the animation FBXs to the same directory under models you created earlier: steamtours_addons\portal_turret\models\turret_models.
You will see in there a DMX and a VMDL that the model editor created.
You will see in this folder that the model editor has already created a DMX and a VMDL file.


[[Image:12_move_fbxes.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:12_move_fbxes.png|thumb|680px|left]]
{{clr}}
{{clr}}


* Underneath animations pulldown, select "add animation". This may take a little while depending on the length of your animation.
* Back in the Model Editor underneath animations pulldown, select "add animation". This may take a little while depending on the length of your animation.
13_add_animation.png


[[Image:13_add_animation.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:13_add_animation.png|thumb|512px|left]]
{{clr}}
{{clr}}


* You can see the animations here, so far I only added 3penny_hi.
* You can see the animations here, so far I only added 3penny_hi.
If you select this animation in the outliner, you can play it using the play controls at the bottom right of the model editor.
If you select this animation in the outliner, you can play it using the play controls at the bottom right of the model editor.


[[Image:13_playbar.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:13_playbar.png|thumb|512px|left]]
{{clr}}
{{clr}}




* You can add as many animations as you like at a time.  So I will grab the three remaining FBXs and add them all at once.
You can add as many animations as you like at a time.  So I will grab the three remaining FBXs and add them all at once.


[[Image:14_outliner_animations.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:14_outliner_animations.png|thumb|512px|left]]
{{clr}}
{{clr}}




Here in the property editor you can see the lenth of the animation expressed in frames.  You start the animation later or end it early by atlerning the numbers in these fields.  You can speed up or slow down the animation by changing the FPS, and make the animtion loop.  There are more advanced things to do in here.
Here in the property editor you can see the length of the animation expressed in frames.  You can start the animation later or end it early by altering the numbers in these fields.  You can speed up or slow down the animation by changing the FPS, and make the animation loop, as well as other more advanced actions.
[[Image:15_property_editor.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:15_property_editor.png|thumb|512px|left]]
{{clr}}
{{clr}}


* You can also create new animation sequences from existing animation.  It's often useful to have an idle animation, this can often be just a static animation.  In the case of the turrets, their idle is them just sitting there with the gun foils closed. Since this state exists as the first frame of these animations, we can just create that here instead of having to export another FBX.


* You can also create new animation sequences from existing animation.  It's often useful to have an idle animation, this can often be just a static animtion.  In the case of the turrets, their idle is them just sitting their with the gun foils closed. Since this state exists as the first frame of these animations, we can just that instead of having to export another FBX.
* To do this start by copying one of the animations.  A dialog box will pop up asking for a name for this animation. I'm calling it “idle”.
 
* To do this start by copying one of the animations.  a dialog box will pop up asking for a name for this animation, I'm calling it idle.


[[Image:16_copy_anim.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:16_copy_anim.png|thumb|512px|left]]
{{clr}}
{{clr}}


To create an idle of a static turret change the end frame to 0, effectivly removing all the animation.
To create an idle animation of a static turret change the end frame to 0, effectively removing the rest of the animation.
[[Image:17_make_idle.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:17_make_idle.png|thumb|512px|left]]


1[[Image:18_idle_in_outliner.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:18_idle_in_outliner.png|thumb|512px|left]]
{{clr}}
{{clr}}


Instead of exporting 4 different animations, you could author them as one big sequence, one animation after the other, you could then make four copies of this long animation and clip out the relevant frame ranges from.
‘’Instead of exporting 4 different animations, you could have also authored them as one big sequence, one animation after the other. You could have then make four copies of this long animation and clipped out the relevant frame ranges.’’


Remember to save the model.
Remember to save the model.
Line 135: Line 135:
== Materials ==
== Materials ==


When you imported the FBX with embedded media, the importer created basic materials for each texture according the shader you selected upon import, if you don't remember doing that the default is VR_standard, which is a fine choice.
When you imported the FBX with embedded media, the importer created basic materials for each texture according the shader you selected upon import. If you don't remember doing that the default is VR_standard, which is a fine choice.


* To edit the material (vmat), double click one in the outliner to open the material editor.
* To edit the material (vmat), double click one in the Model Editor outliner to open the Material Editor.
Alternativly, you can do this from the asset editor.
Alternatively, you can do this from the asset editor.


1[[Image:19_materials_outliner.png|thumb|512px|left|caption| textures as the appear in Maya.]]
[[Image:19_materials_outliner.png|thumb|512px|left]]
{{clr}}
{{clr}}


* Here you can assign other textures to different parts of the material.  By default the Vr Standard shader has no Specular.  Turn it on with the checkbox.
* Here you can assign other textures to different parts of the material.  By default the Vr Standard shader has no Specular.  Turn it on with the checkbox.


1[[Image:20_material_editor.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:20_material_editor.png|thumb|680px|left]]
{{clr}}
{{clr}}


* This has created a reflectance component to the shader and you can see the highlight on the material.
* This has created a reflectance component to the shader and you can see the highlight on the material.


1[[Image:22_adding_spec.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:22_adding_spec.png|thumb|680px|left]]
{{clr}}
{{clr}}


By default, the reflectance is looking for a texture, the material editor makes a simple grey texture for a placeholder. If you have authored a reflectance texture it must live with the unpacked ones made during the import process. /content/steamtours_addons/portal_turret/materials/models/turret_models/
By default, the reflectance is looking for a texture, the material editor makes a simple grey texture for a placeholder. If you have authored a reflectance texture it must live in the same folder as the unpacked ones made during the import process. /content/steamtours_addons/portal_turret/materials/models/turret_models/


1[[Image:21_turret_specmask.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:21_turret_specmask.png|thumb|680px|left]]
{{clr}}
{{clr}}


Now you can see the effect of the texture on the highlight.
Now you can see the effect of the texture on the highlight.
1[[Image:23_adding_refl.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:23_adding_refl.png|thumb|680px|left]]
{{clr}}
{{clr}}


* You can further tweak the effect of the texture with the reflectance range sliders below.
* You can further tweak the effect of the texture with the reflectance range sliders below.
1[[Image:24_range_sliders.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:24_range_sliders.png|thumb|680px|left]]
{{clr}}
{{clr}}
[[Image]]


* If you just want a simple solid color to define the reflectance, you can hit the gradient button that switches the texture path to a slider.  
* If you just want a simple solid color to define the reflectance, you can hit the gradient button that switches the texture path to a slider.  
1[[Image:25_gradient_button.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:25_gradient_button.png|thumb|680px|left]]
{{clr}}
{{clr}}


Moving the slider to the right increased the strength of the highlight.  A lot of shader components have this feature.
Moving the slider to the right increased the strength of the highlight.  Many shader components have this feature.
1[[Image:25_gradient_slider.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:25_gradient_slider.png|thumb|680px|left]]
{{clr}}
{{clr}}


Looking at the eye material, it need to glow. One way of doing this is to use self illumintaion.  this looks at the color texture, and makes it incandescent.  Check the 'sefl illum' box in the left, which enables a slider to increase the effect.
The eye material needs to glow. One way of doing this is to use self illumination.  this looks at the color texture and makes it incandescent.  Check the 'self illum' box in the left, which enables a slider to increase the effect.
1[[Image:26_self_illum.png|thumb|680px|left|caption| textures as the appear in Maya.]]
[[Image:26_self_illum.png|thumb|680px|left]]
{{clr}}
{{clr}}


Remember to save the material one you are done.
Remember to save the material once you are done.
 
Now you have model with animations that you can use in Hammer,


[https://developer.valvesoftware.com/wiki/Destinations/Turret_Tutorial like in this this hammer tutorial].
Congratulations! Now you have model with animations that you can use in Hammer. Learn how to hook these animations up with triggers  [https://developer.valvesoftware.com/wiki/Destinations/Turret_Tutorial in this tutorial].

Revision as of 19:58, 28 June 2016

Importing an FBX into Workshop tools

In this tutorial, we will walk through importing an FBX with animations and textures, and run them through the Model and Material editor.

  • Export Model in FBX format from authoring package (Autodesk's Maya in this case).
  • Export animations as FBX files.
  • Import model into model editor.
  • Import animations into model editor.
  • Editing materials.

Authoring the model

  • In the case of this Turret model from Portal2, Maya was used to build the model and the animations. Maya was also used to assign textures to the meshes.
01 turret pic.png
  • Source2 only deals with skeletal animation. You cannot animate meshes or a group of meshes by themselves, you must either skin the geometry to a skeleton, or you can just parent geometry underneath the relevant bone.
  • This model has 4 animations, and uses 4 textures.
02 turret textures.png

Exporting FBX

  • Exporting the model and materials (from Maya).
    • Upon Exporting, there are many options in the FBX exporter, make sure Deformed Models and Skins are checked.
    • You can export this FBX wherever you like. When you pull it into the workshop tools the importer will generate the correct directory structure.
03 deformations.png
  • Make sure to check Embed Media as well - this will include the assigned textures and package them into the FBX files.
05 embedmedia.png
  • In this case the four animations were authored in four separate Maya files, so there is an FBX exported for each animation. For, now export these animation FBXs to the same place you exported the model FBX.
  • You only need the skeleton in this export, but it's ok to export the model too. If you do export the model as well, make sure you UNCHECK the embed media box, so you don't have duplicate textures.
03 animations.png

Importing into Workshop tools

  • If you haven't already, create a new addon where your model will be used.
06 new addon.png
  • Once created, click the 'Launch Tools' button. This will bring up the asset browser - if this is a new addon it will be empty apart from the soundevents file.
07 asset browser.png
  • Open the Model Editor, this is where we will import the FBX.
09 launch modeleditor.png
  • Under file, select 'create New mesh from file'
08-5 dnew mesh from file.png
  • This will bring up a warning about the directory structure. Click ok to let the tools create the directory structure for you.
  • It creates a folder under the addon name you gave, for instance: steamapps\common\destinations\content\steamtours_addons\portal_turret\models. It also create a materials directory and unpacks the textures there.
07-5 importfbx.png
  • You are almost there, but you just need to create the folder all the files associated with this model will live under. This folder cannot use upper case letters, spaces or symbols - only lower case letters, numbers and underscores. (This may seem unnecessary, but if you have many different models in your addon, adding this named folder for each model definitely helps keep things tidy). You have to right click the window, create a new folder and name it. Here it is called turret_model, select it and click [Select folder]
08 directory fun.png

Model Editor

  • Clicking OK opens your model in the model editor. If the Outliner and Property editor are not up by default, you can find them in the UI menu.
11 model in editor.png
  • If all has gone well, you will see the model with all its textures. The skeleton and the materials will be displayed in the outliner. You may run into a situation where the model is made out of glowy wireframes, this is most likely a problem with the FBX export. Make sure you have followed the preceding steps correctly.


Adding animations

  • Before we import them into the tools, we must copy the animation FBXs to the same directory under models you created earlier: steamtours_addons\portal_turret\models\turret_models.

You will see in this folder that the model editor has already created a DMX and a VMDL file.

12 move fbxes.png
  • Back in the Model Editor underneath animations pulldown, select "add animation". This may take a little while depending on the length of your animation.
13 add animation.png
  • You can see the animations here, so far I only added 3penny_hi.


If you select this animation in the outliner, you can play it using the play controls at the bottom right of the model editor.

13 playbar.png


You can add as many animations as you like at a time. So I will grab the three remaining FBXs and add them all at once.

14 outliner animations.png


Here in the property editor you can see the length of the animation expressed in frames. You can start the animation later or end it early by altering the numbers in these fields. You can speed up or slow down the animation by changing the FPS, and make the animation loop, as well as other more advanced actions.

15 property editor.png
  • You can also create new animation sequences from existing animation. It's often useful to have an idle animation, this can often be just a static animation. In the case of the turrets, their idle is them just sitting there with the gun foils closed. Since this state exists as the first frame of these animations, we can just create that here instead of having to export another FBX.
  • To do this start by copying one of the animations. A dialog box will pop up asking for a name for this animation. I'm calling it “idle”.
16 copy anim.png

To create an idle animation of a static turret change the end frame to 0, effectively removing the rest of the animation.

17 make idle.png
18 idle in outliner.png

‘’Instead of exporting 4 different animations, you could have also authored them as one big sequence, one animation after the other. You could have then make four copies of this long animation and clipped out the relevant frame ranges.’’

Remember to save the model.

Materials

When you imported the FBX with embedded media, the importer created basic materials for each texture according the shader you selected upon import. If you don't remember doing that the default is VR_standard, which is a fine choice.

  • To edit the material (vmat), double click one in the Model Editor outliner to open the Material Editor.

Alternatively, you can do this from the asset editor.

19 materials outliner.png
  • Here you can assign other textures to different parts of the material. By default the Vr Standard shader has no Specular. Turn it on with the checkbox.
20 material editor.png
  • This has created a reflectance component to the shader and you can see the highlight on the material.
22 adding spec.png

By default, the reflectance is looking for a texture, the material editor makes a simple grey texture for a placeholder. If you have authored a reflectance texture it must live in the same folder as the unpacked ones made during the import process. /content/steamtours_addons/portal_turret/materials/models/turret_models/

21 turret specmask.png

Now you can see the effect of the texture on the highlight.

23 adding refl.png
  • You can further tweak the effect of the texture with the reflectance range sliders below.
24 range sliders.png
  • If you just want a simple solid color to define the reflectance, you can hit the gradient button that switches the texture path to a slider.
25 gradient button.png

Moving the slider to the right increased the strength of the highlight. Many shader components have this feature.

25 gradient slider.png

The eye material needs to glow. One way of doing this is to use self illumination. this looks at the color texture and makes it incandescent. Check the 'self illum' box in the left, which enables a slider to increase the effect.

26 self illum.png

Remember to save the material once you are done.

Congratulations! Now you have model with animations that you can use in Hammer. Learn how to hook these animations up with triggers in this tutorial.