General info
MATSpider is a material editor for Lightflow created by Takeshi Maeda. If you ever tried it out, you might have found it a bit hard to use, and the documentation might not have helped you much, so we are going to create a simple material to get to know some of the features of both MATSpider and Lightflow materials & patterns, as well as learn how to best use it with the script.
First, MATSpiderLF is not perfect, there are quite a few bugs, ranging from spelling errors in parameter names to buttons not functioning properly. And as Lightflow itself also has it's problems, this can cause some annoying things to happen. At times I had to manually reboot my system after I got the infamous 'blue screen of death'. So basically MATSpider might not turn out to be very useful, but then at least it is a reasonable learning tool to get to know Lightflow's material/pattern system.
One thing to remember is that Lightflow patterns sometimes need uv-coordinates (like the 'checker' pattern), so make sure if you don't see the pattern you expect to see on your meshes, try clicking the 'Make' button next to 'TexFace' in the editbutton section of Blender, or go into face-select mode by pressing the F-key and exit again.
A basic wood pattern
Anyway let's start. A good basic material to start with is something like a 'wood' type material. I know, not very 'Lightflowish', since everybody wants to do metal and glass, but the woodmaterial uses some of the most useful parameters that will come in handy when you create others yourself, these parameters have some similarities to the Blender material/texturing system as well, so that might make them easier to understand too. For other materials, there are plenty of examples to learn from, both in the LF examples folder and the MATSpider examples as well. After you did this tutorial, it might be a good excercise to recreate some of the Lightflow examples.
Startup MATSpiderLF, you should get an already opened window called 'Untitled-1' ready to create a new material. In case you don't, select 'New' from the 'File' menu.
Lightflow matererials consist of the actual material, which define things like specularity, reflection, refraction, plus any number of 'patterns', which can be used to vary almost every aspect of the material parameters like diffuse/specular/reflection/refraction Color, Reflectivity, Displacement/Bump-mapping etc...
Let's start with the wood pattern itself. At the top of the main MATSpider window is a toolbar where you can select all patterns and material types as well as some other things. Select the 'Pattern5(s-w)' tab, click on 'wood'. Now move your mouse cursor to the 'Untitled-1' window (you might want to maximize it) and click anywhere you want.
A new window opens.
A description of all marked items in the picture to the right:
At the top of the window you see a small triangle (6), if you click that, the window will expand so that sliders will be available to more easily change the values of the parameters. Here we meet the first bug. These sliders only go from 0 to 1, not all parameters have that range, so sometimes you still need to type new values into the rightmost column. |
![]() |
So, lets start with the wood color. Lightflow patterns use a system similar to Blender's colorbands, you define a series of colors defined over a range from 0 to 1 which Lightflow uses to smoothly blend from one color to the next. The 'X' parameter determines where this color is positioned in the 'colorband', similar to Blender's colorband 'pos' parameter.
We will start our first color at the position 0, so either click the slider next to 'X" and move it all to way to the the left, or click in the rightmost column after 'X', where it now says '(float)' (the type of the parameter) and type 0 and then the enterkey.
IMPORTANT: The parameters don't take effect until you move the cursor out of the box, either by clicking elsewhere on the screen or by using the enterkey, up/down cursor keys, tab key etc...
Now there are two color values you can specify ,'left' and
'right'. This is going to be a bit confusing, so you probably
have to read this a few times. These two values determine what
color Lightflow uses based on what side the number is on
Lightflow is currently using for it's calculation. If the 'X'
parameter is set to 0.5 for instance, and the current value
Lightflow is using to determine what the color should be is
0.123, then Lightflow will use the 'left' color since 0.123 is to
the LEFT of 0.5 (less than 0.5). Similarly when the current
Lightflow value is something like 0.753, then Lightflow will use
the 'right' color, since 0.753 is to the RIGHT of 0.5 (greater
than 0.5).
Now that you know that, forget about it again (phew!), since we
are not interested in abruptly switching colors, we want them to
smoothly change from one to the next. To do that, you simply use
the SAME color for BOTH 'left' and 'right', and ADD more color
blocks to the pattern. So to complete the analogy to Blender's
ColorBand, consider each color block to be a single entry in the
'colorband'.
For the wood I think it would be a good idea to start with a
dark color (the wood grain) going to a lighter color. To make it
look better we will add another color that is the same as the
first, ie. it is CYCLIC, so the color will change smoothly from
dark to light and back to the same dark color again.
What these colors are set to is completely up to you of course, but for this example, set both the 'left' and 'right' color to: 0.0941 0.0627 0.1569 Just type it in as it is written there, the number followed by a space followed by the next number, don't forget to use the enter or up/down cursor keys! Once you did the first, you can simply copy & paste the same value's to the second box (copy: CTRL-C, paste: CTRL-V). This is the first dark color which starts at the value (position) 0. |
![]() |
Now we need to add another two colors, there are no more colors available, so we need to add them ourselves. To do that, click the 'PARAMETER' button (3). This will open another window where you can add new material/pattern parameters.
From this window you can add, remove & duplicate
parameters, as well as move them around in the list with the
arrow buttons. Not all parameters can be removed, only the ones
that are colored pink (parameters that you added), all others are
default parameters that cannot be removed. You can delete
parameters with the 'Delete' button, it will be disabled when the
parameter cannot be deleted (default parameters).
Click on the 'color' parameter, now click on 'Duplicate'. This
will create a copy of the color block, now click again on
'color', either one is fine, and click 'Duplicate' again. Then
close the window by clicking 'OK'. You will now have two extra copies of the color block. |
![]() |
Now we have three times the same color. We will change the
second (middle) color to the light colour of the wood, to keep
things simple we will make this colour start at the 'X' value
0.5, so the middle position of the 'colorband'. Click the
rightmost column next to 'X' and type 0.5 or use to the slider to
set it to 0.5. Then the color itself, again you can set this to
anything you like, but for this example use: 0.7373 0.6118 0.3765 Again, just type it in as written, or use the sliders to create any color you like better. Since we wanted to have a color going from the dark color to the light color and back to the dark color again, we don't need to change the third color since it is a copy of the first, exactly what we wanted. The only thing we need to change is the 'X' value, which, since it is the last color, we will set to 1.0. |
![]() |
So now we have a dark color starting at 0, changing into the
light color at the position 0.5, and then changing back again
into the dark colour when the value is 1.0 This is exactly the same as if you would have created the colorband in Blender you see here to the right. |
![]() |
You can now try the first test render to see what it looks
like. Press the 'RENDER' button(1) and MATSpider will render a
sphere with the current pattern. It is a bit unfortunate that
MATSpider only uses spheres to preview the pattern, which makes
it a bit hard to see the pattern sometimes, but it will have to
do.
Since we didn't complete the pattern yet, Lightflow will use
default values for some of the other parameters. Like in Blender,
we can scale the pattern with the 'scale' parameter and we also
can add some turbulence to the colour to add a bit more (or less)
'chaos'. A good value for 'scale' is around 0.15, and a good
value for 'turbulence.amount' is somewhere from 0.1 to 0.3, I
used 0.2
You can also adjust the 'turbulence.octaves' if you want, but
that is not really necessary.
These are all the parameters we need for now. Later I will tell
you how you can change things so you can use Blender materials to
control the pattern without editing every time in MATSpider.
This will be our basic wood pattern, you can use this for any material parameter that accepts a pattern, obviously we are going to use it for colour mapping. It is good practice to give your patterns and materials a descriptive name, this will make it easier to edit if you would want to do that later. To do that, right-click on the pattern window, select 'Name as..', type 'woodpattern' or any other name you like, and click 'OK'.
The Material
Now let's add the actual material, click the 'Material' tab at the top of the window, and select 'generic', this is a good all-purpose material with lots of parameters. Click somewhere in the main window area and move things around as you like. Click-hold-drag on the pattern/material window sidebar to move it around, click-hold-drag anywhere in the main window area to move the view around. You might have noticed and probably already used that tiny window which has a smaller representation of the main work area, you can click in the square and drag to move around, or just click anywhere in the window to immediately change the view.
So, now we have the main material window. All those K-something parameters probably look quite confusing, you can make MATSpider display a bit more meaningful parameter names by selecting 'Detail of parameter' in the 'View' menu.
The wood pattern is going to be used for the 'diffuse' color
channel. Lightflow always needs a base color to 'modulate'
(multiply) the pattern with, so if you use a pattern to affect
some color (diffuse, ambient, reflection/refraction, specular),
the parameter will be used two times, the basic color and the
pattern itself.
The base color will act as a filter, so if the base color was set
to pure red, it doesn't matter if the pattern you used outputs
all colors of the rainbow, since these will be filtered out.
Since we want the pattern colour to be unaffected we will make
the base diffuse color white. The parameter we need is called
either 'Kd' or, in case you used the 'detail of parameter'
option, 'diffuse reflection'. Since the color white has the value
one for red, green and blue, MATSpider allows you to make a
shortcut by specifying the value only once. So type the value '1'
to the right of the FIRST ' diffuse reflection' parameter, use
enter/cursor-keys or click somewhere else and MATSpider will
complete the rest to make it 1.0 1.0 1.0.
Of course you can use the color sliders too if you prefer.
Now we need to connect the output of the woodpattern to the
'diffuse reflection' parameter right below it. Click on the
little white square at the top of the pattern window(4) (mouse
cursor changes to cross), hold and drag the line to the SECOND
'diffuse reflection' parameter (mouse cursor changes to pointer
with white square). Simply let go of the mouse button over the
parameter box.
WARNING: Make sure that the cursor is not active in the input channel
by clicking anywhere else before you try to connect the pattern,
otherwise the connection will fail.
![]() |
![]() |
The pattern is connected to the 'diffuse reflection' parameter. | The resulting material preview |
This is all that is really needed, all the default settings
for the other parameters are good enough for now. Try another
testrender by clicking 'RENDER' again. This would basically be
good enough to use as a material, or use it as a basis for
further experiments, so you might want to save it at this
point.
The script can only import MATSpider materials that are saved as
'Library', most of the MATSpider examples are library materials,
you can see them all represented in the icon window to the right.
A similar window can be used with the script, where you can click
any of the icons to edit the material in MATSpider.
To be able to save it as a Library, you need to connect an
output pin to the output of the material, this is nothing more
than a box where you can assign another name to the material.
Go the the 'Pin' tab at the top of the window and select 'output', click anywhere to the left of the wood material, then right-click on the output pin to assign a good name to it, and finally drag a line from the material output to the pin input. You can now save the material by selecting 'Save as Library' in the 'File' menu, then click 'OK'. As soon as you do that you will see a new icon in the material pallete window appear, whenever you want to edit it, you only need to double-click, or choose 'Edit' from the popup menu when selecting with the right mouse button. |
![]() |
You might want to save your material in it's own directory, you can do that by right clicking on the palette window, choose 'Create sub-folder', then type a name for the new directory and click 'OK'.When you then save the material you can select the new directory name from 'Folder Name'.
An extra displacement pattern
So let's try to make a more complex example using this
material to work from. I was asked if I could make something
resembling cedar wood shingles, I don't think I quite succeeded
(probably because I didn't try hard enough) but it is a good
enough example to duplicate here. Lightflow happens to have a
pattern called 'shingles', might as well try to use that.
Click on the 'Pattern5(s-w)' tab again, select 'shingles', then
click somewhere to the right of the material window. We are going
to use this for displacement mapping. Name the pattern (or not,
your choice) and connect the output of this pattern to the input
box of the 'displacement' parameter.
WARNING: The 'shingles' pattern is one of those pattern types that NEEDS UV-COORDINATES, so make sure when you use this with the script that your mesh has uv-coordinates, otherwise nothing will show.
You could try another test render, but you won't see any difference yet. This time we don't need to specify colors but 'depth' values, these control the displacement output. The same principles apply as with the colors however, you specify a number of values which Lightflow will use to smoothly blend from one value to the next, just like the colors. We also need an extra depth parameter, the current window has only one. To add another, just do the same as for the colors. Click the 'Parameter' button(3), then select the depth parameter and select 'Duplicate' again, click 'OK'.
We now have two depth parameters, let's start with setting these to 0 and 1 respectively so we can try out the pattern to see what it looks like. Set the first one to 0 for 'X' (remember this is like Blender's colorband position parameter, even though we are not using colors here). Now we also need to set both the 'left' and 'right' parameters to 0. Then to the same for the second depth parameter, setting all to 1.
You could visualize this like a bumpmap, dark (value 0) is a 'valley', light (value 1) is a 'hill', and anything in-between blends smoothly from one to the next, so going from 0 to 1 is like going uphill and going from 0 to 1 is like going downhill so to speak.
We need one more parameter before anything will happen in the render, and that is the scale parameter. A good value for MATSpider's testsphere is around 0.05
Now it would be a good idea to make the preview window a bit larger so you can clearly see the effect, then click the 'RENDER' button in the material window again.
This time it will take a bit longer to render, Lightflow has
to do a lot more calculations for the displacement. The result
looks ok, but not really what we want yet.
The shingle bumps are going 'downhill' too fast, producing a jagged sawtooth type look when viewed from the side. |
![]() |
The shingles pattern should be flatter with the indentations being more close together. To do that, all we need to do is move the 'hill' closer to the 'valley', or in other words, set the second depth parameter postion closer to 0. Try lowering the 'X' value for the second depth parameter in steps, going from 1 to 0.75 to 0.5 to 0.25 and doing some testrenders so you can clearly see the effect. I chose a value of 0.1, but maybe you find another setting you like better. | ![]() The final pattern settings |
![]() The result |
For more irregular patterns, try playing with the 'shingles' pattern 'turbulence' and 'variation' parameters.
Well, that's it, personally I don't think it is really usefull as it is now, but at least it was a good learning example, I hope...
If you want to know more about the actual Lightflow material/patterns/parameters, you can browse the Lightflow documentation from MATSpider by right-clicking on the material/pattern and selecting "Show SDK..."
NOTE: Lightflow actually cannot do displacement mapping on
polygonal meshes, it will revert to regular bumpmapping instead.
The only way to do real displacement mappping using the script is
to use Blender nurbs/surfaces using the 'Import from blendfile'
option.
Another possiblity, but doesn't really work well, is to use a
simple mesh (NOT a complex one, only a few triangles/quads at
most) and adding the extension '_SURF' to the object name. Before
the rendering is started, the render script will try to decompose
the mesh in Lightflow 'patches' and triangles which can be used
to do real displacement mapping with, but this has the
disadvantage that the polygons will likely be pushed apart at the
seams, since they are not really connected, just separate
polygons. The surface export option definitely looks much better,
since by definition this is a smooth mathematical surface without
polygons (strictly speaking, this is not true for the rendering
process, but never mind that..).
If you want to use the displacement map as a bumpmap (maybe
because it renders faster or the object is far enough from the
camera that it wouldn't look any different), you can't just
connect the 'shingles' pattern to the material 'bump' parameter.
You will have to 'transform' the displacement map to a bumpmap
first. Disconnect the 'displacement' parameter by clicking in the
'displacement' parameter box and pressing the delete key, don't
forget to use the enter-key or click somewhere else before you
try to connect another pattern.
Now go the the 'Pattern1(a-c)' tab and select 'bump', put it
somewhere between the shingles pattern and the material. Now all
you need to do is connect the shingles pattern output to the
input of the bump pattern, and then the bump pattern output to
the 'bump' parameter input of the material.
The bumpmap will then render properly as it should.
In case you would ever want to do the reverse, ie. use a bumpmap as a displacement map, the pattern you would want to use would be, you guessed it, the 'displacement' pattern. This you might want to use with image textures for example. You can control how the displacement is interpreted with the 'type' parameter, which has several options. Here we find another MATSpider bug, one of the options is 'color-as-perturbation', which is misspelled 'color-as-perturvation' in MATSpider, this will produce a Lightflow error when you try to use this. You have two options, one is to simply edit the output, or you can also add a parameter with the same name of type 'string' and you specify the parameter yourself, but this can be a bit unreliable.
Now, we have used 'depth' and color', but what use is that 'value' parameter? Well, that happens to be exactly the actual parameter that is used to calculate the blending of other patterns. One pattern you would use this for is the 'gradient' pattern, this blends two patterns/colors/values, using the 'value' of another pattern. This allows endless combinations and chains of patterns to create extremely complicated materials.
Blender takes control
Okay, now you have a simple material to be used with the
script. There is one disadvantage however, every time you use
this material, it will always have the same settings, it would be
nice if you could somehow control some parameters from Blender.
You can in fact do this, although it might appear a bit
complicated, it almost looks like ...like ... *gasp*
...programming... (OH NO!!!!)
It is not as scary as it sounds (or maybe it is?), and it has the
advantage that you can use it in animations too, since IPO's can
be used as well.
Actually, if all you want to do is control things like
location/rotation/scaling of the texture, then you can do that
using a similar method as you would use in Blender, using Empty's
(or in fact any other object). The only thing you need to do is
to name the Empty (or object) as follows: the MATSpider material
name plus the extension '_TEXC', so if the MATSpider material is
called 'wood' the name of the Empty (or object) should be
'wood_TEXC'. The texture will then be moving/rotating/scaling
along with the empty (or object).
However, this will happen for ALL objects that use that material,
if you want to control only the texture for a specific object
then you use the name of the object instead, followed by '_TEXC'
again. So if you want to control the material/texture of a object
called 'Sphere' then the name of the Empty (or object) should be
'Sphere_TEXC'.
This might be (complicated) enough for most, but you can't control actual material parameters though, what about colors for instance?
Well, the system I created to do that is based on the fact that you can use 'pins' in MATSpider attached to any parameter, these then set the actual value in the material/pattern. By using a special name for the pin's (again), the script will replace the values by any Blender material parameter value you want to use instead.
All you need to do is connect a pin that has the same type as
the parameter you want to control and rename it. The only thing
that changes is that you now specify any values for these
parameters with the pins value.
NOTE: When using
some of the MATSpider examples, the script might warn you that
there are comments in the python script which will generate an
error if you run the script without editing it first. These are
caused by some of the pins used for that material don't have
values assigned to them. The comment will be something like this:
<Plese write 'X' type parameter here> where 'X' is the type
of the parameter that should be assigned.
There are two 'types' of Blender variables you can use, first, most of the material parameters themselves, and second, ones that can be accessed only using an IPO. The python API of Blender still doesn't allow full access to all material parameters, some of these unaccesable parameters are available indirectly through the use of an IPO however.
Now let's try to to 'implement' this using the woodmaterial
(wow, that sounds so exciting!!..yAwN!!....zzzz ...ZZZZ...).
...hmm, wel, okay, let's continue for those who didn't fall
asleep...
The parameters that would benefit the most from being editable from Blender would be color and the 'shingles' scale value.
Starting with the color, click the 'pin' tab at the top of
the window, select 'vector3', all Lightflow color parameters use
this variable type. Now place this to the left of the wood
pattern, we are going to connect this to both the first and the
third color, since these are the same. First delete the color
value's by clicking on the value and using the delete key, make
use to click somewhere else after you did this, so the cursor is
not active. Now connect the output of the pin to the 'left'
color' and then another to the 'right' color. Then do the same
for the third color, delete the values, then connect the pin to
both the 'left' and 'right' parameters. The most obvious Blender parameter to use for this would be the base RGB color, all you have to do is right-click on the pin, select 'Name as...', then type BLEND_COLOR_RGB Now create another 'vector3' pin, this is going to be used to set the middle color, do the exact same thing again, delete the color value's of the middle color parameter, then connect the pin to both 'left' and 'right' of the middle color. A good choice for the Blender parameter to use with this would be the mirror color sliders, so this time rename the pin to: BLEND_COLOR_MIR_RGB Now you can put back the value's you used before for the color's, click on the right part of the BLEND_COLOR_RGB pin (box next to the 'default'), and type as before: 0.0941 0.0627 0.1569, then do the same for the BLEND_COLOR_MIR_RGB pin, again as before (the middle color): 0.7373 0.6118 0.3765 |
|
Then the displacement 'scale' parameter, there is no really
immediately obvious Blender parameter that would make sense to
use for this. Well, there are, the texture 'Size' parameters
maybe, but these can only be used with a material IPO, so instead
we are going to use another one, the Blender 'Amb' parameter,
most people probably never even used that, I don't want a Blender
parameter to feel neglected however, so let's use this for the
scale parameter. Delete the value you typed in previously, as you can see after you delete the value, it is replaced with '(float)', this is the type of the parameter, and you should therefore use a 'float' pin this time. Place to the right of the displacement pattern and connect the output of the pin to the input of the 'scale' parameter. Rename the pin as: BLEND_AMB. |
|
That's it...
Whenever you now import the material from Blender, the Blender material RGB color will be used to replace the wood dark color, the mirror color will be used to replace the light wood color, and the 'Amb' slider can be used to scale the 'shingles' pattern.
Of course you can do lots more complicated stuff this way, just try and experiment (like anyone is ever going to use this..)
And finally, here is a list of all Blender material variable names you can use:
And these are the extra parameters you can use when the material has an IPO:
There is one other variable which does not belong to any parameter, and that is BLEND_TIME, which is the current Blender frame-time. One of the Lightflow patterns actually has a time parameter: Smoke, so I suppose it might be useful for that, but you can of course use it anywhere else you want.
Of course nobody is going to use it, I have the feeling I probably wasted my time implementing all of this...Does anybody actually read this? Hello?? echo..
Oh well, hope it is a bit useful to somebody...