Tomato127's avatar

Tomato127

430 Watchers47 Deviations
55.7K
Pageviews
This honestly took too long to come out. The previous part is  SFM/GMod Porting Tutorial Part 1 (Models)Do you want to learn how to port models but don't know how? Either because 3D modelling is daunting, you don't know how GMod or SFM works, or you don't know where to get the models in the first place? I hope this tutorial will help guide you through the process.
Texture details are explained in part 2, over here:
Please let me know if there are details in the porting tutorial that require more explanation. I'd love to make this as clear as I can for everybody and it's hard to do without remembering how it felt when this was all new.
Tools
A major difficulty with porting is finding the required tools for importing, extracting, and converting, not to mention with free programs. Every tool required are included with links directing you to their source.
Blender (Steam version) is what we'll use. This is not a Ble


Extracting textures is easy. Using them correctly is another task, though. I hope to provide as much information on the texture parameters for SFM/GMod as I can along with information on the textures themselves.

Tools

I use Noesis to convert DDS files to TGA or PNG, and use VTFEdit to convert those to VTF. Switch Toolbox can extract textures from BNTX files, which are often included in the BFRES model files, directly into PNG.

Texture Types

What type of textures do the models use? More often than not, the suffix of a texture name denotes its role. Here's a list of the ones I personally know.

_Alb  Albedo
The base color
_Nrm  Normal
The bumpmap
_Rgh  Roughness
The Roughness as used in Physically-Based Rendering
_Mtl    Metalness
The Metalness as used in Physically-Based Rendering
_Emm  Emission
The glow
_Tcl Team Color
The colorable parts of the model. It is additively blended to the albedo
_Trm Transmission
Related to subsurface scattering
_2cl    Color mask
Used when the model is inked
_MtlA  Misc
Its use depends on the model, from glow color to detail overlay

Some unfamiliar texture suffixes include _Thc, _Fxm, and _Hlt.

Due to the different rendering engines, the textures need to be adjusted in order to work with Source. In particular, the roughness and metalness textures can't be used directly, and the normal map's green channel has to be inverted because the Y axis is inverted in Source.

I recommend you lighten the albedo using the roughness and darken the albedo using the metalness, but do adjustments as you see fit.

Texture Conversion

It suffices to open VTFEdit with the PNG or TGA file and select the VTF format. The formats are as followed:
RGBA8888: Uncompressed RGBA
RGB888: Uncompressed, no alpha channel
DXT1: Compressed, no alpha channel (or one bit if DXT1 with One Bit Alpha is selected)
DXT3: Compressed RGB, uncompressed alpha channel
DXT5: Compressed RGBA
A8: Only alpha channel
I8: Uncompressed grayscale

Remaining formats are found on the Wiki, but mostly consists of different ordering of the RGB channels. I personally use DXT1 (no alpha channels) or DXT5 (with alpha channels), as the compression artifact is little. DXT5 can take twice as much space as DXT1, so please be careful!

VMT Setup

A VMT file is just a text file. The locations of the VMTs depend on the $cdmaterials command entered in the QC of the model you compiled (all of that was already discussed in the first tutorial). A VMT file consists of a shader name followed by curly brackets, with texture parameters between. For models it is almost always VertexlitGeneric. The setup essentially looks like this:
VertexlitGeneric
{
  name value
  othername "[1 2 3]"
  ...
}
The order of VMT parameters don't matter. Parameters with square brackets ([]) go from 0 to 1 whereas parameters with curly brackets ({}) go from 0 to 255, and are completely interchangeable. Higher values are allowed and just mean a larger strength, though too high values can lead to unexpected results. These values must also be enclosed between quotation marks as they contain spaces. Quotation marks are otherwise not necessary. Capitalization is also not necessary.

There's plenty of parameters (here's the list on the wiki), but here's an overall list:


