-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathToonOutlineNormal.shader
More file actions
76 lines (63 loc) · 2.28 KB
/
ToonOutlineNormal.shader
File metadata and controls
76 lines (63 loc) · 2.28 KB
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
Shader "Custom/ToonOutlineNOrmal" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_OutlineColor("Color", Color) = (1,1,1,1)
_OutlineRange("Range outline", Range (-1.,1.)) = 0.
_Limits("Limites", Vector) = (0.,0.5,0.7,1.)
_Bump("Normal map", 2D) = "white" {}
_NormalIntensity("Normal intensity", Range(0.0,3.0)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Toon
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _Bump;
sampler2D _MainTex;
float3 _Limits;
half _NormalIntensity;
struct Input {
float2 uv_MainTex;
float3 WorldNormalVector;
float3 viewDir;
float2 uv_Bump;
};
half4 LightingToon(SurfaceOutput s, half3 lightDir, float3 worldNormal)
{
float d = dot(s.Normal, lightDir);
float n = step(_Limits.x, d)*step(d,_Limits.y);
float n1 = step(_Limits.y, d)*step(d,_Limits.z);
float n2 = step(_Limits.z,d);
n = 0.3*n + n1*0.7 + n2;
half4 c;
c.rgb = s.Albedo*n;
return c;
}
fixed4 _OutlineColor;
fixed _OutlineRange;
fixed4 _Color;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
void surf (Input IN, inout SurfaceOutput o) {
// Albedo comes from a texture tinted by color
float d = dot(o.Normal, IN.viewDir);
d = 1-step(d,_OutlineRange);
fixed4 c = d*tex2D (_MainTex, IN.uv_MainTex) * _Color + (1-d)*_OutlineColor;
o.Albedo = c.rgb;
//o.Normal = UnpackNormal (tex2D (_Bump, IN.uv_Bump))*_NormalIntensity;
o.Normal = UnpackScaleNormal(tex2D(_Bump, IN.uv_Bump),_NormalIntensity);
//o.Normal = UnpackNormal(tex2D(_Bump, IN.uv_Bump));
// Metallic and smoothness come from slider variables
o.Alpha = c.a;
// float3 worldNormal; INTERNAL_DATA - contains world normal vector if surface shader writes to o.Normal.
//To get the normal vector based on per-pixel normal map, use WorldNormalVector (IN, o.Normal).
}
ENDCG
}
FallBack "Diffuse"
}