Skip to content

Instantly share code, notes, and snippets.

@SoylentGraham
Created September 27, 2018 18:28
Show Gist options
  • Save SoylentGraham/b19fd513f3b369a94ae50d32de003f1f to your computer and use it in GitHub Desktop.
Save SoylentGraham/b19fd513f3b369a94ae50d32de003f1f to your computer and use it in GitHub Desktop.
Very simply lit shader for particle system that uses vertex/particle system colour
Shader "NewChromantics/NormalDotLight"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Cull Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityLightingCommon.cginc" // for _LightColor0
struct v2f
{
float4 vertex : SV_POSITION;
float3 Colour : COLOR;
float Light : TEXCOORD0;
};
v2f vert (appdata_full v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
float3 worldNormal = UnityObjectToWorldNormal(v.normal);
o.Light = dot(worldNormal, _WorldSpaceLightPos0.xyz);
o.Colour = v.color;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float3 Rgb;
if ( i.Light < 0 )
{
float Shadow = -i.Light;
Rgb = lerp( i.Colour, float3(0,0,0), Shadow);
}
else
{
float Light = i.Light * i.Light* i.Light;
Rgb = lerp( i.Colour, float3(1,1,1), Light);
}
return float4(Rgb,1);
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment