0

This will be my second question regarding my ongoing VR project.

I am making a photosphere cardboard app.

I have added a sphere and inside of it, I have placed the Main camera on 0,0,0 position.

Inside of the cube I have placed a 3d cube. If user gazes towards it for some specific seconds, the equirectangular textures on the sphere will change via script.

Now I am using the GvrReticlePointer in this project, and I can't seem to find the white dot anywhere except when it is on the 3d cube. I would really like to know what is causing the reticle to disappear on the scene and how to fix it.

Thanks in advance.

Deep Das
  • 76
  • 11
  • 1
    Does your sphere have a collider component? I am not sure if you can detect a collider from inside but you can use a simple Canvas on your camera then add an image with your reticule in front of it. – Ludovic Feltz Jun 07 '17 at 15:19
  • Yes, the sphere has a sphere collider component added to it. The workaround you have suggested looks good. But sadly it could not be used in my project. Do we have some kind of inverted collider in unity? – Deep Das Jun 08 '17 at 07:05

1 Answers1

0

Answering this question myself!

Just use this shader. Works like a charm!

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

SubShader{
    Pass {
    Cull Front
        Tags {"LightMode" = "Always"}

        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(sphereCoords.x * 0.5 + 0.5, 1 - sphereCoords.y);
                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"
}
Deep Das
  • 76
  • 11