Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
theboyrossy's avatar
theboyrossy
Honored Guest
9 years ago

Oculus Cursor Shader Issue?

Hi everyone!

I've got what I hope is a quick question, I've been using a shader provided by Oculus for my cursor, it's been working great but I recently updated Unity to the latest 5.3.3 and the cursor isn't working the way it used to, well actually it works almost the same, the difference now is that the cursor is much darker than it used to be, but only when the project is built (for windows currently). Previously it was quite a strong red colour but now it a very dark red (the cursor is simply a circle reticule). Nothing I'm aware of has changed besides the update to 5.3.3.

The shader code appears to be quite simple, so I hope it's a trivial issue I'm experiencing, I've posted the shader code below.

Does anyone have any idea what the issue could be? Also with regards to shaders I know next to nothing so a little hand holding would be appreciated.

    Shader "Custom/Mobile/Particles/Alpha Blended AfterTrans" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
}

Category {
Tags { "Queue"="Transparent+10" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }

BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}

SubShader {
Pass {
SetTexture [_MainTex] {
combine texture * primary
}
}
}
}
}

Any help would be appreciated.

4 Replies

Replies have been turned off for this discussion
  • Are you sure that is the shader you were previously using? That one is not the one from Oculus.

    Install the Oculus Utilities, and use the "Unlit Crosshair" shader in OVR/Moonlight/Shaders folder:

    // Unlit alpha-blended shader.
    // - no lighting
    // - no lightmap support
    // - supports tint color

    Shader "Unlit/Crosshair" {

    Properties
    {
    _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}
    _Color ("Main Color", Color) = (0.5,0.5,0.5,0.5)
    }

    SubShader
    {
    LOD 100

    Tags
    {
    "Queue" = "Transparent"
    "IgnoreProjector" = "True"
    "RenderType" = "Transparent"
    }

    Cull Off
    Lighting Off
    ZTest Always
    ZWrite Off
    Fog { Mode Off }
    Offset -1, -1
    Blend SrcAlpha OneMinusSrcAlpha

    Pass
    {
    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag

    #include "UnityCG.cginc"

    struct appdata_t
    {
    float4 vertex : POSITION;
    float2 texcoord : TEXCOORD0;
    fixed4 color : COLOR;
    };

    struct v2f
    {
    float4 vertex : SV_POSITION;
    half2 texcoord : TEXCOORD0;
    fixed4 color : COLOR;
    };

    sampler2D _MainTex;
    float4 _MainTex_ST;
    fixed4 _Color;

    v2f vert (appdata_t v)
    {
    v2f o;
    o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
    o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
    o.color = v.color;
    return o;
    }

    fixed4 frag (v2f i) : COLOR
    {
    fixed4 col = tex2D(_MainTex, i.texcoord) * i.color * _Color * 2.0;
    return col;
    }
    ENDCG
    }
    }


    }

  • Hi Peterept,

    Thanks for the reply, the shader I'm using was included in the project downloaded from the Oculus Developers blog in the post titled "Unity’s UI System in VR". https://developer.oculus.com/blog/unitys-ui-system-in-vr/

    I've tried the shader that you recommended, besides the fact my cursor now seems to dissapear when hovering my canvas (Fixed by commenting out "ZTest Always"), I'm also experiencing the same issue where the cursor is much darker when the project it built rather then when viewed in the editor.

    Very strange.
  • Hi theboyrossy
    If you are seeing different behaviour in the editor to in a build then it's possible you're seeing a Unity bug. Would you be able to share screenshots of the color difference you mentioned?
  • Hi,

    I have attached two screenshots, the first is the view in the editor, hovering over three different parts of the screen with different background colours, with the second image the same but when the project is built.