Tuesday, April 26, 2011

Making clothes - A tank top, part 1

Hi everyone!

I mentioned in one of the Second Life Forums (Fora?)  that I would try to give a simple example of how to create clothes in Second Life.  And, in particular, show how to make smooth 'cuts' using Paths (Bezier Curves) and how to avoid the Dreaded Jaggies using the Gaussian Blur.

I've decided that the way to do it is to step back first and talk about Paths, aka bezier curves and how one works with them, and thinks about them with GIMP.  So what I will do here is create a simple Path in GIMP and show you what is possible.  If you want to do some reading on the math behind this you can google Bezier Curves.  If you'd like to get a 'hands on' feeling of what we'll be doing go here:


Give it a little time to load into your browser and then use the handles and move the end-points to play with the Bezier Curve it provides.

If you're jumping into this without the preceding posts in this blog, I'd suggest you take a look at the Tools, Credits and Caveats post found here:


It will tell you how to get the various tools you'll need, starting with GIMP (free!).

Ok.... now let's talk about clothes.....

There are two big problems with clothes.  The first is creating nice smooth 'cuts' in your clothing item.  And the second is avoiding the Dreaded Jaggies.  That's where a diagonal line looks more like a staircase than a nice smooth line.

In this post, we're going to deal with the first problem, how to create smooth 'cuts' in your 'fabric' as you make clothes.  The solution to this problem in GIMP is to use Paths, which are in fact, bezier curves.

Working with Paths is another of those things common in computers with graphical user interfaces that is easier to do than it is to explain.  I'd suggest reading through this post once.  Then reading through it a second time and try to do the examples yourself.  You'll wonder pretty quickly what all the fuss is about.  :)

Lets get started!

Step 1:  Open GIMP, create a new Image of 256x256 pixels.  Then find the Path Tool on the Tools window and create a coarse, first pass, unrefined Path.  Take a look at the path I've created below:

There are two things we're going to work on here:

  1. Connecting a curve to a straight line.
  2. Connecting a curve to a curve.
We'll start with the line segment in the lower left and leave it completely unchanged so it can be our straight line segment.  The second line segment then will be the one that connects to both a straight line (the first line segment) and a curved line (the third line segment).

So.... the thing we need to do is to grab the second segment in the middle and drag it.  Use your mouse, place the pointer over the middle of the second segment, press the left mouse button and hold it down as you drag the mouse as shown in the image below.

As you drag the segment you'll notice that two handles appear, one on each end.  Use the mouse to grab the lower handle and move it around.  What we want is a smooth connection between this second and the first line segment.  If you make the line that is attached to the handle look like it is a straight line extension of the first line segment, you'l have the smooth connection we want.

Looking at it from the second line segment's point of view, that line is tangent to the curve at the point it connects to the first line segment.  If the word 'tangent' makes you think that someone might be mispronouncing the name of a small orange-like fruit, dont worry.  There will NOT be a test.

Now take the second handle and drag it in the direction shown in the picture below.

The exact angle you drag the second handle to in the picture above is not particularly important. BUT!  The next step will be!!

Use the mouse to drag the third line segment from the middle as you did with the second to expose the handles.  And then take the left-most handle and make the line it connects to be straight when compared with the line on the second handle on the second segment.

Whew!  That's a lot of words to describe something pretty simple.  Look at the picture below.

Now let's pause and look at what we've done.....

We've connected the second line segment smoothly to a straight line on one end and connected it smoothly to a curved line on the other end.  Success!  We've achieved our goal!

Now we can repeat the process, working our way from line segment to line segment smoothly connecting and creating curves.  Be sure to leave the last line segment straight as we did with the first.  When you're done it will look like something like this.

Yay!  It looks pretty good doesn't it?

Go ahead now and play with it.  Move the points around.  Stretch the handles out so they're really long.  Experiment!  Play!

There's a handy trick you will want to know about.  If you place your mouse in the middle of a line segment and press 'ctrl' on the keyboard you'll see a very small + appear.  That + indicates that a new point will be added when you click the left mouse button.  Then you can move that point around as you've done with the others and play with it as well.

Oh, one more thing!  Go to the Layers window and click on Paths tab. (look at the image above)  You'll see a thing under that tab that looks a lot like a layer, but in fact it is the Path we have just created.   And yes, there are a lot of fun things we can do with these, almost as much fun as the things we can do with layers!  But we'll save that for a future post.  *winks*

On the next post we will use Paths to create a top.   I'm thinking of creating a nice tank top.  What do you think....?  Red?


Friday, April 1, 2011

Making a seamless tile - part two

Hi again!

We're going to make another pink flower tile this time, but much fancier. First, I'm sure you've noticed that flower petals are not really just one color, but instead they are delicate shades, merging from one color to another.  And flowers have that thing in the center, what is it called?  (Pistil and Stamen I think). Whatever it is, its often yellow and we'll make a yellow one for this flower.

We're going to go through the same steps as before with some additions.  I'm not going to repeat the detail from the previous post though.  Instead I'll try to focus on the new GIMP tricks in this post - hopefully you'll be able to put it together yourself.

Sooo.... First let's open GIMP, create a 64x64 canvas to work on like we did in the last post.  Here's what mine looks like... just 2 layers:

That's simple enough.

Now let's make the petals of the flower more interesting.   We're going to shrink the selection by 3 pixels and add a layer for the new size and fill it with a lighter shade of the pink we have above.  Then!  We'll do it again!  Shrink the selection by another 3 pixels, create a new transparent layer and put paint the lighter shade in that layer.  To shrink the selection use Select->Shrink and tell it you want it 3 pixels smaller.

