Create material at runtime for voxel terrain

I finally got some voxels working in lumberyard. I have hacked in a voxel terrain in cryengines main code base. I have the voxels generating/meshing and I am creating a RenderMesh for each of the chunks. I need to apply a material to the render mesh in order to get the textures showing.

The texture is generated at runtime by the voxel library, it generates a texture atlas based on the block types in use. I need to create a material with this texture so that the texture can then be rendered out on the block. What is the best way to handle this?

I have created the mesh with the texture uv set to the pixel locations needed on the texture. I attempted to load the material_terrain_default material and use it. However if I use it directly I just get white blocks. I tried to replace the texture by loading the material and swapping the texture via

    m_voxelMaterial=gEnv->p3DEngine->GetMaterialManager()->LoadMaterial("Materials/material_terrain_default");
    uint8 diffuseSlot=gEnv->p3DEngine->GetMaterialHelpers().FindTexSlot("Diffuse"); //Bumpmap, Specular

    SShaderItem &shaderItem=m_voxelMaterial->GetShaderItem();
    IRenderShaderResources *shaderResources=shaderItem.m_pShaderResources;
    TexturesResourcesMap *pTextureReourcesMap=shaderResources->GetTexturesResourceMap();
    SEfResTexture *textureResource=&(*pTextureReourcesMap)[diffuseSlot];
    textureResource->m_Sampler.m_pITex=m_terrainTexture;

but something happened as I got

<11:10:32> [Error] Failed to create an input layout for material "materials/material_terrain_default".
The shader and the vertex formats may be incompatible.
Vertex format: "1".  Shader expects: "5".

I use SVF_P3F_C4B_T2F (which is eVF_P3F_C4B_T2F=1) on the RenderMeshes, eVF_P3S_N4B_C4B_T2S=5 so I am guessing the Terrian.Layer shader is likely not the best one to use, unless I want to stuff the normals.

Is there a better material to start with? What is the proper way to set the texture on the material? Is there a better way to do this?

I switched to using the Illum shader and replacing to the texture using the above and it seems to work for the moment.