   Heightmap with holes?
  I'm planning on making my terrain with a heightmap and then make an algorithm to create the triangles from that. Now I have 2 questions:1) I was thinking of creating some caves (as a mesh) but then I need a whole in the heightmap somehow, is that even possible? If so, how? I was thinking of giving the pixel in the heightmap a value which isn't "valid" or something and then I'll have to have cave entrances on not-so-extremely-sloping "walls" because then I'd have a huge whole.2) How am I going to do shadowing + lighting?   
  1) That's one way to do it. Just don't add triangles if one of their vertices would have an invalid value. LOD would be not so easy though, but that's probably not an issue.2) Shadowing/Lighting could be done as normal as long as you use the correct normals at the holes' edges. For that you'd need to take the "in-hole" geometry into account (e.g. the walls of a cave), so that requires some amount of tweaking. You might consider using a normal map and updating the normals in the fly, as soon as you know the hole-filling geometry.   ;  Another possibility is to superimpose a mesh with a portal. The mesh forms the "outer" geometry and need not necessarily have the same geometric resolution as the height map. Its purpose is (a) to hide the height map behind it, and (b) to have a frame for the portal. Care must be taken not to have problems with collision with the height map mesh behind the portal, of course.   