$phong <0 or 1>
Activates phong
$phongboost <number>
Controls strength of phong highlights. The default is 1.
$phongexponent <number>
Controls spread of phong highlights. The default is 5.
$phongfresnelranges "[<number> <number> <number>]"
Controls rim lighting strength when facing directly (first number), facing at a 45 degree angle (second number), and facing the grazing angle (third number). Default is "[0.05 0.5 1]".
$phongtint "{<R> <G> }"
Controls color of phong highlights.
$phongalbedotint <0 or 1>
Makes the color of the phong highlight depend on the $basetexture.
$halflambert <0 or 1>
Activates half-lambert shading (rather than full-lambert). This option is forced on if phong is on and actually cannot be deactivated with $halflambert 0, so it isn't necessary to type out.

$selfillum <0 or 1>
Activates glow. The alpha channel of $basetexture decides the glow strength per pixel.
$selfillumtint "{<R> <G> }"
The color of the glow. You often want this larger than 255 for the glow to be noticeable.


$envmap <path or "env_cubemap">
Texture used for specular reflection.
$envmaptint "{<R> <G> }"
Controls color of specular reflection.
$basealphaenvmapmask <0 or 1>
Use the $basetexture alpha channel as the envmap's mask.
$normalmapalphaenvmapmask <0 or 1>
Use the $bumpmap alpha channel as the envmap's mask.

$basetexture <path>
The main texture of the model. The _Alb texture is typically used here.
$selfillummask <path>
The glow mask of the model. The _Emm texture is typically used here.
$bumpmap <path>
The bumpmap of the model. The _Nrm texture is used here. The alpha channel controls the effect of $phongboost.
$envmapmask <path>
The environment map's mask. Cannot be used with $bumpmap, however.
$phongexponenttexture <path>
Controls the phongexponent per pixel with the Red channel and the tint color percentage with the Green channel (if $phongalbedotint is on).


$detail <path>
An extra texture to be drawn over $basetexture
$detailscale <number>
Scales the $detail texture. The default is 4. It should typically be set to 1 for these textures.
$detailblendmode <number>
Sets the way the $detail texture is blended with $basetexture, listed here.

$color2 "{<R> <G> }"
Multiplicatively blends this color with the $basetexture.
$additive <0 or 1>
Sets the model to blend additively instead of multiplicatively. Useful for glass and ghostly textures.
$translucent <0 or 1>
Adds transparency depending on the alpha channel of $basetexture
$alphatest <0 or 1>
Like $translucent but no partial transparency. Is usually faster as well.
$decal <0 or 1>
Useful to solve clipping issues with poster-like models. Mostly only happens in maps, though.
$blendtintbybasealpha <0 or 1>
Sets whether amount of color blending should be controlled by the $basetexture alpha channel.

Material proxies are like code that can edit material properties, useful for animated textures, recolorable parts, and other special effects. More information can be found here. In particular, ItemTintColor and SelectFirstIfNonZero are often used together to make recolorable textures work in both GMod and SFM.


As long as you experiment and take your time to understand how the rendering engine works, it should be easy. I'll make sure to update this and the first tutorial with more knowledge as I stumble upon them. Nothing is perfect, and the Source engine is too old to properly display the Splatoon models, so please enjoy what you're capable of doing. ^^
Join the community to add your comment. Already a deviant? Log In
Do you want to learn how to port models but don't know how? Either because 3D modelling is daunting, you don't know how GMod or SFM works, or you don't know where to get the models in the first place? I hope this tutorial will help guide you through the process.

Texture details are explained in part 2, over here: SFM/GMod Porting Tutorial Part 2 (Textures)This honestly took too long to come out. The previous part is 
Extracting textures is easy. Using them correctly is another task, though. I hope to provide as much information on the texture parameters for SFM/GMod as I can along with information on the textures themselves.
Tools
I use Noesis to convert DDS files to TGA or PNG, and use VTFEdit to convert those to VTF. Switch Toolbox can extract textures from BNTX files, which are often included in the BFRES model files, directly into PNG.
Texture Types
What type of textures do the models use? More often than not, the suffix of a texture name denotes its role. Here's a list of the ones I personally know.
_Alb 


Please let me know if there are details in the porting tutorial that require more explanation. I'd love to make this as clear as I can for everybody and it's hard to do without remembering how it felt when this was all new.

Tools

