Created
September 27, 2018 18:28
-
-
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
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 "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