Now if you look at that closely it looks a little ragged around the edges.  So we need to smooth it out.  We'll use something called Gaussian Blur on each layer to do that.  You'll find it in Filters->Blur->Gaussian.  I chose to blur by 2 pixels on the lower (biggest petals) layer and 3 pixels on the other two.  Choose what looks good to you though, your flower is likely different.  Here's my result:

That's much nicer!

Now we need the yellow center, the pistil/stamen.  This is pretty easy - just do what you did before to create the flower petals, but create a round area in the middle that you will paint yellow.  It doesn't have to be centered perfectly.  Heck it doesn't even have to be perfectly round.  Look at mine!

I went ahead did the blurring thing we did above.  Nice!  Isn't it?!

Oh, one thing I forgot to mention.  I also tinted the background layer pink and made it a little less bright.  You may want to do the same.

What we've been done so far is to create a fancier version of the rather cartoon-ish flower we had before.  Now I want to add some 'pop' to this.  Some 3-D effects.  We'll use something called Bump Map in a few minutes, but first we need to do a little preparation.   I'll detail the steps here so its easier to follow.

  1. Click the eye icon on the background layer so that it is no longer visible.
  2. Now make a copy of the large petal layer and click the eye icon to make it invisible.
  3. And make a coy of the large pistil/stamen layer and click the eye icon to make it in visible
  4. At this point you have the original layers visible, minus the background.....Now go to Image->Merge Visible Layers and all of the petal and pistil/stamen layers will be merged into one layer.  (If this makes you nervous, save the file before you do it).
Ok, now it should look something like this:

Note especially the Layers window.... four layers, one visible, our merged layer.  Now we're going to use the large petals layer and large pistil/stamen layer to create masks for the Bump Map.

First the petals layer.  Click on where the eye should be, making it visible.  Then select that layer, making it active and....

  1. Make the layer black and white with: Colors->Desaturate
  2. Then blur the layer rather severely.  Use Filters->Blur->Gaussian ..... I chose 8 pixels and that's probably a good number for you too.
  3. Finally you will want to brighten this - its very grey at the moment.  So choose Colors->Brightness-Contrast and adjust the two controls you see to the right.  I think for mine I moved both up to somewhere between 50 and 60.
  4. Click on the eye and make the layer invisible again.
Next make the pistil/stamen layer visible and active and repeat the above.

Now select the layer that is our merged flower.  Just check - it should be the only visible layer.  If it is not correct this now.  The Bump Map we're going to do next will actually make changes to the layer, so let's make a copy of this layer and work on the copy.   The new layer will now be selected and visible - that's good.

Now for the Bump Map.  We're going to do it twice, once for the petals and once for the pistil/stamen.

  1. Choose Filters->Map->Bump Map.  You will get a dialog window with many choices... The only one we need to look at is the first one that chooses the Bump Map to use.
  2. Click the pull down and select the large flower petal layer we had been working on above.
  3. Notice in the preview window that some subtle shading has appeared - this is exactly what we want.  Press OK.
Take a moment and notice what the Bump Map filter did.  It created a rather nice 3D look on your petals.  So now repeat the process again, except in step 2 choose the pistil/stamen layer we had been working on before.

In the end, you should see something like this:

Pretty nifty!  Isn't it?

Now, you could at this point do the same thing we did before....  Duplicate this layer, divide the duplicate in half vertically and horizontally....  Combine the two with the background layer and create your test tiling.  And there is really nothing wrong with that but we'll do something just a little fancier.  This creates a result where the upper of the split image and the lower part of the split image, both overlay the original.  Since we've added a kind of 3D-ness here though, I'd like to carry that into the end result and make it so there is a kind of interleaving.

To do this we'll create the duplicate, divided layer as before, but then we'l add a layer mask.  (New GIMP trick!) and use it to hide one half of the duplicate divided layer.  Then we'll duplicate that and reverse the layer mask and with some simple positioning of the layers we'll achieve our result.

Ok let's list the steps:

  1. Duplicate the layer and split is as we did in the previous post.
  2. Now right click that new layer and choose Add Layer Mask.  Make it a white layer when you are asked to choose.
  3. Now right click again and check 'Show Layer Mask"  (note that Edit Layer Mask is already checked). The image will become white, showing the layer mask you just created.
  4. In the tools menu choose the Rectangle Select Tool.   Drag your mouse across the lower half of the layer mask.  Your first will not be perfectly accurate, but you will want this to be positioned at 32 on the vertical axis.  (recall that the image is 64x64).  You can use the 'position' on the lower part of the Tools window to see where your selection is.  Move it up or down as needed to make the second position value 32.
  5. Make the foreground color in the Tools window black.  
  6. Select the pain Bucket Fill Tool (the paint can) and click within the selection on the Image window.
  7. Right click the Layer and uncheck 'Show Layer".
Now you will see that the portion of the layer with the white layer mask is visible.  And the part with the black layer mask is not.  Here's a snapshot of the result:

Now one more thing to do:

  1. Duplicate the layer we've been working on.
  2. The duplicated layer will be selected.... Choose Color->Invert.
You should see the layer mask reverse on the selected layer.  Black becomes white, white becomes black.    Now move the layer with the white/black layer mask above our original merged layer and look closely at the result.

Look at the upper corners first and how they interact with the middle.  The corner flowers are overlaying the middle flowers.  Now look at the middle flower and how it interacts with the lower corners.  The middle flower is overlaying the lower corner flowers.   Cool!!

Before we do anything else, let's save the file.  There's a lot of work here and it would be awful to loose it though a simple mistake.

Now, we need to make one layer for our tiling test.  So Image->Merge Visible Layers.  (notice that all three flower layers and the background layer are visible).  Then Filters->Map->Tile  and choose 640x640.   Here's the result:

Click on the image to get a close look at the tile testing window.  It looks pretty good to me!