Difference between revisions of "Using stencils"

(To wrap up)
(Using Blenders texture blend types)
Line 53: Line 53:
  
 
As I mentioned above I used a small gradient image. Blender is actually capable of creating this image for you and several others to. For all textures mentioned I used the "image" option to load them into my materials. You have probably scanned the other options in the Texture Type dropdown. One of them is called "blend". And not for nothing ;) Selecting this option brings you several blend types to choose from. The images below show some of them, including a simple lineair blend, similar to what I used.
 
As I mentioned above I used a small gradient image. Blender is actually capable of creating this image for you and several others to. For all textures mentioned I used the "image" option to load them into my materials. You have probably scanned the other options in the Texture Type dropdown. One of them is called "blend". And not for nothing ;) Selecting this option brings you several blend types to choose from. The images below show some of them, including a simple lineair blend, similar to what I used.
 +
  
 
The PRP plugin can handle all of these blend types and will create the necessary 64x64 mipmaps to be used in Plasma. So, while was stubborn enough to make my own alpha mask, I could have used this one instead.
 
The PRP plugin can handle all of these blend types and will create the necessary 64x64 mipmaps to be used in Plasma. So, while was stubborn enough to make my own alpha mask, I could have used this one instead.
 +
  
 
'''Lineair blend''' (the quad and ease types are lineair too, but with a looser or tighter gradient.
 
'''Lineair blend''' (the quad and ease types are lineair too, but with a looser or tighter gradient.

Revision as of 11:44, 20 January 2008

NOTE: The features in this tutorial need gow-pyprp version 1.1.0 or higher.

Welcome to the first installment of a series of Blender stencil tutorials. In this first tutorial we’ll do some basic, straightforward blending using a simple model and a gradient alpha map. At the end I will enhance the things we did to show you another use of stencils. In the second part I intend to show how Cyan uses stenciling to blend terrain. But let me explain the principles of stencils first.

Actually it’s pretty simple. What a blender stencil does is use a black-and-white or alpha image to decide which part of a texture to show and which to hide. By combining two textures seperated by a stencil you can have parts of both appear at will. Have a look at the stack of textures below for instance and the effect of the stencil image on the end result:

Stencil example.jpg

I bet you don’t need much imagination to see the implications of this being available to us in the plugin. Cyan uses stencils a lot to do simple blends between terrain textures. If you’ve ever studied Relto and the way blends are done there, then you know what I’m talking about. I must admit that I haven't found many other uses of stencils in Cyan's ages. Most of their textures are stunning in their own right. More on


Starting with a simple model

Okay, here is our model (I have a copy of Yeesha as an import file to check dimensions). The model already has its bounds set, and I already have a link in point in place. I also set the default background color in the .fni file to blue. I said it was a simple model didn’t I ;) ?

Stencil model.jpg

What I want to do is have a patch of grass on one side and stone on the other. I assume you know how to do UV mapping, so I will skip that part. Later on however I will show you how to use more UV maps on one model. For our little exercise I use one UV map for all layers we'll be using. The default UV map is called UVTex. Since our little patch of terrain is flat I simply choose Project from view to unwrap. I admit, my little age won't be the prettiest. I will be using the following textures:

Stencil tex 01.jpg

Notice that I use a very small alpha blend image. Since there isn't much detail in it, there is no point in making it to big. This is actually the actual size, while I downsized the other textures for this tutorial. After adding it to the material it looks like this:

Stencil setting stencil mat.jpg

Now have a look at the settings for each texture layer. There is nothing new to the settings of the actual textures (grass and stone). You can use the settings you are used to here. The real magic is performed by the middle layer, the AlphaBlend layer.

So here are the settings in Blender. First the grass texture. I won't show the stone texture here, since the settings are the same:

Stencil setting tex.jpg

Settings for the stencil layer:

Stencil setting stencil.jpg

Three important things here:

1. Deselect the "col" button

2. Select the "Stencil" button (you must have seen this coming ;) )

3. Select the "No RGB" button

If you are using one of Blenders (procedural) textures as a stencil (for instance the blend textures) then the No RGB button can be left alone.

Hopefully we are lucky and the material preview window confirms all settings are correct. And yes! I'm a happy camper today :D

Stencil tex prev.jpg


Using Blenders texture blend types

As I mentioned above I used a small gradient image. Blender is actually capable of creating this image for you and several others to. For all textures mentioned I used the "image" option to load them into my materials. You have probably scanned the other options in the Texture Type dropdown. One of them is called "blend". And not for nothing ;) Selecting this option brings you several blend types to choose from. The images below show some of them, including a simple lineair blend, similar to what I used.


The PRP plugin can handle all of these blend types and will create the necessary 64x64 mipmaps to be used in Plasma. So, while was stubborn enough to make my own alpha mask, I could have used this one instead.


Lineair blend (the quad and ease types are lineair too, but with a looser or tighter gradient.

Stencil alpha blendline.jpg

Circular blend (the halo type is also a circular blend but smaller)

Stencil alpha blendcirc.jpg

Diagonal blend

Stencil alpha blenddiag.jpg

Okay, let's not forget what we were doing before this intermezzo and head back to see if our stencil actually works.

Let's check how Plasma is doing

Export your age and pay it a little visit! Have a look at the picture below and you will see that we did all right. Since I didn't tile the alpha image or use it only on a smaller part of the model, the result looks a bit crude. But you get the picture.

Stencil Plasma 01.jpg

To show you one of the many uses of stenciling, look what happens if I change the basic linear blend stencil to something (only a little) more exciting:

Stencil Plasma 02.jpg

The map I used looks like this:

Stencil tex 01b.jpg

There are many tutorials online showing how to use these kinda stencils to do some cool blending of large terrains. Maybe you are using black and white height maps to create terrains in Blender. In that case you could use the same maps to assign textures based on height giving it a natural look. You won't see this type of texture blending in Cyans ages however. In many cases they use small linear alpha maps to blend textures.

Another use of stencils

To make our age a little more DRC proof I've decided to put a wall at one end (let's not talk about the dangers on the other three sides). Just for cosmetics I changed the tiling of the grass a bit giving it it's own UV map. What I want to show you is a way to make the tiling of textures less obvious.

We all know that we have to stay away from patterns that are obviously repetitive. But then again... details make textures so much more interesting. A way to add detail is to combine textures and give them another "rythm". Layering textures that are both 512 pixels wide using the same UV map will make the details appear at the same place each time, resulting in repetitiveness. But if one of the layered textures is stretched to for instance 140%, then the repetition will occure less.

I will show this principle on our newly erected wall. Again I use three layers. This time the stencil is a drippy kinda map, intended to mask a rust texture. The effect I'm after is to have some rusty patches at the top of the wall. Have a look at the textures we will use here.

Stencil tex 02.jpg

As I said in the beginning (but you probably already know this), it's possible now in Blender to use several UV maps within one material. This comes in handy especially when using stencils and even more if you want to combat repetitiveness. Just to make sure you know what I'm talking about I included the image below. If you have a look at the bottom right corner, than you will notice three UV maps: Wall, Rust and AlphaRust. A new UV map within the same material will be created by clicking "New" to the right of "UV Texture". Use the buttons to the left of for instance "Wall" to respectively use (or change) the map itself and to show the texture in 3D view.

Stencil setting stencil2 uv.jpg

To actually use the maps you created, be sure to assign them to the different textures that make up this particular material:

Stencil setting stencil2 uv2.jpg

What I did is give the rust mask stencil layer a different UV map and stretch it a bit. By doing so I created a different rythm for this particular pattern.

And here is the end result. Ok, I know, it can be done much better, but to show how this technique can be used effectively this should do. I did add a little vertex painting for "dramatic" effect ;)

Stencil Plasma 03.jpg

Stencil Plasma 04.jpg

To wrap up

I have not seen many uses of stencils in Cyans ages. They mainly use this technique to do straight forward lineair blends. I don't know why they don't make use of it more. In most cases I think they manage to design textures that are so incredible that in the end they get away with them without us being distracted by their repetiveness. Which maybe a good lesson here too: stencils give a whole new range of posibilities, but always think about other, maybe more (CPU) efficient, options too.


Ok, that's it! I hope you are ready to use stencils in your own ages and manage to fine some cool applications for them. Please let me know what you came up with. Maybe we can dedicate another tutorial on your ideas.

In the next installment I will show some simple uses of stencils in Cyans ages, which will give you an alternative to the use of vertex painting.


Marcello