If you are like me, you are lazy. Making a UV Map for every object takes time and even if I am still sitting in my chair while doing it, it can involve an internal meltdown. Box mapping to the rescue!
Box mapping is a way to project a texture onto a 3D object without a UV map. We project the texture from 6 sides, XYZ and their negative counterparts. Box mapping is often called triplanar projection. To use box mapping for a texture in Blender, select the image texture node and change projection from flat to box. Use a texture coordinate node with generated or object coordinates connected to the vector slot.
With box projection, we project the texture from six sides. Positive and negative X, Y and Z.
In the UV map we can tell what pixels the faces (polygons) should have projected to it, but in box project mode we are limited to the 6 sides of projection. What we sacrifice with box projection is control, but what we gain is speed, lots of speed.
Related content: The definitive tutorial to UV mapping in Blender
In a way you could say that box projection is a good effort to make an image texture a procedural texture.
Box mapping is not suitable for every type of 3D model. But one area where it excels is architectural visualization and interiors. The reason for this is that there is a lot of objects that are square shaped, and we can box project our texture on to those objects, make some adjustments and be done.
We have two different kinds of textures that we will consider. An image texture that is seamless and is quite uniform, meaning there is no clear direction as to how the texture should be laid out. This could be a moss or rock texture. The second image texture is also seamless, but it has a clear direction to it. Like wood.
Let us first look at the uniform type since it is the simple one.
Start with a texture coordinate node. Use the generated or object output from the texture coordinate node.
You can connect this to a mapping node for extra control, but in this example, we keep it simple and connect it directly to the image texture node.
Generated and object coordinates works differently but for our intentions here they will serve a similar enough purpose.
You can learn more about the differences in this guide
Related content: The complete beginners guide to Blender nodes, Eevee, Cycles and PBR
Connect the vector output to an image texture and change the image texture from flat to box. This is what tells Blender that we are using box projection.
Now you will get a blend value that you can raise to blend between the 6 angles the texture gets projected from. For a rock or mud texture a value around 0.2 or 0.3 usually gets rid of any seams that might have been.
Image note: Arrows should be pointing at object, not camera
This is as simple as it gets for box projection.
The tricky part is when we come to the second type of texture where we have a clear direction that absolutely needs to be rotated correctly, like wood.
If you try to change the rotation value with a mapping node you will get less than ideal results in most cases. Here we have two options. Let's first look at the rotate image option.
We can rotate our texture in a 2D image editor and save a rotated version. Then use the rotated version in the same way as we did with the uniform texture.
Another alternative is to use Boxtoggle tools, an add-on that I wrote. The add-on was originally made for Blender version 2.80, but has now been updated and should work all the way up to version 4.02 and probably for later versions as well.
Boxtoggle tools (Direct download)
Also available on github:
External content: BoxToggleTools repository
The install instructions have changed since the first version and requires you to run a few commands. These are the steps:
The add-on relies on a python library called Pillow to handle image manipulation. The commands we run installs a library manager called pip and then uses it to install the correct version of Pillow for your operating system and version of Blender. Then we simply copy the add-on to the add-ons folder and enable it.
Related content: 30 Blender addons (install, manage, free and paid)
Boxtoggle tools has two functions.
The first operation is a toggle between box and flat image texture projection for all selected image textures at once. When toggled to box project the blend value is set to 0.2. It speeds up the switch significantly when using multiple texture maps.
TO use it, select the image texture nodes in your node tree that you would like to toggle. Hit Alt+Q or hit space, or F3 to bring up search, then type “boxtoggle” and hit enter to use this function.
The second operation will rotate the image texture that is set for any selected image texture nodes. Use it with Alt+W or search for “rotateimage”.
This is how it works. Let’s say that we are trying to box map “MyWood.png” to our object.
When we run the “rotateimage” operation Blender looks inside the blend file for an image called “MyWood_rotated.png”. If the image is found, it will switch to that image.
If Blender can’t find the image it will look in the original folder on the hard drive for “MyWood.png” and see if there is a "MyWood_rotated.png" image in that folder.
If the image is found, Blender sets it as the image for the node that has the "MyWood.png" image attached. If the rotated version still can’t be found the add-on will create it and store it in the original folder on disk.
Now the rotated version will be there and the next time you run the operation Blender will toggle between the rotated and non-rotated image.
This gets us some more control. We get to rotate all projections by 90 degrees at the same time. But we still can’t rotate every projection angle individually.
The other method is to use a node group. The math behind this node group was made by MartinZ on blenderartists and the node group was then put together by Nathan_boder. You can read the full forum thread here.
However, the download links seems to be broken. But you can get the blendfile here. You need 2.80 or later to open it. A 2.79 version is available from the thread above.
Append all node groups from the file. Use the node group called "texture preferences" instead of the texture coordinate node and pipe it straight to your image texture.
This node uses the flat projection method. Notice here how we lose the blend slider when we use this method. This is one of the drawbacks. The seams that might be however, may not be so obvious and if this way of texturing can save us UV Mapping and still gives us enough control, then we might have saved ourselves some time.
To learn how it works setup it up in the shader workspace to see how the texture behaves as you change the values in real time.
So, how could we use all this to our advantage? This is my approach.
First, determine if the model is fit for box projection or if I need a UV Map. Most of the time I will go with a UV Map starting with a Smart UV Project but if my model is simple enough or generally square shaped, I will go ahead and try box project first. It can also be a plane, like a terrain ground.
Related content: The definitive tutorial to UV mapping in Blender
From here, I select all image textures that I want to box project and use the Boxtoggle add-on above. I inspect the projection and see if it fits my needs.
If not, I may rotate the images using the add-on if it is the rotation that is the issue or add a mapping node and adjust the scaling if that is the problem.
If I am still not happy, I will delete the texture coordinate node and use the node group from the blenderartists thread above. From there I adjust the parameters as I see fit.
In case I am still not happy with the mapping. or instance I may need a different rotation or scaling independent of the projection angle for instance. Then fall back on a UV Mapping workflow.
This may seem like a lot, but all this is done within the minute if Blender is set up correctly.
We learned how to use box mapping and that it can also be called triplanar projection in other applications than Blender. We also looked at increasing our control over how the mapping is done by rotating and scaling.
Either using a rotated image quickly made with the add-on above or through a node group. With the node group though we lose the blend value, but the rotated image approach can’t rotate individual projections.
I hope you found this useful and I would like to encourage you to share this on your social media channels as well as commenting if you have any questions or feedback. It really helps a lot.
Thanks for your time