-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToonShader.shader
148 lines (143 loc) · 7.31 KB
/
ToonShader.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Shader created with Shader Forge v1.38
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
// Note: Manually altering this data may prevent you from opening it in Shader Forge
/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:Mobile/Diffuse,iptp:0,cusa:False,bamd:0,cgin:,lico:0,lgpr:1,limd:0,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:False,rpth:0,vtps:0,hqsc:False,nrmq:0,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:2,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:False,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:2865,x:32719,y:32712,varname:node_2865,prsc:2|emission-1766-OUT,olwid-5918-OUT,olcol-247-RGB;n:type:ShaderForge.SFN_Multiply,id:6343,x:32307,y:32669,varname:node_6343,prsc:2|A-7736-RGB,B-6665-RGB;n:type:ShaderForge.SFN_Color,id:6665,x:31921,y:32805,ptovrint:False,ptlb:Color,ptin:_Color,varname:_Color,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:0,c3:0,c4:1;n:type:ShaderForge.SFN_Tex2d,id:7736,x:31921,y:32620,ptovrint:True,ptlb:Base Color,ptin:_MainTex,varname:_MainTex,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Color,id:247,x:32095,y:33289,ptovrint:False,ptlb:OutlineColor,ptin:_OutlineColor,varname:node_247,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0,c2:0,c3:0.3137,c4:1;n:type:ShaderForge.SFN_Slider,id:5918,x:32017,y:33143,ptovrint:False,ptlb:OutlineWidth,ptin:_OutlineWidth,varname:node_5918,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.03461539,max:0.05;n:type:ShaderForge.SFN_Slider,id:2296,x:32017,y:33003,ptovrint:False,ptlb:Brightness,ptin:_Brightness,varname:node_2296,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1.854701,max:3;n:type:ShaderForge.SFN_Multiply,id:1766,x:32521,y:32754,varname:node_1766,prsc:2|A-6343-OUT,B-2296-OUT;proporder:6665-7736-247-5918-2296;pass:END;sub:END;*/
Shader "Shader Forge/ToonShader" {
Properties {
_Color ("Color", Color) = (1,0,0,1)
_MainTex ("Base Color", 2D) = "white" {}
_OutlineColor ("OutlineColor", Color) = (0,0,0.3137,1)
_OutlineWidth ("OutlineWidth", Range(0, 0.05)) = 0.03461539
_Brightness ("Brightness", Range(0, 3)) = 1.854701
}
SubShader {
Tags {
"RenderType"="Opaque"
}
LOD 250
Pass {
Name "Outline"
Tags {
}
Cull Front
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define _GLOSSYENV 1
#include "UnityCG.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardBRDF.cginc"
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_shadowcaster
#pragma only_renderers d3d9 d3d11 glcore gles
#pragma target 3.0
uniform float4 _OutlineColor;
uniform float _OutlineWidth;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct VertexOutput {
float4 pos : SV_POSITION;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.pos = UnityObjectToClipPos( float4(v.vertex.xyz + v.normal*_OutlineWidth,1) );
return o;
}
float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
float isFrontFace = ( facing >= 0 ? 1 : 0 );
float faceSign = ( facing >= 0 ? 1 : -1 );
return fixed4(_OutlineColor.rgb,0);
}
ENDCG
}
Pass {
Name "FORWARD"
Tags {
"LightMode"="ForwardBase"
}
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#define _GLOSSYENV 1
#include "UnityCG.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardBRDF.cginc"
#pragma multi_compile_fwdbase_fullshadows
#pragma only_renderers d3d9 d3d11 glcore gles
#pragma target 3.0
uniform float4 _Color;
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform float _Brightness;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.pos = UnityObjectToClipPos( v.vertex );
return o;
}
float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
float isFrontFace = ( facing >= 0 ? 1 : 0 );
float faceSign = ( facing >= 0 ? 1 : -1 );
////// Lighting:
////// Emissive:
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
float3 emissive = ((_MainTex_var.rgb*_Color.rgb)*_Brightness);
float3 finalColor = emissive;
return fixed4(finalColor,1);
}
ENDCG
}
Pass {
Name "ShadowCaster"
Tags {
"LightMode"="ShadowCaster"
}
Offset 1, 1
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_SHADOWCASTER
#define _GLOSSYENV 1
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardBRDF.cginc"
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_shadowcaster
#pragma only_renderers d3d9 d3d11 glcore gles
#pragma target 3.0
struct VertexInput {
float4 vertex : POSITION;
};
struct VertexOutput {
V2F_SHADOW_CASTER;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.pos = UnityObjectToClipPos( v.vertex );
TRANSFER_SHADOW_CASTER(o)
return o;
}
float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
float isFrontFace = ( facing >= 0 ? 1 : 0 );
float faceSign = ( facing >= 0 ? 1 : -1 );
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
}
FallBack "Mobile/Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}