Last active
January 7, 2018 15:20
-
-
Save inosyan/94e5e40781346db1d20272e583022d0e to your computer and use it in GitHub Desktop.
Shader "LightSphere" for Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "LightSphere" { | |
SubShader { | |
Tags { "RenderType" = "Opacity" } | |
Cull Off | |
Pass { | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
struct v2f { | |
float4 pos: SV_POSITION; | |
float2 uv: TEXCOORD0; | |
float4 worldPos: TEXCOORD1; | |
}; | |
v2f vert(appdata_base v) { | |
v2f o; | |
o.pos = UnityObjectToClipPos(v.vertex); | |
o.uv = v.texcoord; | |
o.worldPos = mul(unity_ObjectToWorld, v.vertex); | |
return o; | |
} | |
fixed4 frag(v2f i): SV_Target { | |
float dist = distance(i.worldPos, _WorldSpaceCameraPos); | |
dist = int(dist * 10) / 10 / 1000.0; | |
return fixed4( | |
i.uv.x % dist / dist, | |
i.uv.y % dist / dist, | |
(dist * 100 % 1), | |
1); | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment