Sunday, March 16, 2008

Shadow-palooza and Layer Faire

Yes, welcome back. This last installment here has been written for about 2 weeks, but I've had a devil of a time getting the images embedded, so sorry 'bout that. I am sure many of you have come up with inventive solutions to the project we are working on by now. I am back on my Mac laptop today as I compose this lesson. Now, before we start talking about the process of creating a shadow of an object in a layer, let's talk about the dynamics of light and shadow in an image. This might seem like geek-speak when you look at it the first time, but look at two example images:



Now, what I've done is take an object which is casting a shadow in its original image, removed the shadow, and used the technique we are going to use to cast a shadow in our sandbox image to create two different shadows -- one like the original, and one which is frankly wrong.

Now, intuitively, you're going look at one of these objects and realize it looks, well, wrong. But how will you know which one is physically impossible? In the real world, we know that a shadow casts away from a light source -- like this:



Light comes from a source, strikes some object so we can see it, and behind the object -- away from the lightsource -- is the shadow. Duh, right? So which image of our examples has the shadow in the right place if this is so "duh"?

Look at the die a minute and see if it tells you anything about the light source. If you're really observant, you'll see a reflection of white light on the front-left edge of the die right here:



That reflection is a giveaway that SAMPLE #1 is a phony -- the shadow is resting under the light and not away from the light. If we look at the original image, we can see that its shadow is cast in the same direction as SAMPLE #2, under the die and away from the light source as indicated by the little reflection of light.



So what does that teach us? Well, it teaches us, in the very least, that we have to learn how to cast shadows by reading the light source in our lifted objects, and that our objects have to look like they are all under the same light bulb when they are all laid out together.

So here's our image right now:



And if we look at the knight closely, we can see the tell-tale shine of a direct light source right here:



So the lightsource is above the knight, and in front of it -- in the foreground, but outside of the picture itself, and maybe a little to one side. Some purist is going to say that the shadow should dip off to the right, but that's going to make our layout all messed up. So while I'm telling you that your shadow has to look realistic, I'm also telling you that as long as it's not a catastrophe, it'll be OK.

Now, we have one last conundrum to solve -- and that's how to get a shadow which looks somewhat like the knight in question. It's actually a very simple exercise in manipulating layers, and what I want you to do is go to your Layers dialog, select the "knight" layer, and click the "duplicate layer" button.

Your "Layers" dialog should now look like this:



Now, notice in that dialog the little "eye" icon to the left of each layer. It's sorta weird, right? Just to see what it does, line up on the eye for the "logo" layer and click it so the eye disappears. You'll notice that when the eye disappears, the layer is no longer visible in your sandbox, even though GiMP knows it's still there. Click the place where the eye ought to be to make both the eye and the layer re-appear.

Cool, yes?

OK -- now click the eye for the "knight copy" layer to make it disappear. It looks like nothing happened, but the layer is now invisible. We're going to work with the "knight" layer, so select it in the "Layers" dialog.

The reason we make the "copy" layer invisible is to keep us, the stupid human users, from getting confused. We're going to make a shadow out of this identical layer, but we don't want to accidentally start wrecking both "knight" layers in the process.

Now select the "knight" layer and in the sandbox image, go to the "Colors" menu. In that menu, select "Brightness/Contrast" (B/C)



You'll get a dialog that looks like the one below, and you're going to pull both sliders all the way to the left, as pictured below:



You'll see the results as a preview if you have the "preview" checkbox checked, but when you hit "OK", the sandbox image looks like this:



Pretty cool, right? The "Brightness" slider adjusts the color intensity of the image, and the "Contrast" slider adjusts the difference between colors. So moving them both to the left reduces the layer to a gray blob -- no distinct colors as all colors have been reduced to no brightness and no color.

Just as an enrichment exercise, think about how we were able to do what he have here: if the knight were not a dstinct layer, when we used the B/C sliders we would have decolorized the whole image. What we have instead is a single layer, independent of the rest of the image, which we have manipulated pretty significantly to make it into a shadow. Without keeping the parts of our image in separate layers, we would have never been able to do this.

We are, however, going to manipulate the color of this layer even more. If we wanted to make this later into "smoke", this gray stuff would be very serviceable. But we want a translucent shadow, and everybody knows that shadows are black.

In that case, we have to open the B/C dialog again, and this time run your sliders like this:



When you click "OK", your sandbox image will look like this:



And that's a nice black outline version of the knight. Now, if you make the "knight copy" layer visible, this black outline will disappear -- it will be hidden underneath the copy layer. And that's a bad thing right now, but go ahead and test it so you can see that we haven't lost the knight yet in this operation. Click the eye again to make the "copy" layer invisible again.

To keep our exercise as simple as possible, select the "knight" layer, grab the magic wand tool, drag the threshold up to 40, and select the black shadow outline. Your shadow image should have the "marching ants" around the outside of the shadow.

Next, go to the "Tools" dialog and select the "Perspective" tool. These are all tools we have used in other lessons, so I'm going to take it for granted that you can find the tools I'm talking about.

Take the perspective tool to the selected shadow and click in the middle of the shadow. You'll get something that looks like this:



That means you're ready to manipulate the shadow so that it looks like it's down flat on top of the logo, and you can also tilt it in such a way that it cuts from where the base of the knight will be over slightly to the left. You'll do that by pulling the corners until you get something that looks like this:



You'll have to hit "enter" to complete the edit, and then click the "anchor" button to put the adjusted shadow back into its layer, but you're practically a pro at GiMP by now -- or at least a competent basic user, anyway -- so that stuff is old hat.

After you have the shadow back in its layer, go to the "Filters" menu, and select "Blur", and in the nested menu select "Gaussian Blur". The link there is the geek-speak for those who want to read up on what a "gaussian" blur is vs. a normal "blur". The rest of us are just going top use the tool and love it.

When you select "Gaussian Blur", you're going to get this dialog window:



Use the scroll bars inside the dialog to get the preview image in the middle, and set the blur radius to "20". If you type "20" into the "Horizontal" field, and tab to the next field, the "Vertical" field will automatically fill in "20". and you can see the preview of the blur factor in the preview window.

Click "OK", and you'll have the basic image which looks like a shadow in a brightly-lit area.

To finish our work, we're going to make the "knight copy" layer visible so we can position the shadow so it seems to make sense relative to the solid object.

When you make the "knight copy" layer visible, you get something like this:



Before we go too far, grab the "Move" tool from the tool dialog, then select the "knight" layer -- the one which is actually the shadow. Then go to the sandbox image and drag it to the top and to the left of the imageso that little nip of shadow in the foreground at the edge of the base of the knight slides under the knight.

Use your best judgement, and make the shadow look as realistic as possible relative to the knight.



And that's not too bad -- except the shadow is too dark. It ought to show the logo through itself, and right now it doesn't do that very well. Go back to your "Layers" dialog, select the "knight" layer, and change the "Opacity" of that layer to 50 -- meaning it's 50% transparent.

And that's it. To save your image with layer, save it as a .xcf file; if you want to post it on the web someplace, use .jpg, .gif or .png.

Izzat cool or what?