Skip to content

Instantly share code, notes, and snippets.

@lyuma
Last active November 18, 2020 09:52
Show Gist options
  • Select an option

  • Save lyuma/c5cd4f031e45210e9cf96dc685c7d229 to your computer and use it in GitHub Desktop.

Select an option

Save lyuma/c5cd4f031e45210e9cf96dc685c7d229 to your computer and use it in GitHub Desktop.
/*
Original file :
Storage for distribution - Lyuma
https://gist.github.com/lyuma
rounded_trail for quest
LICENSE : CC0
*/
// 2019-09-30 customized for quest.
Shader "Unlit/trail_customized_quest"
{
Properties
{
_Color ("Solid Color", Color) = (1,1,1,1)
_InvisibleDistance ("Invisible Distance from Camera", Float) = 500.0
}
SubShader
{
Tags { "Queue"="AlphaTest" "RenderType"="Opaque" }
LOD 100
Cull Back
Blend One Zero
ZWrite On
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma target 3.0
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
float4 _Color;
float _InvisibleDistance;
#ifdef USING_STEREO_MATRICES
static float3 centerEyePos = 0.5 * (unity_StereoWorldSpaceCameraPos[0] + unity_StereoWorldSpaceCameraPos[1]);
#else
static float3 centerEyePos = _WorldSpaceCameraPos;
#endif
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
if (distance(mul(unity_ObjectToWorld, v.vertex).xyz, centerEyePos.xyz) > _InvisibleDistance) {
o.vertex = 0./0.;
}
o.uv = v.uv;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float l = length(i.uv);
return float4(_Color.xyz,1);
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment