Jump to content

Tutorial: cutting holes in round objects (with Blender)


Recommended Posts

The Problem

Cutting a hole in a round object can be very tricky, as it often generates problems with the shading of the mesh.

Some examples and the discussion that lead into a solution can be found in this thread. Today, I want to summarize our findings and add some details in this tutorial for blender. Very(!) basically, the shading of a mesh is derived from the normals of its vertices. Techniques like Phong shading will interpolate the normals of the vertices that span a polygon on every point (pixel) of its surface to create a normal for this point that are then used in a special model to empirically create the lighting of that point. But if you cut additional vertices, that aren't in line with the existing ones of a sphere or a cylinder, these normals will also be used and cause the problems. Also, the topology of the mesh - it's flow of connected quads influences the shading. For rendering and/or animation, you would avoid these problems by adding a higher mesh density, so that every edge of the hole would be on an original edge of the target mesh. Also, you would avoid triangles, avoid stretched polygons, avoid 5+sided poles (vertices with more than 5 edges connected to them). Read more about normals and (phong) shading and mesh topology.

For games, this is not a solution, but can be fixed by tweaking the normals of the mesh.

The Solution

1 Cutting a hole

1.01 Position a circle with the numbers of vertices and the right diameter of the hole you want to cut. The example shows a fairly large hole to cut into a frustum. Like maybe a round hatch.

001_overviewvpqax.png

1.02 Adding a edgeloop (alt-r in edit mode) where the centre of the hole should be on the target mesh. This will help us positioning the hole, as well as give us some extra geometry to play with.

002_helper_edgeloopd3row.png

1.03 Set Snap to vertex - active and pivot to center

003_set_snap_active0sr8s.png     003a_set_pivotm7qu3.png

1.04 In object mode, select the circle, hit g to move and hover over the vertex on the newly created helper edgeloop where the center of the hole should be. This snaps the center of the circle to this vertex.

004_snap_center-to-veqxqhg.png

1.05 With the circle still selected, go into edit mode, select everything, de- and re-select the top vertex to make it active.

005_select_all_make_ajgodf.png

1.06 Hit r to rotate and hover over the vertex on top of the frustum that is vertically above the centre of the hole. The circle will rotate and align perfectly with the angle of the frustum. (On sphere-like objects, create a vertice in the centre of the sphere, rotate to this vertice, and rotate additional 90° on the needed axis to get the circle into a tangential position above the surface)

006_rotate_snap_activl3ocy.png

1.07 Hold shift while using the 1/3/7 and maybe control- keys (or View->Align View->Align View to Active->) to snap the view to the circle like shown in the picture. The rotation is irrelevant, but the circle should be coplanar to the screen.

007_make_face_and_snaocqx4.png

1.08 With the circle selected, shift-select the target mesh, then hit tab to go into edit mode.

008_select_knifemesh_72qq4.png

1.09 Select Knife Project from the Mesh Tools tab of the t-menu.

009_goto_edit_mode_seu5o5i.png

1.11 This will project the circle (our "knife") on (and into) the target mesh. Please note that the projection axis is the current view axis (thus the alignment in step 1.07)

010_after_knife_projef4q7d.png

1.12 Now we can edit the frustum. Select the faces in the area of the newly cut circle...

011_select_facesuwp8l.png

1.13 Hit f to make it a single n-gon and extrude using the e key.

012_hit_f_and_extrudex6o16.png

1.14 to clean up the topology a bit, select the edges/vertices on the frame of the hole that are not edge vertices of the circle ...

014_select_edgeso6plx.png

1.15 ... and edge-slide (double tap on g) them to the nearest edge of the circle. Use the Remove Doubles command from the Mesh Tools tab of the t-menu  to remove double vertices.

015_edgeslide_and_rem0jogh.png

1.16 Select the edges that shall be sharp edges and press control-e (or use Mesh->Edges) and select Mark Sharp.

016_select_edges_and_okpjb.png

1.17 Add an edgesplit multiplier with only Sharp Edges selected.

017_add_edgesplit9srke.png

1.18 The result looks like this: so far, so good ...

018_looks_okish1ho1t.png

1.19 But if we add a matcap pseudo-material that is more glossy, the problems in the shading can be seen clearly:

019_add_matcapmrql5.png     020_problem16gqyn.png     021_problem2dxojv.png

2 Fixing the normals

2.01 To fix the normals and thus the shading of the mesh, we need a copy of it, without the hole. Add a fairly large amount of subdivision surface modifier to this copy, to make it very smooth.

022_copy_with_high_suacr34.png

2.02 The copied and smoothed helper mesh can now be hidden and even moved to another layer.

2.03 Back to our original mesh, select the edges that are not on the surface of the basic shape of the mesh. (everything extruded inwards in step 1.13)

023_select-inner-vertczpnh.png

2.03 Invert your selection by pressing control-i (or using Select->Inverse).

024_select_inverse52rwa.png

2.04 On the Data tab of the mesh, under Vertex Group, add a vertex group, and Assign the selected vertices. Invert the selection again, to only those vertices that are not on the surface of the basic mesh, and Remove them from the Vertex group.

025_assign_vertexgrouenru2.png

2.05 Add a Data Transfer modifier to the mesh. Point the source object to the helper mesh created in 2.01. Select Face Corner Data and hit the Custom Normal Button. Also select the vertex group created in 2.04 in the Generate Data Layers part of the modifier.

026_add_data_transferdaou4.png

2.06 The data modifier now assigns the normals of the helper mesh to all vertices of the mesh with the hole cut into, that are assigned to the vertex group from step 2.04. (On more complex meshes, its often useful to only make a helper mesh with the most basic geometry (the curved surface where the hole should be cut into) and to exclude vertices that are not in the area of the hole from the vertex group.)

028_result177p9d.png     029_result2bjoo2.png

2.07 Now only one problem remains: the Data Transfer modifier cannot be applied! So exporting to unity removes it. To fix this issue, head over to the DATA tab of the object again. Under Normals, select Auto Smooth and hit the button Add Custom Split Normals Data from the Geometry Section under Geometry Data.

027_add_autosmooth_an3xrp0.png

 

You can now apply the Data Transfer modifier and export the mesh into unity, where the normals will still look perfectly.

 

 

 

Edited by InsaneDruid
Link to comment
Share on other sites

  • 2 weeks later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...