Torchlight Material Guide

This article is an Island. It cannot be linked to using wiki BB-codes.
It seems this is rather unexplored territory. Which is a shame because they're easy to work with and there's a lot of cool things you can do just by editing the material file.
The goal of this guide is to provide some practical examples of basic elements, which you can then use to string together something wondrous.
(TL2 uses the same graphics engine (OGRE) so this guide should still be relevant when it releases.)

[top]File Breakdown

Code:
material generic_material
{
technique
{
pass
{
ambient R G B [A]
diffuse R G B [A]
specular R G B [A] (Intensity)
emissive R G B [A]
[pass functions]
texture_unit
{
texture texture.png
[texture functions]
}
}
}
}
In the simplest terms
Diffuse is the colour of the material.
Ambient is the colour of the shadows.
Specular is the colour of direct light.
Emissive is the materials own light.

RGBA values can range from 0 - 1 and specular intesity can be anything above 0 (although it's rarely used.)

Generally in Torchlight the 'ambient' and 'diffuse' have the same settings, while 'specular' is set to 0.
This helps keep the hand-drawn cartoon look. But I'll show you how to break that :P

[top]Colour Settings

[top]Emissive

The materials inherent brightness. Setting this to high values will make your model glow even when it's in the shadows.
Left to right, the ambient & diffuse are 0.25, 0.5, 0.75
Going down the emissive is 0, 0.25, 0.5, 0.75

[top]Recolouring

By messing around with the rgb settings you can make your material a different colour to how you drew it.

For this example ambient & diffuse have been set the same.

You'll get more precise results by recolouring them manually, but it's useful if you just want to give it a tint, or that blue didn't come up quite as brilliantly as you wanted.

[top]Lighting

By setting the ambient and diffuse differently you can get some hard lighting effects.


While you could try messing around with the specular settings, I can't think of an example in torchlight that does.
Note: If you make them too different from each other your model will start looking out of place.

[top]PASS FUNCTIONS

[top]Alpha Blend

This is probably the most commonly used pass function, (which is why it's going first.)
With it you can use the skin to 'cut out' parts of the mesh. It's often used for hair/spikey bits.
Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.588 0.588 0.588
diffuse 0.588 0.588 0.588
specular 0 0 0 0
emissive 0 0 0
scene_blend alpha_blend
alpha_rejection greater 255
texture_unit
{
texture 2handers_12_alpha.png
}
}
}
}
There's 2 parts that make this

scene_blend alpha_blend
This tells torchlight to apply the textures alpha values to the mesh

alpha_rejection greater [0-255]
This sets a cutoff point for the alpha
0 = the alpha shows up exactly how you made it
255 = any part with alpha is completely invisible

The easiest way to demonstrate how it works is by applying the alpha in a gradient (from black to white)

[top]Transparent Items

You want transparent weapons but don't want to mess around with alpha channels?
There's 2 ways you can do this
scene_blend add: Which lightens things behind the mesh.
Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.588 0.588 0.588
diffuse 0.588 0.588 0.588
specular 0 0 0 0
emissive 0 0 0
scene_blend add
texture_unit
{
texture 2handers_12.png
}
}
}
}
scene_blend modulate: Which darkens things behind the mesh.
If you go this way you'll also want to raise the emissive to high values, as it'll get lost in any shadowy areas.
Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.588 0.588 0.588
diffuse 0.588 0.588 0.588
specular 0 0 0 0
emissive 0.8 0.8 0.8
scene_blend modulate
texture_unit
{
texture 2handers_12.png
}
}
}
}
Both ways are entirely valid, it just depends on what look you're going for.
i.e. If you wanted a sword from the nether-realm, modulate would be the better choice.

*note: These screenshots don't really do it justice as there's nothing behind them.

You can couple this with recolouring for some nice spectral effects.

Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.188 0.988 0.688
diffuse 0.188 0.988 0.688
specular 0 0 0 0
emissive 0 0.2 0.1
scene_blend add
texture_unit
{
texture 2handers_12.png
}
}
}
}

[top]Texture Functions

[top]Texture blending

There's 4 general options for how the texture interacts with the material
colour_op add
colour_op modulate
colour_op alpha_blend
colour_op replace
add, modulate and alpha_blend are all the same as their 'scene_blend' counterparts
replace does exactly what it suggests. It ignores the material settings and replaces them with the colours from the texture.
These really only start being useful when you're working with dual layers.

[top]Animations

scroll_anim x y
Scrolls the texture at a fixed speed. I'm not entirely sure what the speed is.
I'm assuming 1 = the texture makes a full scroll every second.
In any case, follows the general 'lower is slower' rule.