A major difficulty with porting is finding the required tools for importing, extracting, and converting, not to mention with free programs. Every tool required are included with links directing you to their source.
Blender (Steam version) is what we'll use. This is not a Blender tutorial, though Blender tricks will be shared to help kick-start your modelling knowledge and UI screenshots are included to help you find where everything is (Blender 3.0 screenshots will be shared soon).
We're porting for SFM/GMod so we'll use the Blender Source Tools. Its installation instructions are found on the website.
Crowbar will be used as the model compiler (raw-asset to game-usable converter). There are other options for compilation but this one is the simplest, and can also act as a decompiler if necessary.
A popular method of extracting Nintendo models like BFRES is using the Switch Toolbox. Extracting the data from Switch cartridges themselves is beyond the scope of this guide. Already-extracted models can be found on the Models Resource.

Model Manipulation


More often than not, model manipulation is required for the model to work in a new format. The only one absolutely required for GMod and SFM is the maximum number of weight groups a vertex is allowed to be in, which is 3 (in other words every point can be influenced by 3 bones at most). This can be assured by entering Weight Paint mode and select Limit Total on the left menu.

Limit Total by Tomato127
This menu is on the left, in Weight Paint mode. Press T if it doesn't appear

You can leave this step until the very end, but make sure to remember to do it. If you receive a "Too many bone influences per vertex!" error during compilation, it means you forgot this step.

If you want to create models to merge onto the existing Inklings and Octolings, you need to import their bones, which can be done by decompiling the models using Crowbar.

New Materials

You want to make a certain part of a model transparent (such as a logo) without affecting the whole texture? Or maybe you want certain parts to have certain effects such as metallic reflection? Whatever the reason, adding a material is actually easy.

Materials by Tomato127
This menu is on the right, in Edit mode.

Click on the plus button to add more materials or minus to remove the material. Assign sets the selected faces to the selected material, Select selects all faces that are assigned to the material, and Deselect deselects all faces that are assigned to the material.

Split Model

Want to separate a wristband from a gear or make a part of a map its own object? After selecting the parts you want to split in Edit Mode, hit P and select the first menu's option (separate by selection). Pressing L while hovering over a vertex will select connecting vertices, helping you select parts of the full object, but it's up to you to properly select areas.

On the contrary, hitting Ctrl+J joins the selected objects.

Flexes

Flexes are called "Shape Keys", and they are found in the Data tab.
Shape Keys by Tomato127
This menu is on the right.

Add shape keys using the plus button and remove them using the minus button. The Basis shape key will be the first key added and is simply the default state. A flex can only be edited when its slider is at 1, in case you're experiencing odd issues unable to edit the model. Pressing the tack sets the selected shape key to 1 automatically, allowing you to sort through them and quickly edit as necessary.

Flexes can be whatever you want. The bust adjust slider is created by adding bumps to clothing using Sculpt Mode, for example.

Make sure the flex sliders are all set to 0 before compiling.

Eyes

All you need is the center of the individual eyeballs, either the actual center of a sphere or the center of the sphere section, and the center point of the eyes as a compilation parameter later. I'm not too sure of easy ways to calculate this, but some models have eye bones and those positions should suffice.

More information are found on the wiki.

Physics collision

It's actually relatively easy: Just split the model and set the weight of each section to their corresponding bone to 1. Model pieces should not overlap to prevent collision glitches, and make sure each object's origin is set to (0,0,0) by hitting Ctrl+A in object mode and selecting Apply Location. More information on collision meshes can be found on the wiki.

If you want to view collisions in GMod, type "vcollide_wireframe 1" in the console.

Model Export


More often than not you need to group the model(s) with its skeleton. This allows you to work on multiple parts at once (such as for creating body groups) and choose the exported DMX's name. This is relatively simple to do: just select the models to group and hit New Group. Name the group as you please.
New Group by Tomato127

Now comes the exporting! The export function is unusually not placed in the export main menu, but rather as a property of the scene.
Export DMX by Tomato127
This menu is on the right, in object mode

The Export Path can be wherever you want, and the default values should suffice for both SFM and GMod. I recommend the DMX format over the SMD format due to its more convenient and up-to-date features. When hitting Export, select the group you have created.

Compilation


