FEBRUARY 07, 2002
The Complete Guide to Creating Photoshop Filters
The Filter Factory tutorial series, parts 1 through 7
by David Nagel
Page 7 of 9

Appendix 2: More on 3D Effects

In the last section, we examined ways to use Photoshop's Filter Factory to create a 3D effect. This time around, I thought we'd take a look at an alternate method for generating a 3D effect and get a little deeper into the Filter Factory. This one, once again, will show you how to create your own filter for achieving this 3D effect. [an error occurred while processing this directive] Now, before we move on, I must caution once again that this is not a tutorial on creating the kind of 3D seen in Monsters Inc. or Final Fantasy. This is the kind of 3D that you have to wear googly red and blue glasses to appreciate--you know, the kind that makes it look like one portion of the image is closer than another.

Last time, we broke apart portions of our image into its constituent parts and used the Filter Factory to shift the red channels of each layer a different amount. To refresh your memory, the 3D effect is achieved by shifting the red channel of an image to the left. The farther the shift, the farther away the image looks. By separating elements of an image onto separate layers, you can adjust each object's "distance" by varying the red shift on each layer.

What's the theory?
This time around, we're going to do it differently. We're going to use the background layer of an image and shift the red channel proportionally--sort of squish a portion of the image based upon the position of that portion of the image. Get it? No? Well, here's the theory.

If you shift the red channel of an image, it will look flat unless you have something to compare it with, right? 3D imagery is all about the differences in the amount of red channel shift, not the shift itself. This is the reason it worked in our previous experiment: Each layer had a unique shift in its red channel so that, compared with the other layers, it looked nearer or farther. But here we're just going to be affecting the red channel on a single layer, so we need to vary the red shift on our single layer.

Probably the most useful application for this would be a panoramic perspective shot of a wall or maybe a flying logo that trails off to the horizon. Why? What we're going to do is use Photoshop's Filter Factory and a special, magical formula to create more or less red channel shift based upon the current position of each individual pixel in our image. Sound complicated? It's not.