rotate_anim [revs]
Rotates the texture anti-clockwise at a fixed speed. This is per second.

Both of these are difficult to take screenshot effectively, so I'm not even going to try :P

[top]Dual Layers, Multipasses & Glow Maps

Dual Layers and multiple passes are both possible, but difficult to show without making multiple textures.
So to demonstrate how they work, I'll be doing both with a simple glow map.

[top]Dual Layered

Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.588 0.588 0.588
diffuse 0.588 0.588 0.588
specular 0 0 0 0
emissive 0 0 0
texture_unit
{
texture 2handers_12.png
}
texture_unit
{
texture 2handers_12_illum.png
colour_op add
}
}
}
}

Because its using the same settings for both textures, there's only one possible result.

[top]Multipass

Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.588 0.588 0.588
diffuse 0.588 0.588 0.588
specular 0 0 0 0
emissive 0 0 0
texture_unit
{
texture 2handers_12.png
}
}
pass
{
ambient 0.588 0.588 0.588
diffuse 0.588 0.588 0.588
specular 0 0 0 0
emissive 0 0 0
scene_blend add
texture_unit
{
texture 2handers_12_illum.png
}
}
}
}

The initial result isn't quite as bright as the dual layered one, but because it has seperate settings you can fine tune it however you'd like

[top]Phase Blades

Now it's time to throw together a few of these techniques to make something even more awesome.
This one does require some small image editing, so load up the texture in your favourite image editor.

Mask out all the 'blade' areas, but don't delete them as we still want the information underneath.
(well you can delete it, you'll just need to save it as a new texture)

When you've finished with that, add an alpha blend to your material

Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.588 0.588 0.588
diffuse 0.588 0.588 0.588
specular 0 0 0 0
emissive 0 0 0
scene_blend alpha_blend
alpha_rejection greater 64
texture_unit
{
texture 2handers_12.png
}
}
}
}



Now we're going to add a new pass before that one, with a purple transparent blade.
Both passes are using the same texture, but because we haven't told the first one to do anything with the alpha channel the blade still shows up.
Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.9588 0.7588 0.8588
diffuse 0.9588 0.7588 0.8588
specular 0 0 0 0
emissive 0.8 0 0.8
scene_blend add
texture_unit
{
texture 2handers_12.png
}
}
pass
{
ambient 0.588 0.588 0.588
diffuse 0.588 0.588 0.588
specular 0 0 0 0
emissive 0 0 0
scene_blend alpha_blend
alpha_rejection greater 64
texture_unit
{
texture 2handers_12.png
}
}
}
}



I'm not quite happy with the handles colouring, so let's brighten it up a bit and give it a purple tint.
Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.9588 0.7588 0.8588
diffuse 0.9588 0.7588 0.8588
specular 0 0 0 0
emissive 0.8 0 0.8
scene_blend add
texture_unit
{
texture 2handers_12.png
}
}
pass
{
ambient 0.688 0.588 0.688
diffuse 0.688 0.588 0.688
specular 0 0 0 0
emissive 0.2 0.1 0.2
scene_blend alpha_blend
alpha_rejection greater 64
texture_unit
{
texture 2handers_12.png
}
}
}
}

Much better.


But wait... there's more. We're now going to add a new animated layer to the blade.
You can find a suitable texture in 'media\particles\Textures\Vein'
You'll probably need to play around with them in [insert your image editor of choice] a bit.
For this I'm using an edited version of vein22


Code:
material 2handers_12
{
technique
{
pass
{
ambient 0.9588 0.7588 0.8588
diffuse 0.9588 0.7588 0.8588
specular 0 0 0 0
emissive 0.8 0 0.8
scene_blend add
texture_unit
{
texture 2handers_12.png
}
texture_unit
{
texture energy_additive.png
scroll_anim -0.1 -0.02
colour_op modulate
}
}
pass
{
ambient 0.688 0.588 0.688
diffuse 0.688 0.588 0.688
specular 0 0 0 0
emissive 0.2 0.1 0.2
scene_blend alpha_blend
alpha_rejection greater 64
texture_unit
{
texture 2handers_12.png
}
}
}
}

This one's a lot harder to take a decent screenshot of. :P

Throw some particle effects on it in-game, and you've got yourself a pretty epic weapon.

This has barely even scratched the surface of what's possible, but is enough of a starting point to get you used to them. (Time permitting, I'll continue updating this guide.)

Posting Permissions

Posting Permissions

  • You may not post new pages
  • You may not post comments
  • You may not post attachments
  • You may not edit your posts
  •