Forum Discussion
suppenhuhn
11 years agoExplorer
Adding Alpha CutOff to the Crossair Shader ?
Hi,
i'm trying to add a "waiting circle" round the gaze-cursor used in the great new utilities samples.
First i tried to duplicated the gaze-cursor and gave it a new material using the unlit/transparent cutout shader - but it seems that it's not working, i can't see it at all - because it's always facing away from the camera.
Changing the gaze_cursors shader to unlit/transparent cutout makes the cursor disappear - but rotating it 180°, deactivate the crossairscript and used as a child of the regular cursor it's visible. BUT as soon you hover over a menu button - it disappears because of the depth i guess.
So i need the crossair-script activated to get the fixed depth of that waiting circle - but this scripts makes the object facing away from the camera. Using the crossair shader -> it's visible but no alpha cutoff is possible...
So i'm no shader-crack or coder-crack at all and i added two lines to the crossair shader - but i'm sure it's not enough :oops:
I got that AlphaCut of Slider in the editor but it has no effect when changing this value.
Is it possible to add Alpha CutOff to the Crossair Shader ?
i'm trying to add a "waiting circle" round the gaze-cursor used in the great new utilities samples.
First i tried to duplicated the gaze-cursor and gave it a new material using the unlit/transparent cutout shader - but it seems that it's not working, i can't see it at all - because it's always facing away from the camera.
Changing the gaze_cursors shader to unlit/transparent cutout makes the cursor disappear - but rotating it 180°, deactivate the crossairscript and used as a child of the regular cursor it's visible. BUT as soon you hover over a menu button - it disappears because of the depth i guess.
So i need the crossair-script activated to get the fixed depth of that waiting circle - but this scripts makes the object facing away from the camera. Using the crossair shader -> it's visible but no alpha cutoff is possible...
So i'm no shader-crack or coder-crack at all and i added two lines to the crossair shader - but i'm sure it's not enough :oops:
// 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)
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5 // ADDED
}
SubShader
{
LOD 100
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "TransparentCutout" // ADDED
}
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
}
}
}
I got that AlphaCut of Slider in the editor but it has no effect when changing this value.
Is it possible to add Alpha CutOff to the Crossair Shader ?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 years ago
- 2 years ago
- 6 months ago
- 6 months ago
- 4 months ago