Tired? This is the final step, so keep it up! To be able to use the model in-game, it must be compiled into a game-specific format. The compiler requires instructions on how to create a model; these instructions are stored in a QC file. A QC file is really just a text file with a different extension, so create a text file and rename its extension. Every line is a command (empty lines are allowed for organization). Here's a list of important commands:
$modelname path
The path to the exported model, relative to the models folder of the addon, including the mdl extension.
$body bodyname path
The path to the DMX file. There can be multiple of them, or none if they are all body groups (see below). Bodyname can be whatever you like.
$cdmaterials path
The path to the materials, relative to the materials folder of the addon. The path tends to be "models\" followed by the model path (without the mdl extension) by convention. There can be multiple paths, though keep in mind the order matters.
$sequence name file
An animation for the model. There has to be at least one animation, so usually it's just the DMX file itself with "idle" as its name.
$texturegroup skin {
texture name 1 }
texture name 2 }
}
A list of VMTs for the model's alternate skins ("skin" is actually the name of the texture group but goes unused). The first texture name must be the name of the material within Blender.

$bodygroup name {
  studio dmx path 1
  studio dmx path 2 
  blank
}
A list of DMX files for each model of the body group, or "blank" for no models. The DMX names do not appear in GMod but they do in SFM.
$scale number
In the offset chance that the model's scaling should change, there's no need to re-import the DMX into Blender just to scale it up; it's simpler to change it here. Make sure this command comes before other commands or else they will not be scaled.

Inkling and gear scale is 4. NPC scale is 3. Scaling can vary from model to model so it's recommended to set the scale here instead of scaling inside Blender.
$model name dmx file {
...
eyeball name bone X Y Z texture diameter angle unused scale
...
}
Use this instead of $body if you're doing NPCs with controllable eyes. XYZ is the sphere center coordinate for the eyeball (note that using $scale will not adjust these XYZ coordinates!). You should read up the $model commands for more options.
$attachment name bone X Y Z
Special position relative to a particular bone, though this is mainly for the eyes. The name is "eyes" and they are normally attached to the head bone. Note that XYZ typed here should actually be X -Z Y of the eye center you calculated earlier.
$collisionjoints dmx file {
...
}
Particularly important for GMod. Use $collisionmodel if it's a static model like a box or simple prop. Check out the $collisionjoints commands.

A list of all QC commands can be found on the wiki.

Example
$modelname "test\folder\wooden_box.mdl"
$body body "WoodenBoxModel.dmx"
$sequence idle "WoodenModel.dmx"

$cdmaterials "models\test\folder\wooden_box"
$cdmaterials "models\test\shared"
$texturegroup skin {
  { "oak" }
  { "dark_oak" }
}

$bodygroup Sticker {
  blank
  studio "Sticker.dmx"
}

$collisionmodel "WoodenBoxPhysics.dmx" {
  $mass 100
  $inertia 5
}

Open up Crowbarand find the QC file. Select the game from the drop-down list and hit compile (the UI can be found here). It's that simple.

Note that the models won't have textures! Check out part 2 of the tutorial (link at the top of this page).

Blender Tips


Shortcuts

Tab
  Switch to Edit Mode
Ctrl + Tab
  Switch to Weight Paint Mode
Ctrl+J
  Join (objects and bones)
Ctrl+D
  Duplicate
Ctrl+A
  Apply Transform
Ctrl+P
  Split objects
L
  Select vertex island
Ctrl + +/-
  Selection step forward/backward

Simple functions

Remove duplicates
Recalculate normals (Ctrl + N in edit mode)
Subdivide

Complex functions

