unity3d 在球体中固定Unity 360照片

pdkcd3nj  于 2023-01-05  发布在  其他
关注(0)|答案(2)|浏览(137)

我想修复我的360照片在一个球。正如你所看到的,它看起来打破了当我把照片在我的球。我也想保持在我的球透明度(见窗口。)所以也许着色器应该包括透明度,有人知道如何编码吗?
my sphere

eufgjt7s

eufgjt7s1#

Shader "Custom/Equirectangular" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Diffuse (RGB) Alpha (A)", 2D) = "gray" {}
}

SubShader{
    Pass {
        Tags {"LightMode" = "Always"}
        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 = UnityObjectToClipPos(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(1 - (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"

}

rks48beu

rks48beu2#

Shader "Custom/Equirectangular" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Diffuse (RGB) Alpha (A)", 2D) = "gray" {}
}

SubShader{
    Pass {
        Tags {"LightMode" = "Always" "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha
        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 = UnityObjectToClipPos(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(1 - (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"

}

相关问题