How to smooth shade an object while retaining hard edges?
I frequently come to the problem of having a mesh with parts I would like to render smooth and "hard" edges connecting them.
How can I set the mesh to show the sharp edges but render everything else smooth?
In the example I would like the sides of the individual cylinders render smooth but the intersection between bottom and top to be sharp/flat
There are a few ways to do this but the quickest and most efficient (in your case here) is to just smooth it the same way, using Shade Smooth and then adding an Edge Split modifier to the mesh.
From the wiki
The EdgeSplit modifier splits edges within a mesh. The edges to split can be determined from the edge angle (i.e. angle between faces forming this edge), and/or edges marked as sharp.
Splitting an edge affects vertex normal generation at that edge, making the edge appear sharp. Hence, this modifier can be used to achieve the same effect as the Autosmooth button, making edges appear sharp when their angle is above a certain threshold. It can also be used for manual control of the smoothing process, where the user defines which edges should appear smooth or sharp
Here it is as you have it above..
With the modifier added
While what iKlsR says is indeed the most efficient, it's often preferred to either add edge loops on both sides of the hard edge, or bevel it (Ctrl + B). When smooth shaded this produces a more realistic surface since there's seldom any truly sharp corners in reality, and also catches specular highlights nicely showing off the model better.
Note that the Edge Split modifier shouldn't be used when beveling or using edgeloops to sharpen corners. Edge Split physically cuts the model to fake a sharp corner, whereas beveling actually creates the corner.
It is perhaps useful to mention to the reader that the _EdgeSplit_ modifier and _Bevelling_ operations are not mutually exclusive techniques. Doing manual bevels helps guide the transition from smooth to flat in those sections where _EdgeSplit_ produces unnaturally abrupt transitions.
For anyone really new to Blender -- Bevel is a modifier. Look for it there.
This is basically like the old Autosmooth, but it works in Cycles and the viewport in addition to BI.
If you don't know what Autosmooth is, it behaves like the edge split modifier, but without actually splitting edges:
There is no edge split modifier used in the above screenshot.
This is amazing. It fixed all my shading problems caused by subdiv / 1.0 creases at once.
This should actually be the top answer, or the accepted answer should be updated.
The following method is probably best for real-time (e.g. games) and low-poly work in particular.
Gandalf3 mentioned the new Autosmooth feature, but I'd like to add that with it enabled, you can manually select faces, edges and vertices that you would like to be hard - the Autosmooth 'Angle' setting merely creates a base smoothing to work from. If you then go into edit mode and look in Shading / UVs > Shading, there are options to mark vertices, edges and faces. With Autosmooth disabled, you can see the edges/vertices you have marked, but they will not be rendered flat, but when Autosmooth is enabled, they will be rendered correctly.
As Gandalf3 mentions, unlike the split edges modifier, Autosmooth does not physically split elements in order to get hard edge lighting, so is ideal for low-poly work, and seems to be designed for better compatibility with the FBX and OBJ formats, which are commonly used in games.
Another simple way to do this would be to select the faces that you want smooth (in this case the non-horizontal surfaces) and select Shading: Smooth in the tool panel. Then, select the faces that you want sharp (horizontal surfaces, in this case) and select Shading: Flat.
It probably won't give as nice results as Greg's method, but it might be quicker and simpler.
This is a useful method if you need a lowpoly mesh to import into i.e. Unity. Just make sure to import tangents.