Monday, 26 October 2015

TUTORIAL: Gothic Double-Vaulted Ceiling Using the Boolean Modifier

Last night I posted some pictures of a work in progress to my G+ account and was greeted with some very favorable responses (thanks!) but I got the sense that a few people were thinking "gosh, I wish I could do that" and I'm happy to tell you that it's extremely easy. Here's a reference picture to show you the type of ceiling I'm talking about. It's impossible to do this with prims but easy to do it with mesh.
All that's really involved in the classic gothic ceiling is two cylinders, intersecting and then being repeated over and over again to cover the required area. Then plop down some columns to support it all and you're done.

I just make one ceiling section and one column support, import those, then use them as my building blocks. That keeps the mesh data to a minimum, making it much faster to send to the visitor. You can even make the columns using prims if you prefer, so the only thing you can't do in-world is make the ceiling. This mini-tutorial will show you how it's done in Blender and is suitable even for beginner level users. It should take less than half an hour to complete.

Start by adding a mesh cylinder. In most cases 32 vertices is fine, but if you want to you could bump the count up to any even number that is a multiple of 4. Going beyond 48 would be excessive unless you plan to scale it very, very large (which was never the case in real life because the whole point of vaulted ceilings was a lack of technology and building materials that wouldn't collapse if you tried to get them to cover huge areas without support).

For this one I use a 1.5m radius (hence a 3m diameter) and 4m length. The critical thing is the length must be at least as great as the diameter and no more than double the diameter. It's the ratio of the two that determines the overall look of it and is worth experimenting with. The closer the length is to the diameter, the smaller the column portion and intervening joiner.

Don't fill the end caps and rotate it by 90 degrees on the x-axis or y-axis so it's lying on its side.
 
 On the Tools tab of the toolshelf, click the "Smooth" shading button to give it smooth normals. Then enter Edit mode and with all faces selected invert the normals using the menu Mesh > Normals > Flip Normals. That causes the faces to be oriented towards the inside which is where we want them, rather than to the outside. Then return to Object mode.
Now duplicate the cylinder and rotate it by 90 degrees on the z-axis using the hotkey combination of: shift+D R Z 90 (duplicate > rotate > z-axis > 90 degrees) and press enter.

That will now give you a pair of intersecting cylinders where the upper halves of both form the classic Gothic vault shape. All we need to do is get rid of the overlapping parts which is easy using the Boolean modifier.

If you've never used the Boolean modifier I suggest hiding the duplicated cylinder so you can see what's happening as you apply the modifier to the original object (select it and hotkey H or click the little visibility eyeball in the Outliner pane).

Now select your original cylinder and add a Boolean modifier to it (you will find it in the "Generate" class of modifiers). When you first do so it will highlight the name in red because Boolean requires a second object to be defined for the operation.

Click the "Object" box to get a drop-down of other scene objects, and since our only other object is the duplicate we made a moment ago, it will be the only one in the list.

By default the modifier should select the "Intersect" operation which is the one we want in this case. If it doesn't look like the accompanying picture for this step you probably skipped the step, above, to flip the normals so Blender is interpreting the operation differently. If that's the case, either go back and flip normals for both of the cylinders, or set it to "Union" operation and then flip normals later.

As you can see, this modifier produces almost the exact shape we want (once we cut the bottom half off) but there are a few other things we need to take care of as well.

Normally I prefer to wait until the very last possible moment before applying modifiers, but in this case we need to work with the post-Boolean object so go ahead and click the modifier's "Apply" button.

Now un-hide your duplicate cylinder and you'll notice that it's completely unaffected...its only purpose was to provide the secondary object for the Boolean modifier. Since we don't need it any longer we can delete it.

Now switch into edit mode where we first need to do a little clean-up since the Boolean modifier often leave orphaned vertices that don't cause problems in Blender but will usually make a mesh refuse to up-load into Opensim. Select all, then click the "Remove Doubles" button (on the "Tools" tab of the toolshelf) to get rid of them.

Using edge select mode, select the diagonal edge loops and the four cylinder ends. Mark those edges as both sharp and as seams. We want them sharp so they won't distort the normals of the ceiling faces when they're smoothed, and we need them as seams for our UV mapping.

Next, select all the faces of the bottom half of the object and delete them, leaving us with only the final shape we're interested in.

Now select all faces and UV map them using the Unwrap method. If you plan to make your textures using Blender's procedural methods you can work with them from this point however you like.



I prefer to give myself more flexibility and a lot more versatility but arranging my UV map to facilitate using seamless textures with any tiling I need.

To do that you need to arrange the resulting map to have all four islands superimposed and aligned along one of the map edges. The seams will now match perfectly on adjoining pieces when you build your ceiling as long as you tile in whole number increments.

Our final step before export is to add an Edge Split modifier which will break the edges we've marked as sharp. This increases the vertex count but makes the normals of the surface look correct and it doesn't change the face count. I also add a Triangulate modifier set to "Beauty" although with this object there's almost no visible difference between that and the "Shortest Diagonal" method.

You can now export this model to dae and import it in-world to use as a building block for your own classic Gothic vaulted ceiling. Notice that the finished object is a mere 128 triangles which is significantly less than even a prim cylinder. don't forget to apply rotation and scale before you export.

The advantage of the building block method is how rapidly the geometry can be sent to the visitor's viewer and the very low poly count which will make it much more gentle for underpowered graphics cards to display. Using the seamless UV map approach also means we can use any seamless texture we want on it...brick, tile, stucco, paint, marble, or anything else that fits the need.

Because it's a single object, it can also be scaled in any dimension you like. For my sample image at the beginning of this post, I have them scaled to only 1m height around the edges and 2m height for the center ones. Of course this meant I had to make end caps for the transition pieces but that's very easy to do from this point of the model. I made matching mesh columns for mine but you can use prims if you prefer. They just need to be the appropriate size for the arch portions to rest on.

Me standing under a 3x3 array of them before I add columns
If you want to get even fancier, you can make additional ornamental pieces to fit the arching and connections simply by selecting the loops, duplicate to a separate mesh, convert to curve, then set whatever parameters look best. Those will then require conversion back to mesh, then mapping, and probably a separate material and texture. Of course that can increase the poly count rather dramatically if you start to get very ornate.