I'm trying to implement shadow mapping with cube maps. I believe I've done the first stage by filling the cube map, but for the final shading pass I am unsure how to exactly calculate the cubemap coordinates. Any pointers?

To use a cube map for shadows you need to recreate the world position of the pixel you are rendering and from that get the normal that points at that world position from the light source, now you can calculate the distance of your pixel from the light source as well as check the cube map for the distance to the first shadow casting object.

Vertex shader needs to send along the z and w components of the vertices so you can perform the unprojection in the fragment shader

output.position = mul(input.position, worldViewProjMatrix);
output.depth.xy = output.position.zw;


Then you can combine these values with the inverse projection matrix in the pixel shader to recreate the world position of each pixel:

float4 projectedPos = float3(input.position.xy, input.depth.x / input.depth.y, 1);
float4 worldPos = mul(projectedPos, invProjectionMatrix);
float4 lightDir = worldPos - lightPos

float4 normal = normalize(light2pixel);
float dist = distance(worldPos, lightPos);