Align cone to surface of the sphere

Hello I have this piece of code:

float sdCone(float3 p)
{
    float2 c = float2(0.5, 0.5);
    float h = 0.45;

    float q = length(p.xz);
    float2 b = float2(q, -p.y);

    return max(dot(c.xy, b), h + p.y);
}

It’s a similar function to what I have, and it returns the signed distance from a cone. I’m using the marching cubes algorithm to generate a mesh form the distance, but there is a problem. I need the cones to align with the surface of the sphere…

Here are 2 images:

Here is an image of the actual mesh:

Aligning with a sphere is a special case: if you just set what you consider the “up” vector of your cone to be the local position on the sphere, it will automagically align.

Eg if you are at point P on a sphere located at Q, then your local position is (P-Q) and if you set your cone’s transform.up vector to (P-Q) it should just work (modulo any other rotations you have going on!).

The general case is of course use the normal at the surface for this alignment, but on a sphere the normal and the local position are normal-equivalent.