How to get the global position of a vertex in a Cg vertex shader?

I'm trying to write a Shader with Cg that calculates a vertex's uv-texcoord out of its position in 3d space. I got some results but the shader obviously uses the positions of the vertices relative to the local coordinate system of the mesh, because every GameObject I applied this shader to gets texture coordinates accordingly to its rotation. And that's the way it should behave normally, of course. However, I wan't to compute the global - the world vertex coordinates. Is there any way to retrieve them in Cg? Maybe through some glstate.matrix multiplications? I don't quite get these yet.

Something like this should work (see more in the sparse docs).

// v.vertex is the input vertex in the vertex shader
float3 worldPos = mul (_Object2World, v.vertex).xyz;