Fix crashes caused when terrain materials don't get created (e.g. due to cg shader bug on Windows/D3D9).  Should resolve Bug #1284.
Merge remote-tracking branch 'cc9cii/crash-fix-cg-shader'