PDI->DrawMesh crash

Hi!

I’m new to this so I don’t really know my way around to well.
I’m trying to draw a custom mesh but when I, in the SceneProxy, call PDI->DrawMesh the game just crashes and the only thing in the VS output is

Couldn't find Shader TBasePassVSFCachedVolumeIndirectLightingPolicy for Material Resource WorldGridMaterial!
		With VF=FWaterSurfaceVertexFactory, Platform=PCD3D_SM5 
		ShouldCache: Mat=1, VF=0, Shader=1 
		Material Usage = MSM_DefaultLit, BLEND_Opaque, SpecialEngine, TSNormal

And I have no clue what is causing it so if anyone knows what might be causing the issue then please help me out here. Here’s the code where I render the mesh.

FMeshBatch Mesh;
		FMeshBatchElement& BatchElement = Mesh.Elements[0];
		Mesh.bWireframe = bWireframe;
		Mesh.VertexFactory = &VertexFactory;
		Mesh.MaterialRenderProxy = MaterialProxy;
		Mesh.ReverseCulling = IsLocalToWorldDeterminantNegative();
		Mesh.Type = PT_TriangleList;
		Mesh.DepthPriorityGroup = SDPG_World;

		BatchElement.IndexBuffer = &IndexBuffer;
		BatchElement.PrimitiveUniformBuffer = CreatePrimitiveUniformBufferImmediate(GetLocalToWorld(), GetBounds(), GetLocalBounds(), true);
		BatchElement.FirstIndex = 0;
		BatchElement.NumPrimitives = IndexBuffer.Indices.Num() / 3;
		BatchElement.MinVertexIndex = 0;
		BatchElement.MaxVertexIndex = VertexBuffer.Vertices.Num() - 1;
		PDI->DrawMesh(Mesh);

Whats your FWaterSurfaceVertexFactory function “ShouldCache” look like? Im asking this coz in the error output, it says “ShouldCache: Mat=1, VF=0, Shader=1”. So the Material and the Shader but not the Vertex Factory should be cached. So I am thinking that your vertex factory is not being properly cached and so therefore its not getting properly added to the vertex factory shader library.

Thanks! I tried that and now it works! I guess I just set it to false because I wasn’t quite sure of what it did.