title: Spherical mapping
body: <p>I'm having trouble projecting objects (for example a plane) onto a spherical surface.</p>
  
  <p>The shader just have to take vertex local position (P0), convert it in world coordinates (P1), then find the vector from a given center (C) to P1 (P1 - C). So normalize this vector and multiply by a given coefficient, and finally convert back to local coordinates.</p>
  
  <p>I'm working in Unity with surface shaders</p>
  
  <pre><code>Shader "Custom/testShader" {
     Properties {
        _MainTex("texture", 2D) = "white" {}
        _Center("the given center", Vector) = (0,0,0)
        _Height("the given coefficient", Range(1, 1000) = 10
     }
     Subshader {
        CGPROGRAM
        #pragma surface surf Standard vertex:vert
        sampler2D _MainTex;
        float3 _Center;
        float _Height;
  
        struct Input { float2 uv_MainTex; }
  
        // IMPORTANT STUFF
        void vert (inout appdata_full v) {
           float3 world_vertex = mul(unity_ObjectToWorld, v.vertex) - _Center;
           world_vertex = normalize(world_vertex) * _Height;
           v.vertex = mul(unity_WorldToObject, world_vertex);
        }
        // END OF IMPORTANT STUFF
  
        void surf (Input IN, inout SurfaceOutputStandard o) {
           o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
        }
        ENDCG
     }
  }
  </code></pre>
  
  <p>Now the problem is that in the scene, where I have some planes with this shader, they look split and much more little that what they are supposed to be. Any ideas?</p>
  
  <p>EDIT</p>
  
  <p>Here are some screenshots:
  <img src="https://i.imgur.com/Hq6OpX0.jpg" alt="The meshes without the shader">
  <img src="https://i.imgur.com/AYOREGc.jpg" alt="The same meshes with the shader"></p>