Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created July 2, 2016 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save unitycoder/a4ffdf0437de63b4bdbfcd28f3c0cd35 to your computer and use it in GitHub Desktop.
Save unitycoder/a4ffdf0437de63b4bdbfcd28f3c0cd35 to your computer and use it in GitHub Desktop.
FakeTubeishLight Shader
Shader "Custom/FakeTubeishLight"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
CGPROGRAM
#pragma surface surf SimpleSpecular
half4 LightingSimpleSpecular (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
half4 c = half4(0,0,0,0);
int steps = 16;
// sample light many times with different values
for(int i=0;i<steps;i++)
{
half3 l = lerp(half3(1,1,i),half3(i,1,1),fmod(_Time.x*10,1));
half3 h = normalize (lightDir*l + viewDir);
half diff = max (0, dot (s.Normal, lightDir*l));
float nh = max (0, dot (s.Normal, h));
float spec = pow (nh, 10.0);
c.rgb += (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
}
c.rgb /=steps;
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
}
ENDCG
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment