-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
449 lines (424 loc) · 21.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<style type="text/css">
figure.figure {
display: block;
}
.octicon {
fill: #ffffff;
}
h2 {
border-top: 1px solid #cccccc;
}
</style>
<title>Importing SFM Models into Unity</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark d-flex justify-content-between">
<h1 class="navbar-brand">Importing SFM Models into Unity</h1>
<a href="https://github.com/RoBorg/sfm-to-unity" target="_blank" aria-label="GitHub">
<svg height="32" class="octicon" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
</svg>
</a>
</nav>
<div class="container">
<div class="row">
<div class="col-sm">
<h2 id="contents">Contents</h2>
<ol>
<li>
<a href="#introduction">Introduction</a>
</li>
<li>
<a href="#software-requirements">Software Requirements</a>
</li>
<li>
<a href="#download">Download SFM model from Steam Workshop</a>
</li>
<li>
<a href="#installation">Installation</a>
</li>
<li>
<a href="#convert-the-model">Convert the Model</a>
</li>
<li>
<a href="#convert-the-textures">Convert the Textures</a>
</li>
<li>
<a href="#load-into-blender">Load into Blender</a>
</li>
<li>
<a href="#fix-skeleton">Fix the Skeleton (Optional)</a>
</li>
<li>
<a href="#export-to-unity">Export to Unity</a>
</li>
<li>
<a href="#load-into-unity">Load into Unity</a>
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="introduction">Introduction</h2>
<p>These instructions will tell you how to import Source Film Maker (SFM) models into Unity, through Blender.</p>
<p>
They are based primarily off the now-dead instructions by
<a href="http://www.digitalzombie.de/2016/02/13/how-to-use-sfm-models-in-unity/" target="_blank">Digitalzombie</a>.
</p>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="software-requirements">Software Requirements</h2>
<ul>
<li>
Unity -
<a href="https://unity3d.com/get-unity/" target="_blank">download</a>.
</li>
<li>
Blender -
<a href="https://www.blender.org/download/" target="_blank">download</a>. Used to convert 3d models to FBX format.
</li>
<li>
Blender Source Tools -
<a href="http://steamreview.org/BlenderSourceTools/" target="_blank">download</a>. Used to load decompiled SFM files into Blender.
</li>
<li>
BoneFix -
<a href="https://raw.githubusercontent.com/RoBorg/sfm-to-unity/master/utilities/BoneFix.py" target="_blank" download>download</a>. Optional - used to fix skeletons.
</li>
<li>
Crowbar (ZIP Version) -
<a href="http://steamcommunity.com/groups/CrowbarTool" target="_blank">download</a>. Used to decompile SFM files.
</li>
<li>
VTFEdit -
<a href="https://valvedev.info/tools/vtfedit/" target="_blank">download</a>. Used to convert VTF textures to PNG.
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="download">Download SFM model from Steam Workshop</h2>
<p>
To download a model from the Steam Workshop you can use a website like
<a href="http://steamworkshop.download/" target="_blank">steamworkshop.download</a>
or
<a href="https://steamworkshopdownloader.io/">steamworkshopdownloader.io</a>.
</p>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="installation">Installation</h2>
<h3> Installing Unity & Blender</h3>
<p>Install Unity and Blender as normal - the default options should be fine.</p>
<h3>Installing Blender Source Tools</h3>
<ol>
<li>
Load Blender and click on the
<b>Edit</b> menu and choose
<b>Preferences</b>.
</li>
<li>
Click the
<b>Add-ons</b> tab then click the
<b>Install</b> button.
<figure class="figure">
<a href="images/blender-user-preferences.png">
<img src="images/blender-user-preferences.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Install an add-on</figcaption>
</figure>
</li>
<li>
Locate the blender_source_tools.xxx.zip file you downloaded earlier and click the
<b>Install Add-on</b> button.
<figure class="figure">
<a href="images/blender-select-plugin-file.png">
<img src="images/blender-select-plugin-file.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Select Plugin File</figcaption>
</figure>
</li>
<li>
Check the plugin is active by typing "source" into the addon search box, and making sure the checkbox is checked next to
<b>Import-Export: Blender Source Tools</b>.
<figure class="figure">
<a href="images/blender-plugin-active.png">
<img src="images/blender-plugin-active.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Ensure Plugin is Active</figcaption>
</figure>
</li>
</ol>
<h3>Installing BoneFix</h3>
<ol>
<li>
Create a folder to store the scripts, and move
<b>BoneFix.py</b> into it.
</li>
<li>
Load Blender and click on the
<b>Edit</b> menu and choose
<b>Preferences</b>.
</li>
<li>
Click the
<b>File Paths</b> tab and set the
<b>Scripts</b> folder to where you placed
<b>BoneFix.py</b>, then click the
<b>Save User Settings</b> button.
<figure class="figure">
<a href="images/blender-user-scripts.png">
<img src="images/blender-user-scripts.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">User Scripts Folder</figcaption>
</figure>
</li>
</ol>
<h3>Installing Crowbar & VTFEdit</h3>
<p>Extract the each zip file into its own folder.</p>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="convert-the-model">Convert the Model</h2>
<p>
Your SFM file will probably be a zip file - extract it and find the folder with the
<b>.mdl</b> file you want to use.
</p>
<p>
Before starting, it's best to create a new folder to store your converted model and textures in.
</p>
<ol>
<li>
Load Crowbar and on the
<b>Decompile</b> tab, open your
<b>.mdl</b> file.
<figure class="figure">
<a href="images/crowbar-choose-file.png">
<img src="images/crowbar-choose-file.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Choose your File</figcaption>
</figure>
</li>
<li>
Click the
<b>Full path</b> radio button and choose folder you want to put the decompiled files in, then click
the
<b>Decompile</b> button. You can leave all the options at their default values.
<figure class="figure">
<a href="images/crowbar-decompile.png">
<img src="images/crowbar-decompile.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Decompile the Model</figcaption>
</figure>
</li>
<li>
When decompilation is complete your model will be ready to import into Blender, but the textures need converting separately.
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="convert-the-textures">Convert the Textures</h2>
<ol>
<li>
Open VTFEdit and click the
<b>Tools</b> menu then choose
<b>Convert Folder</b>.
</li>
<li>
Select the input folder that has the
<b>.vtf</b> and
<b>.vmf</b> files in it. Select an output folder for the
<b>.png</b> files - use the folder you created for the decompiled model. Click the
<b>Convert</b> button to convert the textures.
<figure class="figure">
<a href="images/vtfedit-convert.png">
<img src="images/vtfedit-convert.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Decompile the Textures</figcaption>
</figure>
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="load-into-blender">Load into Blender</h2>
<ol>
<li>
Open Blender and delete the Camera, Cube and Lamp objects.
</li>
<li>
Click the
<b>File</b> menu and go to the
<b>Import</b> submenu and choose
<b>Source Engine (.smd, .vta, .dmx .qc)</b>.
<figure class="figure">
<a href="images/blender-import-menu.png">
<img src="images/blender-import-menu.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Blender Import Menu</figcaption>
</figure>
</li>
<li>
Locate the folder you extracted the model into and select the
<b>*.qc</b> file. Click the
<b>Import SMD/VTA, DMX, QC</b> button. This can take quite a while - don't worry if Blender seems unresponsive.
<figure class="figure">
<a href="images/blender-import.png">
<img src="images/blender-import.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Blender Import *.qc File</figcaption>
</figure>
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="fix-skeleton">Fix the Skeleton (Optional)</h2>
<p>This is an optional step - follow it if your model has a skeleton you want to use in Unity</p>
<ol>
<li>
Click the mode tool and select
<b>Object Mode</b> then right-click on any bone to select the skeleton.
<figure class="figure">
<a href="images/blender-select-skeleton.png">
<img src="images/blender-select-skeleton.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Select the Skeleton</figcaption>
</figure>
</li>
<li>
Go to the Python console by clicking the window button and selecting
<b>Python Console</b>. Note - this was called
<b>Scripts</b> in older versions of Blender.
<figure class="figure">
<a href="images/blender-python-console.png">
<img src="images/blender-python-console.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Go to the Python Console</figcaption>
</figure>
</li>
<li>
Run the script using the following code (don't forget to change the script path!):
<br>
<b>exec(open("c:\\users\\RoBorg\\Documents\\Blender Scripts\\BoneFix.py").read())</b>
<br>
<br> If you're using Python 2, you can use this instead:
<br>
<b>execfile("c:\\users\\RoBorg\\Documents\\Blender Scripts\\BoneFix.py")</b>
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="export-to-unity">Export to Unity</h2>
<ol>
<li>
Click on the
<b>File</b> menu then choose the
<b>Export</b> and click on
<b>FBX (.fbx)</b>.
<figure class="figure">
<a href="images/blender-export-menu.png">
<img src="images/blender-export-menu.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Blender Export Menu</figcaption>
</figure>
</li>
<li>
Type a filename and click the
<b>Export FBX</b> button.
<figure class="figure">
<a href="images/blender-export.png">
<img src="images/blender-export.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Blender Export FBX</figcaption>
</figure>
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm">
<h2 id="load-into-unity">Load into Unity</h2>
<ol>
<li>
Load Unity and open your project or create a new one.
</li>
<li>
In the Project window, create a new folder for your model and under that folder create two more, called
<b>Materials</b> and
<b>Textures</b>.
</li>
<li>
Drag-drop your
<b>.fbx</b> file into your model folder, and the
<b>*.png</b> files into the
<b>Textures</b> folder
</li>
<li>
Export the materials from the model by selecting the model and going to the
<b>Inspector</b> and choosing the
<b>Materials</b> tab. Make sure the
<b>Import Materials</b> checkbox is checked, then click the
<b>Extract Materials</b> button. Choose the
<b>Materials</b> folder you created previously.
<figure class="figure">
<a href="images/unity-extract-materials.png">
<img src="images/unity-extract-materials.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Extracting Materials</figcaption>
</figure>
</li>
<li>
Assign the correct texture to each material by going to the
<b>Materials</b> folder in the
<b>Project</b> windows and clicking on each material in turn. Click the circle icon next to
<b>Albedo</b> and choose the correct texture from the
<b>Textures</b> folder - it should have the same name as the material. Note that not all materials will
have a texture - they may just be solid colours.
</li>
<li>
Remove the colour cast from your materials by selecting all of them in the
<b>Project</b> window then clicking the colour swatch next to
<b>Albedo</b> and set it to white.
</li>
<li>
Go to the
<b>Textures</b> folder and select all the textures, then in the
<b>Inspector</b> check the
<b>Alpha Is Transparency</b> checkbox and click the
<b>Apply</b> button.
<figure class="figure">
<a href="images/unity-transparency.png">
<img src="images/unity-transparency.png" class="figure-img img-fluid rounded" alt="Screenshot">
</a>
<figcaption class="figure-caption">Texture Transparency</figcaption>
</figure>
</li>
<li>
You can now add the model to your scene!
</li>
</ol>
</div>
</div>
</div>
</body>
</html>