Trigs to Quads (Ctrl + F in edit mode)
Beautify faces (Ctrl + F in edit mode)
Join the community to add your comment. Already a deviant? Log In
Ahh... Splatoon. It was released two years ago. I had great times, shed tears and salt, and met new friends along the way. Its sequel is releasing in July. Its community is standing strong. :iconlittlebludragoness: had the idea of sharing her notable experiences for this Splativersary (yeah I'm calling it that), and I thought it was a great idea. I was a little busy throughout the day, but I finally have the time to do this as well. I also encourage you to share your Splatoon experiences!

I was immediately hooked into Splatoon as soon as I saw the first trailer, despite not being a fan of shooters, no less online multiplayer-focused games. If I had no Wii U, I'd even get the console just for this game (it's basically the only game I play on the Wii U). I even felt a little nostalgic, and this is thanks to a rather old PC game called Colors of War. Released by eGames and developed by Brundelock Treasures Inc, this strategy game has you cover the field with your color to win. Weapons and utilities can only be deployed on your own color, and currency earned grows proportionally to your field's size. Seeing the concept of spreading color in a modern game has really excited me.
I believe it's thanks to Colors of War that I got attached to the concept of Splatoon immediately. Otherwise, I'd probably not buy it immediately at launch (the whole Squid-Kid duality is interesting enough to have convinced me if the color shooter aspect didn't).

My favourite stage has got to be Piranha Pit because of the chairs. My favourite Ranked mode is Rainmaker followed by Tower Control. The Charger and Roller class are tied as my favourite, with Custom E-Liter 3K and Octobrush probably being my most favourite of their respective class. I don't remember what was my favourite stuff way back when basically nothing was there the first couple of months, though (I have faint memories of maining a Blaster with the Bubbler Special before accidentally deleting my file while attempting to transfer data to another Wii U). Do you remember when Squid Beacons were placed at spawn? Do you remember the times where the Inkbrush and Port Mackerel was new? Do you remember the Inkzooka's firing speed? I'm still boggled by how much stuff was added and changed ever since launch. Let's hope the Wii U's Internet support doesn't cut off any time soon.

My Splatfest memories are blurry already! I'm not much of a competitive person in this regard, and being forced to choose a side makes me uncomfortable. I missed a couple of Splatfests, but out of forgetfulness rather than discomfort. I really enjoy both Squid Sisters for their own personality, but I personally lean towards Callie because I find upbeat more preferable than snarky. There was only one or two Splatfests where I fallback to the Squid Sisters as my choice instead of the theme.

I've been working on Splatoon mini-fanfictions and characters for quite some time, but there's a big one in particular that I've worked on ever since around August (2 months after the game was released!) according to my old files. Now that I have a DeviantArt account, I finally have a chance at publishing this story. I'm currently making modifications to the story so it fits as an SFM comic rather than text. I'm really excited to share!

I could ramble on and on, but I'm hoping to keep this short and simple enough. I'm looking forward to the community's growth when Splatoon 2 releases!
Join the community to add your comment. Already a deviant? Log In
As a reverse-birthday gift for everyone, I'm announcing that I'm taking requests! You can send requests through comments or notes. There's a couple of things you might want to know:
  • Renders and short animations for free! Points are still acceptable. I might ask for points if you ask for many requests or difficult animations.
  • These requests are a way to help me practice with rendering, but I'm still not all familiar with it yet. I might not be able to do exactly what you request.
  • Some things in GMod might not be easily available in SFM. I will try my best, but may ask for help for finding textures, models, and maps.
  • I'm unfamiliar with maps and currently don't have many options, so map recommendations would be great.
  • You can reupload your requests.
  • Please understand that I might be busy with many things, including work, projects, or other requests.

What kind of requests can I take? Splatoon-related, of course. I like the idea of recreating old GMod scenes into SFM. I also like the idea of creating animations for existing comics. Otherwise, just a simple character in a simple pose is okay as well.

I guess I can do NSFW requests as well, but please no nudity at least. I can decide not to do it for whatever reason, too.



I'm probably going to regret that later.
Join the community to add your comment. Already a deviant? Log In
I can't achieve a rendering effect in SFM, but I can't import a whole SFM session into Blender (from what I've tested) to try out the rendering effects I have in mind. I'm very unfamiliar with Blender, too.
Do I restart? Do I give up? Or do I make things complicated?

Help by Tomato127
Reading data from the session files is actually pretty straight-forward, but what do I do with that? Create a mini-SFM? I should probably look into post-processing filters instead.






Or draw.




I don't actually work like this, though a bigger monitor would be nice to have.
Join the community to add your comment. Already a deviant? Log In
Featured

SFM/GMod Porting Tutorial Part 2 (Textures) by Tomato127, journal

SFM/GMod Porting Tutorial Part 1 (Models) by Tomato127, journal

2-year Splativersary Reminisce by Tomato127, journal

Requests Announcement! by Tomato127, journal

What am I up to. No, really, what. by Tomato127, journal