Search code examples
c#unity-game-engineshader360-panoramaphotosphere

dotted lines are showingup in an image of a photosphere


i have created a photosphere and added an equirectangular shader inside the sphere and then i have added the image.the issue is ("dotted lines are shown on the image how to solve it?)you can see the dotted lines

there is distortion of the image

the source code of shader i used is

Shader "Unlit/rect"{
Properties {

    _MainTex (" Base (RGB)", 2D) = "gray" {}
}

SubShader{
    Pass {
        Tags {"RenderType"="Opaque" }
     cull front
        CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma fragmentoption ARB_precision_hint_fastest
            #pragma glsl
            #pragma target 3.0

            #include "UnityCG.cginc"

            struct appdata {
               float4 vertex : POSITION;
               float3 normal : NORMAL;
            };

            struct v2f
            {
                float4    pos : SV_POSITION;
                float3    normal : TEXCOORD0;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                o.normal = v.normal;
                return o;
            }

            sampler2D _MainTex;

            #define PI 3.141592653589793

            inline float2 RadialCoords(float3 a_coords)
            {
                float3 a_coords_n = normalize(a_coords);
                float lon = atan2(a_coords_n.z, a_coords_n.x);
                float lat = acos(a_coords_n.y);
                float2 sphereCoords = float2(lon, lat) * (1.0 / PI);
                return float2(sphereCoords.x * 0.5 + 0.5, 1 - sphereCoords.y);
            }

            float4 frag(v2f IN) : COLOR
            {
                float2 equiUV = RadialCoords(IN.normal);
                return tex2D(_MainTex, equiUV);
            }
        ENDCG
    }
}
FallBack "VertexLit"

}


Solution

  • it can be cause by several reasons. the two off the top of my head are:

    1. The image is degraded by Unity's import settings: in this case go select the image in your Project tab, in the Inspector uncheck Generate Mip-Maps and make sure the import resolution at the bottom of Inspector is set to something higher than the actual image resolution (e.g. image is 1480x1480, then set import settings to 2048x2048)

    2. The sphere mesh that you are mapping your image on has UV problems. I mean, the default spheres in different programs have different UV maps. Unity's default sphere is different from Blender's or Maya's spheres. If you tested this image in your 3D modeling software and it worked there than export THAT sphere and use it in Unity for your image.