To begin with, choose an image that has some sort of perspective to it. For this particular technique, and image like the one below will work best. (Feel free to use this image for this experiment.) Any image will work though. If you don't have a perspective image, an image like a face can be used, with the result being that the face seems to move as the viewer's head moves. (I'll show you an example of this on the last page. It will freak you out.)



Once you have your image loaded up in Photoshop, you're ready to get working on your filter. Just work on the background layer. Or, if you want to preserve that layer, make a duplicate over it, and work on the duplicate. It really doesn't matter. But definitely have your History active, as you'll probably want to play with variations.

Open up the Filter Factory plugin in Photoshop (Filter > Synthetic > Filter Factory). What you will see there is a strange-looking interface with a bunch of data entry fields and some sliders, as well as a preview window. We're going to be working with one of those sliders (the first one) and one of the data entry fields (also the first one, labeled "R.")



The first field controls the red channel in our image. In our previous experiment, we used a simple formula to cause all of the pixels in the red channel to shift by an equal amount to the left. So we used a formula that looked like this:

src(x+ctl(0),y,0)

What does this mean? It means the source pixels (src) would be moved along the x axis (left/right) by a number of pixels equal to the value of the first slider (called "ctl(0)," or "control 0"). The "y" part of the formula just means that we want to leave the y axis alone. Otherwise, we could do something like y+ctl(1) or something like that. (A 3D effect requires that you move the red channel only left or right, not up and down, unless you plan to have your head sideways while looking at it.) The "0" is Filter Factory's reference number for the red channel. It's redundant, since we're entering our data in the red field, but it does have a purpose in more complex formulas than the ones we're doing today.

Coding the filter
This time around, we want to vary the shift in our red channel. There are lots of ways to do this. For today, we're going to use the x position of each pixel and divide it by the value of our first slider. The higher the x value of a given pixel, the farther it will shift.

Right?

Correct. Filter Factory measure x as the number of pixels away from the edge of the image. A pixel with a value of 100 is 100 pixels in from the side of the image. Our slider (ctl(0)) is an adjustable value that generates a range from 0 to 255. So if we slide the slider to 10, we will be dividing the current pixel value by 10. Pixels at position 100 will be moved over 10 pixels (100/10=10). Pixels at position 150 will be moved 15 pixels (150/10=15). Therefore, the higher the value of a pixel, the more it will move.

The code for this looks like this:

src((x/ctl(0)),y,0)

In other words, the x position (x) of any given pixel (src) will be divided by the value of the first slider (ctl(0)). When ctl(0) is set to 1, the image remains the same. Then it changes more and more as you adjust the slider. However, what you might notice when you use this is that adjusting the slider gives you only three of four usable configurations.

To be able to add more flexibility to the formula, we're going to multiply the x position by 100 and then divide by ctl(0). This gives us a much wider range of settings, which is important for this approach to creating a 3D image. The final formula looks like this:

src(((x*100)/ctl(0)),y,0)

That's x*100 (since the asterisk is the symbol for multiplication) divided by ctl(0). With this formula, the slider should be set to 100 for a neutral effect (since 100/100=1, and x/1=x) and then moved left or right to make the change. In this case, we want to move it left, as we want our red channel to shift left. You can just copy the formula above and paste it into your R field in the Filter Factory.



You want ot be careful not to slide the slider too much. A huge channel shift does not make for a very good 3D image. Keep it in the 95 to 99 range.




What's next?
Actually, you're done. Apply the filter, and look at the results through your 3D glasses.

If you'd like to save this filter for future use, Open up the Filter Factory again, where you'll see your settings just as you left them. Click the "Make" button. This will call up a new dialog box.



Enter in all of the personal information you want. The "Category" field is the name of the directory that will be created in the Photoshop Filter menu. The name of the filter is what will appear in the subdirectory. The only slider we've used for this effect is the first slider, so just click the checkbox labeled "Control 1." Save the filter into your Photoshop "Plug-Ins" directory. The next time you launch Photoshop, this filter will be available for you.

Note that Filter Factory filters only work on the platform they're created on. So, if you're on a Mac, but you want to create a Windows filter, you'll have to open up a Windows copy of Photoshop and create it all over again.

Finally, if you want to want to extend this formula to create a general distortion effect, simply copy and paste the formula in the R channel to all of the other channels. Then change the "0" in the formula to 1 and 2 for the green and blue channels, respectively.



But wait! There's more....

The freakout
In the beginning, I promised I'd freak you out with a disturbing face image with this effect applied. Here it is. When you look at it, sway your head left and right about six inches. (Scroll down the page to see a different perspective.



Above you see the effect on an image that has no perspective. Take a look at the image below, which uses a gray bar to demonstrate the actual effect on distance. You can easily apply any kind of image over the 3D image to bring out the 3D a little bit more (such as your company's logo).



Part 1: Introduction to Basic Operations in Filter Factory
Part 2: Convolving Pixels
Part 3: Geometric Expressions
Part 4: Conditional Statements
Appendix 1: 3D Effects in the Filter Factory
Appendix 2: More on 3D Effects
Appendix 3: Customizing Your Filter Interface
Complete: The Whole Thing on One Giant Page!

Further Resources: I've tried to make this series as accessible as possible for you folks without any programming background. If you'd like to take the Filter Factory even further or just learn more about the guts of Photoshop, there is a highly technical instructional document that you can find at http://www.thepluginsite.com/knowhow/ffpg/ffpg.htm. I highly recommend it. For me, it's been a great source for experimentation, even if, at first, I didn't understand everything that the author was talking about.



Prev 1 2 3 4 5 6 7 8 9 Next
Related sites:Animation ArtistAV VideoCreative MacDigital Media DesignerDigital Post ProductionDigital ProducerDigital WebcastPresentation MasterThe WWUG
Related forums:

[an error occurred while processing this directive]