How to make procedural textures to follow geometry?
Using UV mapping, This is often the most straightforward method since you can edit UV's directly and preview the changes realtime, However you only get 2D coordinates, but you have the advantage that the coordinates are editable and are stored per face-corner (they dont have to be contiguous). UV's are also well supported by many formats, game-engines and render-engines.

if your mesh has primarily a grid topology, then try the Follow-Active-Quads tool from the unwrap menu.

Using Generated mapping, this works when you deform a mesh by a modifier (ShapeKey, Lattice or Armature for example), the un-deformed mesh is used for texture coordinates.
Using TexMesh, see Mesh Data properties, This allows you to select another mesh to use for texture coordinates, this gives a lot of control but the vertex indices must match up. These have the advantage of allowing you to set XYZ coordinates, but you have to take care not to add/remove vertices from the mesh. While useful, this is a Blender specific feature.