Once a swell starts getting near a coastline, its behaviour begins to change as it starts to propagate over shallower water. Out in the open ocean, the water was deep enough compared with the height of the waves for the presence of the sea bed not to have any effect; but once the water becomes shallow enough, the configuration of the sea floor (the bathymetry) starts to seriously affect the waves. This change in behaviour is based on the fact that waves slow down in shallow water, and the amount they slow down is dependent on the water depth. If the bathymetry is irregular, some parts of a wave will slow down more than others.
Forgetting irregular bathymetry for a moment, let me just explain what happens to a wave when it passes from deep water into shallow water. When the wave is in such deep water that there is absolutely no effect from the bed, the speed of that wave is solely dependent upon the wave period" to be precise, the wave speed in metres per second is 1.56 times the period in seconds. Conversely, when the water depth goes below a certain value, the speed of the wave is no longer dependent on the wavelength, only the depth. Here, the wave speed (in m/s) is given by 3.13 times the square root of the depth in metres. In between these two extremes the wave is said to be in 'intermediate water', and the wave speed is a more complicated relationship involving both period and depth.
If a wave comes out of deep water and straight into really shallow water within a very short distance, the wave height will increase dramatically. This you can see happening at surf spots like Mavericks, where powerful swells come out of deep water and suddenly 'trip up' onto a shallow rock shelf. The reason why they do this is linked to the fact that the wave slows down as it hits shallow water. The easiest way to explain this is to think in terms of a wave group: the waves at the front of a group will hit shallow water first, so they will slow down while the ones at the back of the group will keep going at their original speed. This squashes up the group and brings the waves closer together. And squashing them up closer together makes them higher. If you can't see why this is, just take a piece of wire (say a coat hanger), put it on the table, and put some waves in it. Then squash up the wire from one end to the other. The waves in the wire should get bigger.
Now, coastal bathymetry is never so regular and straight that the water depth decreases uniformly as you get closer to the shore. In reality, the depth will be deeper in some spots and shallower in others. This means that, as a wave crest approaches the shore, some parts of it will slow down, and others will keep going at a faster speed. For example, if there is a deep trench next to a shallow reef, the part of the wave crest propagating over the trench might keep going at its deep-water speed, while the part that hits the reef will slow down considerably. This is where refraction comes in. Refraction is when one part of a wave crest travels slower than another, making the wave bend towards that part which is travelling slower. Now, because wave speed near the shore depends upon water depth, refraction will always steer the waves towards shallow water. A good analogy of refraction is if you are travelling along in your car and the brakes are binding on one side. The car will tend to veer off to that side.
By steering the waves in this way, refraction is a crucial factor in determining the characteristics of any surfing break: it can make the waves bigger, smaller, longer, shorter, faster, slower or hollower. It can also dramatically change the behaviour of the surf along a whole stretch of coastline, by acting on the continental shelf before the waves get anywhere near breaking.
One example of how refraction affects the way waves break is called bathymetric focusing or concave refraction. Imagine a shallow slab of reef sticking out from the shore, with relatively deep water either side of it. As a swell line approaches, the middle of the wave starts to propagate over shallow water but the parts either side of it keep going at a faster speed because they are in deeper water. The middle slows down but the outsides do not. As a result, the wave is focused in towards the middle. The result is a bowling wave where all the energy that would have gone into the deep area is concentrated into the peak instead. This makes the wave bigger and more powerful. The reef acts as a 'swell magnet', and the increase in size can sometimes be surprising. At some breaks, the diminution of a long-travelled swell is more than compensated for by the effects of local refraction.
Another good example of refraction at work is at the classic pointbreak. Imagine a headland next to a bay with shallow water (typically a cobblestone beach or a reef) running down one side of the headland, and deep water in the middle. The stretch of coast where the waves are going to break (on the side of the headland) is almost at right angles to the direction of wave approach. As a swell line comes in, one end of it will slow down and bend in towards the side of the headland, and the rest of it will continue on towards the middle of the bay. This process is the opposite of that described above and is called bathymetric defocusing or convex refraction. The energy is spread out over a wider area and the waves are reduced in size. So, at a typical pointbreak, the power and size are reduced by defocusing, but the waves are usually longer, more walled-up. At really good pointbreaks the waves tend to stay the same size, or even get bigger, as you go down the line.