Bump textures

John Davis asked how to make bumpy textures using the Noise function. I figure that this is as good a place as any to answer his question.

Because the Noise function is a continuous function, you can always take a derivative of it, without having to dive inside the Noise function to figure out how it works. You can get a good approximation of a derivative by taking finite differences, using nearby samples.

First choose small distance ε, which is small enough that it is smaller than any feature in our scene. I usually use a value for ε of something like 1/1000. Then instead of using a single evaluation of noise at surface point [x,y,z], do four evaluations: One is f0 = noise(x,y,z), and the other three are fx = noise(x+ε,y,z), fy = noise(x,y+ε,z), and fz = noise(x,y,z+ε), respectively.

Now you can just do finite differences to get an approximate derivative. In particular, you can get a vector in the direction of the derivative, which you can then set to unit length by using the normalize function: B = normalize([fx-f0,fy-f0,fz-f0]).

Then you can just add this into your surface normal. The more you add (say, by varying a constant C), the bumpier the texture: normal = normalize(normal + C * B).

And that’s it. You now have bumpy textures.

This is all inspired by Jim Blinn’s Ph.D. dissertation — as is so much in computer graphics. In 1977 he pointed out that you can fake bumpy surfaces not by changing the surface itself but just by changing the surface normal.

And that’s just one reason we know Jim Blinn is a genius: His bump textures technique is simple, fast to compute, and produces great looking results.

4 thoughts on “Bump textures”

Leave a Reply

Your email address will not be published. Required fields are marked *