Jump to content

[TUTORIAL] Import a model and its material


leplubodeslapin

Recommended Posts

Hello,

Quickly writting that tutorial from my experiments but a more official tutorial on the wiki should definitely replace this.

First, gather the source files. We will consider a material with a standard PBR shader. All the folders are relative path, so find this location on your pc :
Half-Life Alyx\content\hlvr_addons\your_addon\
And then place the files over there :

  • The model itself : \models\folder\mesh.fbx
  • The collision if you have one \models\folder\includes\mesh_physbox.fbx
  • The diffuse (must end with _color) : \materials\models\folder\mesh_color.png
  • The normalmap (must end with _normal) : \materials\models\folder\mesh_normal.png
  • The Roughness (must end with _rough) : \materials\models\folder\mesh_rough.png

Note : You can use PNG, but also TGA, JPG or even PSD
Note 2 : The normalmap doesn't have its vertical values inverted like it was the case on Source 1. If you import a normalmap from Source 1, don't forget to invert the green channel !

 

In my case, it's a vehicle that I'll name "vehicle_sherpa", so here are my files :

  • The model : \models\vehicle\vehicle_sherpa.fbx
  • The collision \models\vehicle\includes\vehicle_sherpa_physbox.fbx
  • The diffuse : \materials\models\vehicle\vehicle_sherpa_color.png
  • The normalmap : \materials\models\vehicle\vehicle_sherpa_normal.png
  • The Roughness : \materials\models\vehicle\vehicle_sherpa_rough.png
  • The AO : \materials\models\vehicle\vehicle_sherpa_ao.png

 

Then, we'll start by creating the material. On the asset Browser window, find the Material Editor and open it.
image.png.ad4cc45d1db42dc95c8e4bfd9f2ac530.png

File → New

And then immediately save (File → Save or CTRL + S) to define a location of your vmat.
In my case, it will go along with with the textures I just imported \materials\models\vehicle\vehicle_sherpa.vmat

Note : once the files are compiled, you'll get the same hierarchy over the game folder than the content folder. Once the vmat will be compiled, it will become vmat_c (compiled material) and will have vtex_c with it (combined texture).

We will keep the Vr Simple shader
image.png.9c2d3b108f9df5ee6af177f299e111a1.png

And you can start importing the textures by clicking on the folder icon next to each field. It will only look for files ending with the right suffix, hence the importance of naming your files to make your work easier afterwards.
In my case, I have an AO texture so I'll check "Ambiant Occlusion Texture" on the left but it's optionnal. In the end, it should look like this :

image.png.c9bb25d7a5f404595edc07d67cff28b1.png

Feel free to use more complex shaders and to tweak things better. My model should definitely use a metalness texture but it's fine for this demonstration.

Ok now save and you can quit the material editor.

 

Back on the Asset Browser, find the ModelDoc Editor
image.png.b4de475078431f904ed82e9bd1a83610.png

 

Same thing, start by saving your model. In my case it will go there \models\vehicle\vehicle_sherpa.vmdl

Start by selecting an archetype, for this we will do a simple Static Prop Model.
And then, import your mesh by using that cute little star button :

image.png.2a77a5233e2648a2bcb137ceadf56a95.png

Once your mesh added, it will feel like nothing is happening. Try pressing the compile button on the right.
That's right, you need to press that compile button to make sure to compile stuff. It wasn't the case for the material editor, everything was being compiled automatically.

Your model should be a ref wireframe because it doesn't have any material assigned to it, so let's start with that.

On the left pannel, check "Show Empty Categories", it will show you "categories" for which you can configure stuff (i'm vague because ... i don't know most of these stuff for now).

 

Right clic on the category "MaterialGroupList"  → Add DefaultMaterialGroup
And then, if the item "DefaultMaterialGroup" is selected, in the Node Editor pannel you'll be able to assign a material. I assume you can manage with this category the multiple materials you might need for your model. For my simple example, there's only one material so I will stick with 1 group.

Compile your model and it should start to look like something ! :D 

You can move like in Hammer (hold RMB/press Z and move with WASD) or you can rotate around the mesh by holding ALT + LMB.

Cool !
image.png.b3a373481b56cb67713553857c615386.png

Now let's add a collision. Right clic on the category PhysicsShapeList and you'll notice multiple options to add collision
image.png.99e1503ee2fbfcb3ba4904b6f752a233.png

I assume it's there because you might be able to add shapes (box, capsules and spheres) by hand or you can decide to generate a collision from ModelDoc. By in my case I have a mesh, so I'll pick "Add PhysicsMeshFile" and gives the physbox FBX I imported earlier.
It should look like this in your 3D view

image.png.8fa8067a929ac5fb8d7e343c5db00efd.png

 

Compile your model and you can try to place your model in hammer !

image.png.fc768304a9d6b7b5e5d31ae47a34dbf7.png

 

:dance:

Edited by leplubodeslapin
Link to comment
Share on other sites

  • FMPONE pinned this topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Mapcore Supporters

    Funds go towards hosting and license costs, Discord server boosts, and more. If you'd like to donate, check out our Patreon announcement.

×
×
  • Create New...