Projecting a plane onto a sphere

So, I have a Sphere (right in the attached image), a camera (in the center of the sphere) and a Quad in between (the Ubuntu Logo). What I want to achieve is making some kind of projection from the cam to the sphere so I can get the Ubuntu logo printed in the sphere. The goal is getting the pixels of the texture and getting the equirectangular projection of the logo (like the quad in the left).

My first thought was raycasting every pixel in the logo and painting it in the sphere, but doing it with c# is too slow and not as good as I thought.

After this i thought using a blending shader so the logo is printed on the sphere. But I don’t think there’s a way to write the texture from that.

Does anybody have any better idea? or anybody knows a way to get the information from the zbuffer to get the pixel that is printed on top of the ones in my sphere texture?

Thanks so much :slight_smile:

OK, I finally solved it thanks to this:

If someone wants to know how, I just followed my first instinct. Iterating for every frame of the sphere’s texture, getting its position in real world and raycasting to the camera. If the raycast passes through the logo I get the color of the raycasthit and paint my sphere texture.

Nice result :')

I know this is a really old question, But I would like to share a small snippet of code that replicates the askers solution, because I stumbled upon this post today and had to painstakingly implement this rough concept.
This code is pretty slow and isn’t perfect, but it works. It loops through the entire texture of the sphere and draws anything to it that is in the path from the zero vector to the radius of the sphere.

for (int x = 0; x < sphereTex.width; ++x) {
    for (int y = 0; y < sphereTex.height; ++y) {
        float phi = y * Mathf.PI / sphereTex.height;
        float theta = x * (1 / Mathf.Cos(l1)) * Mathf.PI / (sphereTex.width / 2);
        //Debug.DrawLine(new Vector3(r * Mathf.Sin(phi) * Mathf.Cos(theta), r * Mathf.Cos(phi), r * Mathf.Sin(phi) * Mathf.Sin(theta)),
        //                new Vector3(0, 0, 0), Color.magenta, 1f);
        RaycastHit rch = new RaycastHit();
        bool hit = Physics.Raycast(new Vector3(0, 0, 0), new Vector3(r * Mathf.Sin(phi) * Mathf.Cos(theta), r * Mathf.Cos(phi), r * Mathf.Sin(phi) * Mathf.Sin(theta)), out rch, r - 3);
        if (hit && rch.distance > 3) {
            Debug.Log("hit at: " + x + " " + y);
            Debug.Log("distance: " + rch.distance);
            sphereTex.SetPixel(-x, -y, exampleTex.GetPixel((int)(-rch.textureCoord.x * exampleTex.width), (int)(rch.textureCoord.y * exampleTex.height)));