Blended Box Mapping
By Neil Blevins
Created On: May 15th 2006
Updated On: Nov 29th 2011
Go here
to read this tutorial in Russian.
Go here
if you'd like a way to make a Blended Box Map in mentalray for Maya. Go
here
if you'd like a way to make a Blended Box Map in for Maya using no
external plugins. And here's a script
that helps to automate the process.
Say I want to apply some dirt to a bunch of objects in my scene. While
I could use procedural noise, I'd prefer to use bitmaps since that will
make the dirt will look a little more organic. But I don't want to
spend a long time setting up good UVs for all of the objects, because
that will take awhile. This is a tutorial that discusses a quick and
easy way to apply a noisy
bitmap to a bunch of objects without the need to unwrap their uvs.
Regular Box Mapping
So lets start with a reasonably random and noisy bitmap like the
following...

And you have a somewhat irregular object like this...

And you'd like to quickly apply this pattern to your object.
As already mentioned, one way is
to unwrap your object's uvs. This will let you apply a very specific
patterns to your object without stretching or seams, but it can take
awhile to set up, especially if you have lots of objects in your scene,
and is overkill for a lot of situations.
A quicker way would be to use
box mapping on the object. Box mapping is a mapping type that projects
your texture from the six sides of a box at your object. So apply a UVW
Mapping modifier to your object, set the mapping type as box, and
render...

Well, that sort of worked, except there's a bunch of bad seams. Why is
that? So
if you use box mapping on an object that has rounded corners, faces of
your mesh that point towards one of the 6 sides of the box map work
fine. But if a face is near a 45 degree angle to the sides of the box,
you get a seam where different sides of the box apply mapping to each
face. For example, say a face is 44.5 degrees away from the front of
the box map, it will receive mapping from the front of the box. Now say
the next face is 45.5 degrees away from the front of the box map, it
will receive mapping from the side of the box. So between those two
faces you get a seam.
Lets look at the same problem on a sphere.

Instead of a noisy map, this is a custom uv map applied using regular
box mapping. Notice the seams right at the edges where faces are near a
45 degree angle to any given side of the box map.
If only there was some way to blend these seams.
RIP InstantUV
Well, back in the
earlier days of max (Max 4) there was a plugin called InstantUV that
did this
sort of thing. But the developer decided to stop selling it, and it
never got recompiled for more modern versions of max.
Blended Box Mapping Using UVWMapping
So if there's no plugin to do this sort of thing anymore, we're just
going to have to construct our own box map with blended edges. The
trick for manually making a blended box map is to apply 3 planar UVW
Mapping
modifiers
using 3 different map channels to your objects, and then blend their
edges using
falloff maps. This method is kind of ugly, but the results are think
are worth the mess.
Take a peak at the map tree...

And a look at the 3 uvw mapping modifiers...

Also note, in the output section of the 2 falloff maps are curve
controls, and modifying these curve controls achieve a sharper or
blurrier
transition on the edges.
Here's a max
8 example file that gives an example of how this works.
And here's the results...

Notice the blending between the edges. Now this isn't ideal for
something with a regular pattern like this uv map, but lets go back to
our original example of the noisy looking map...

The seam is basically gone (if you look real close you can sorta see
it, but
3d is all about illusion, if the viewer can't see it on first read then
it might as
well not be there). And remember, the noisier the map is, or the more
box-like your object is, the better this will work.
Now reproducing a Blended Box Map by hand on a new piece of geometry
can be a bit complicated, so I've automated the process and wrote a
maxscript that will make the map-tree and UVWMapping gizmos for you.
Please visit my Soulburn
Scripts for 3dsMax page and get the latest SoulCollection. Install
the scripts, and run the script called blendedBoxMapMaker. Here's an
interface snapshot...

To run the script, select the objects you want to apply the 3 UVW
Mapping Modifiers to, in the script interface window choose "UVW
Mapping
Method", choose the bitmap you want to use for your blended box map,
and
hit "do".
So lets say you have an air vent like you see below, which is
made up of 20 separate objects, and I want to apply some noisy dirt to
all the pieces. So lets use a Blended Box Map.

I select all the objects, run my script like I describe above, and
voila, it creates the three necessary mapping modifiers...

It adds the map tree to the material editor...

And I'll place the map tree into the diffuse slot of a material
assigned to the air vent so you can see the result rendered...

Now artistically, this doesn't look fantastic, but if you replace this
bitmap with something a little better, you can get some great
results...

You can use this map tree anywhere in your material, one technique I
use
a lot is to use the map tree in the mix map of a blend material to
blend
between a
metal material and a dirt material...

So there, I've added some dirt from a bitmap to 20 objects in just a
few button clicks, no tweaking procedural parameters, no unwrapping.
The "UVW Mapping Method" does have a few downsides...
- The mapping
modifiers are attached to each individual object. So if you move one of
your objects, the mapping modifiers will become misaligned.
- Your objects need to have their transforms reset in order to get
the falloff maps to align properly with the world (this is done using
the Reset XForm utility in max). This is especially
bad if you want to keep your original transforms on the objects.
- Adding a new object to your mapping requires copying and
pasting three separate mapping modifiers, and in the process of pasting
them, again, they may become misaligned.
Here's an example of mis-alignment. I decide to move one of my bolts on
the air vent AFTER I have set up a Blended Box Map using the "UVW
Mapping
Method". Since the UVW Mapping Gizmos are attached to my objects,
moving
the bolt moves just one of the gizmos. Now I have multiple gizmos in
multiple locations in 3d space, instead of them all being nicely
aligned.

So the "UVW Mapping Method" has a number of pretty major downsides.
Thankfully, there is now a better method.
Blended Box Mapping Using
Projections By Script
First off, you will need the free plugin CameraMapGemini v0.16 or
higher by Markus Boos (http://www.projectgemini.net/CameraMapGemini/).
Install the plugin, and run max. Now go back to the blendedBoxMapMaker
script and change the mode to "CameraMapGemini Method".

Run the script, select the air vent, and notice a few changes.
First, instead of applying 3 UVWMapping modifiers, it applies a single
CameraMapGemini modifier to your object, and creates 3 projection
cameras.

These cameras will project your texture, much like how the UVW Mapping
modifiers did, except the cameras are not attached to each separate
object. Decoupling the projection position from
the object position means no more misaligned projections. And if you
need the projections to move with the objects, just parent the camera
projection group (a point object seen in the above image in light
green) with the parent of your geometry hierarchy. Now whenever you
move your whole air vent, the projection cameras will move with it, and
so the projection stays attached to your objects.
Now check out the CameraMapGemini modifier assigned to your objects...

Notice the modifier references your three projection cameras. But since
there's only a single modifier, adding new objects to your air vent is
easy, just copy and paste an instance of this modifier to your new
objects.
Finally, check out the map tree it creates in the material editor...

This map composites your three projections together. And check out each
submap...

Especially notice the "Face Angle Threshold" area. This fades off the
edges of the projection as the object's face points perpendicular to
the projection camera. This replaces the need for 2 falloff maps in the
"UVW Mapping Method". And since the fade-off is aligned to your
projection cameras, and not to the object space of your individual
objects, you don't need to reset the xform on your objects.
And the visual results it provides are identical to the "UVW Mapping
Method"...

So in general, I would recommend using the "CameraMapGemini Method" for
making your Blended Box Maps from now on. It's still not as good as a
dedicated plugin (that I still hope someone writes one day), but it
does fix all 3 of the major downsides to using the "UVW Mapping Method".
This site is ©2011 by Neil
Blevins,
All rights are reserved.
Back to NeilBlevins.com