"We can't stop here! This is Penguin Country!"

Gimp Tutorial - Pebbles

Date/Time Permalink: 07/14/07 02:52:09 am
Category: Graphics Tutorials

Here's a topic I don't see a tutorial on anywhere. While Gimp is NOT a 3D ray-tracer, it does have some plug-ins that perform simple 3D functions. We're going to exploit the "Map Object" plug-in for all it's worth, here. Then we'll look at a more common method.

I'm assuming you already know the basic usage of Gimp. If not, here's the manual in English (other languages available).

How to make pebbles - Method A

1. Grab an example image of pebbles or rocks from online/ creative-commons works. Since we're only going to be sampling them for a few pixels, licensing isn't as hot an issue.

2. Start a new image file - Make it a square 128x128. With your pebble example image open, select a square of pebble texture from the image and copy it into your new square. If the square you ended up with is smaller that the image square, use the resize tool to make it bigger, then Ctrl-X and Ctrl-V to cut it and re-paste it into the frame so it is centered.

step 2

3. Do Filters-> Map-> Make Seamless to make the edges blend. Now pick Script-Fu-> Selection-> To pattern. Give your pattern a name, and it will save it in your personal patterns folder. You can close the pattern sample you made after this.

step 3

4. Open a new file - since the dimensions of the file will determine the pebble's shape, and we seldom encounter perfectly round pebbles in nature, make it a rectangle like 128x256. Use the paint bucket set to "pattern fill" to file the new image with your pebble pattern. Don't be too distressed if the pattern repeats; most of it won't be visible when we're done.

Next, open Filters-> Map-> Map Object to get the 3D rendering dialog. In the Options tab, select "map to sphere" and check "transparent background". I've also played with the Material tab to make the surface not have such a bright highlight (decrease specular) and make the pebble texture stand out more (increase diffuse). Remember that even though the dialog shows a sphere, the actual object will stretch to fit the image dimensions.

step 4

5. Theoretically, you can add a drop shadow, slap it onto a white background, and say you're done at this point. Repeat with different textures and different starting rectangles for different pebbles.

But if you want to try for a little more realism and your hand is feeling steady, you can try distorting the shape a little. Pick Filters-> Distorts-> iWarp and use the "move" function, nudging parts in the preview around with your cursor, to distort the shape to something more natural. Remember that you are also distorting the light and shadow, so go gently here and possibly rotate the finished pebble so the light and shadow are still oriented the way you want them.

step 5

This way is kind of hokey, but good for round, smooth, polished-looking pebbles.

example 1

For more natural, rougher pebbles, let's continue to:

How to make pebbles - Method B

6. This time we'll be doing the standard bump-map-and-mask number. Get any size new file you like, fill it with the pebble texture of your choice, and pop open the layer dialog. As you can see here, this time I used the common texture "paper" just to show that darn near anything will look like a rock once we're done with it.

step 6

7. Leave the textured layer be named "background" but create a new layer called "#2" and fill it with black. Use white color and any drawing tool to make a white-filled blob shaped like the pebble you want.

step 7

8. Augh! We have to smooth out those straight edges and hard corners! Do a Filters-> Blur-> Gaussian Blur with a value of something like 30.0.

step 8

9. Then open Layers-> Colors-> Levels and in the color levels dialog, drag the outer two arrows on the meter in towards the center, to make a hard outline again with rounder edges.

step 9

10. Now we'll use the black and white for two things: our map and our mask. First for the mask: In the image copy the black-and-white drawing. In the layers dialog add a new mask to the background layer. Then with that background layer's mask selected, paste the black-and-white drawing in, anchoring it with Ctrl-H. You should now be able to move layer #2 below Background layer, click off the eye icon next to layer #2, and see this:

step 10

11. Back at layer #2, apply another Gaussian Blur. Go high; 30.0 to 35.0. The higher the number, the "taller" your pebble will look. Next, select the Background layer again (the texture, not the mask), and open Filters-> Map-> Bump Map. Make sure that it's using layer #2 for the map, and set a high depth and low elevation to get a more pronounced mapping.

step 11

12. You should now be able to switch the eye off on #2 and on on Background (in the layer dialog) and see this:

step 12

13. Delete layer #2, apply the layer mask to the Background layer. Optionally, you can use the lighting effects plug-in to cast a not-too-intense directional light on top of the pebble to make it look less flat on top. Give it a drop shadow (Script-Fu-> Shadow-> Drop Shadow) and you're done.

example 2

There, you're all set to add a decorative Zen rock garden border to your web page!

example 3

Hope this was helpful. Comments, corrections, and suggestions are welcome!

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

suddenly the moon