The current bump node (formerly known as zbump) became very popular for its simplicity, and for its ability to get procedural textures as inputs.

However, it has some limitations, for instance not supporting texture pre-filtering, and the fact that its spacing is expressed in world coordinates instead of uv coordinates like the old node. This leads to frequent aliasing problems, that can sometimes be limited by texturing the spacing based on the object’s distance from the camera.

Another way of fixing the aliasing is to filter the high frequencies of the input texture. The primary way to achieve this filtering is to do it on the image in an editing program like Photoshop, but this is harder to do with procedural nodes.

However, by using a few nodes in the rendertree, it is possible to do it there also.

The bump node outputs the new normal (N’), after having bent the original one (N) based on the texture gradient at the current point.

So, we can compare N to N’ by subtracting them and getting the length (L) of this difference vector (D). Since N and N’ are normalized, and the maximum bump angle is 90 degrees, D ranges from 0 (no bump) to 1.41, ie the hypotenuse of a right triangle with unit catheti.

We can then set a maximum length for D, and re-arrange N’ in order not to exceed it, so to filter off the high frequencies and limit the aliasing.

In this first rendertree, we simply want to check the “dangerous” zones. We take the length (L) of the normal’s difference (D) and check it against a maximum scalar. If this scalar is exceeded red is returned or green otherwise.

In this example the scalar is set to 1, we are seeing in red the parts where the bending angle exceeds 60 degrees.

To output the filtered normal, we do the same test as above, but connected to a scalar switch.
The switcher outputs the maximum between Max Displacement and L. This value is used to set the new length of D (VectorNormalize + VectorSetLength).

This vector is then added to the original normal N and normalized. This is our new, filtered normal.

Of course this is a very basic filter, more complex ones can easily be built to fit your needs.

You can grab the scene if you want. The red and green subtree is also included, connected to the shadow port.

This entry was posted
on Saturday, May 24th, 2008 at 12:48 pm and is filed under Texturing.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.