-
Notifications
You must be signed in to change notification settings - Fork 2
/
NoeNoe Opaque Unlit GIF.shader
217 lines (207 loc) · 12.2 KB
/
NoeNoe Opaque Unlit GIF.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
Shader "Okano/NoeNoe/Opaque Unlit + GIF Overlay" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Main texture (RGB)", 2D) = "white" {}
_CrossfadeSurfaceOverlay ("Crossfade Surface / Overlay", Range(0, 2)) = 1
_TileOverlay ("Tile Overlay", 2D) = "white" {}
_TileSpeedX ("Tile Speed X", Range(-1, 1)) = 0
_TileSpeedY ("Tile Speed Y", Range(-1, 1)) = 0
_CubemapOverlay ("Cubemap Overlay", Cube) = "_Skybox" {}
_CrossfadeTileCubemap ("Crossfade Tile / Cubemap", Range(0, 2)) = 0
[MaterialToggle] _DynamicToonLighting ("Dynamic Toon Lighting", Float ) = 1
_StaticToonLight ("Static Toon Light", Vector) = (0,0,0,0)
_Ramp ("Ramp", 2D) = "white" {}
[MaterialToggle] _NoLightShading ("No Light Shading", Float ) = 0
_Emission ("Emission", Range(0.0, 1.0)) = 1
_Intensity ("Intensity", Range(0, 10)) = 1
_NormalMap ("Normal Map", 2D) = "bump" {}
_OutlineWidth ("Outline Width", Float ) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[MaterialToggle] _ScreenSpaceOutline ("Screen-Space Outline", Float ) = 0
_SpriteSheet("SpriteSheet", 2D) = "black" {}
_Rows("Rows", Float) = 0
_Columns("Columns", Float) = 0
_TotalTiles("TotalTiles", Float) = 0
_Speed("Speed", Float) = 0
_CrossfadeSpiral ("Crossfade Spiral", Range(0, 1)) = 0.5
}
SubShader {
Tags {
"RenderType"="Opaque"
}
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 "AutoLight.cginc"
#include "Lighting.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 _TimeEditor;
uniform float4 _Color;
uniform sampler2D _TileOverlay; uniform float4 _TileOverlay_ST;
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform float _CrossfadeSurfaceOverlay;
uniform float _TileSpeedX;
uniform float _TileSpeedY;
uniform samplerCUBE _CubemapOverlay;
uniform float _CrossfadeTileCubemap;
uniform sampler2D _EmissionMap; uniform float4 _EmissionMap_ST;
uniform float _Emission;
uniform sampler2D _NormalMap; uniform float4 _NormalMap_ST;
uniform float _Intensity;
uniform sampler2D _SpriteSheet;
uniform float _Speed;
uniform float _Columns;
uniform float _Rows;
uniform float _TotalTiles;
uniform float _CrossfadeSpiral;
float3 Function_node_3693( float3 normal ){
return ShadeSH9(half4(normal, 1.0));
}
uniform fixed _NoLightShading;
uniform float4 _StaticToonLight;
uniform fixed _DynamicToonLighting;
uniform sampler2D _Ramp; uniform float4 _Ramp_ST;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float2 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 posWorld : TEXCOORD1;
float3 normalDir : TEXCOORD2;
float3 tangentDir : TEXCOORD3;
float3 bitangentDir : TEXCOORD4;
LIGHTING_COORDS(5,6)
};
float2 gifUV (float Speed, float2 UV, float2 Tiles, float TileCount) {
float frame = floor(fmod(_Time.y * Speed, TileCount));
float column = fmod(frame, Tiles.x);
float row = fmod(frame-column, Tiles.y);
float2 offset = float2(row, column);
return (UV+offset) / Tiles;//float2(x,y);
}
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.normalDir = UnityObjectToWorldNormal(v.normal);
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
float3 lightColor = _LightColor0.rgb;
o.pos = UnityObjectToClipPos( v.vertex );
TRANSFER_VERTEX_TO_FRAGMENT(o)
return o;
}
float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
float isFrontFace = ( facing >= 0 ? 1 : 0 );
float faceSign = ( facing >= 0 ? 1 : -1 );
i.normalDir = normalize(i.normalDir);
i.normalDir *= faceSign;
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
float3 _NormalMap_var = UnpackNormal(tex2D(_NormalMap,TRANSFORM_TEX(i.uv0, _NormalMap)));
float3 normalLocal = _NormalMap_var.rgb;
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
float3 lightColor = _LightColor0.rgb;
////// Lighting:
float attenuation = LIGHT_ATTENUATION(i);
////// Emissive:
float4 _EmissionMap_var = tex2D(_EmissionMap,TRANSFORM_TEX(i.uv0, _EmissionMap));
float3 emissive = (_EmissionMap_var.rgb*_Emission);
float2 node_4737 = float2(saturate(dot(normalDirection,_StaticToonLight.rgb)),0.2);
float4 node_6405 = tex2D(_Ramp,TRANSFORM_TEX(node_4737, _Ramp));
float node_9074 = 3.0;
float2 node_2538 = float2(saturate(dot(normalDirection,lightDirection)),0.2);
float4 _Ramp_copy = tex2D(_Ramp,TRANSFORM_TEX(node_2538, _Ramp));
float node_9409 = 3.0;
float node_7920 = 1.0;
float node_6078 = 1.0;
float3 node_769 = viewDirection.rgb;
float node_9795 = 0.1;
float4 node_47 = _Time + _TimeEditor;
float3 node_4810 = viewDirection.brg;
float2 node_1431 = ((float2((node_9795*_TileSpeedX),(node_9795*_TileSpeedY))*node_47.g)+(1.0 - float2(((atan2(node_4810.r,node_4810.g)/6.28318530718)+0.5),(acos(node_4810.b)/(-1*3.141592654)))).rg);
float4 _TileOverlay_var = tex2D(_TileOverlay,TRANSFORM_TEX(node_1431, _TileOverlay));
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
float lightingCoeff = _Emission * 0.65;
float3 finalColor = (_Intensity*saturate((lerp( Function_node_3693( float3(0,1,0) ), 0.0, _NoLightShading )+(lightingCoeff)))*(floor(saturate((dot(node_6405.rgb,float3(0.3,0.59,0.11))+0.8)) * node_9074) / (node_9074 - 1)-0.5)*lerp( 1.0, (floor(saturate((dot(_Ramp_copy.rgb,float3(0.3,0.59,0.11))+0.8)) * node_9409) / (node_9409 - 1)-0.5), _DynamicToonLighting )*lerp(lerp(((lerp(float3(node_7920,node_7920,node_7920),(lerp(float3(node_6078,node_6078,node_6078),(texCUBE(_CubemapOverlay,float3(node_769.r,(node_769.g*(-1.0)),node_769.b)).rgb*2.0),saturate(_CrossfadeTileCubemap))*lerp(float3(node_6078,node_6078,node_6078),_TileOverlay_var.rgb,saturate((node_6078+(1.0 - _CrossfadeTileCubemap))))),saturate(_CrossfadeSurfaceOverlay))*lerp(float3(node_7920,node_7920,node_7920),_MainTex_var.rgb,saturate((node_7920+(1.0 - _CrossfadeSurfaceOverlay)))))*_Color.rgb*1.0),dot(((lerp(float3(node_7920,node_7920,node_7920),(lerp(float3(node_6078,node_6078,node_6078),(texCUBE(_CubemapOverlay,float3(node_769.r,(node_769.g*(-1.0)),node_769.b)).rgb*2.0),saturate(_CrossfadeTileCubemap))*lerp(float3(node_6078,node_6078,node_6078),_TileOverlay_var.rgb,saturate((node_6078+(1.0 - _CrossfadeTileCubemap))))),saturate(_CrossfadeSurfaceOverlay))*lerp(float3(node_7920,node_7920,node_7920),_MainTex_var.rgb,saturate((node_7920+(1.0 - _CrossfadeSurfaceOverlay)))))*_Color.rgb*1.0),float3(0.3,0.59,0.11)),(-0.5)),dot(lerp(((lerp(float3(node_7920,node_7920,node_7920),(lerp(float3(node_6078,node_6078,node_6078),(texCUBE(_CubemapOverlay,float3(node_769.r,(node_769.g*(-1.0)),node_769.b)).rgb*2.0),saturate(_CrossfadeTileCubemap))*lerp(float3(node_6078,node_6078,node_6078),_TileOverlay_var.rgb,saturate((node_6078+(1.0 - _CrossfadeTileCubemap))))),saturate(_CrossfadeSurfaceOverlay))*lerp(float3(node_7920,node_7920,node_7920),_MainTex_var.rgb,saturate((node_7920+(1.0 - _CrossfadeSurfaceOverlay)))))*_Color.rgb*1.0),dot(((lerp(float3(node_7920,node_7920,node_7920),(lerp(float3(node_6078,node_6078,node_6078),(texCUBE(_CubemapOverlay,float3(node_769.r,(node_769.g*(-1.0)),node_769.b)).rgb*2.0),saturate(_CrossfadeTileCubemap))*lerp(float3(node_6078,node_6078,node_6078),_TileOverlay_var.rgb,saturate((node_6078+(1.0 - _CrossfadeTileCubemap))))),saturate(_CrossfadeSurfaceOverlay))*lerp(float3(node_7920,node_7920,node_7920),_MainTex_var.rgb,saturate((node_7920+(1.0 - _CrossfadeSurfaceOverlay)))))*_Color.rgb*1.0),float3(0.3,0.59,0.11)),(-0.5)),float3(0.3,0.59,0.11)),(1.0 - _Color.a)));
// gif stuff
float2 gifGrid = float2(_Columns, _Rows);
float2 gUV = gifUV(_Speed, i.uv0, gifGrid, _TotalTiles);
float4 gif = tex2D(_SpriteSheet, gUV);
finalColor *= lerp(float3(1,1,1), gif.rgb, _CrossfadeSpiral);
return fixed4(finalColor+finalColor,1);
}
ENDCG
}
Pass {
Name "Meta"
Tags {
"LightMode"="Meta"
}
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_META 1
#define _GLOSSYENV 1
#include "UnityCG.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardBRDF.cginc"
#include "UnityMetaPass.cginc"
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_shadowcaster
#pragma only_renderers d3d9 d3d11 glcore gles
#pragma target 3.0
uniform sampler2D _EmissionMap; uniform float4 _EmissionMap_ST;
uniform float _Emission;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
float2 texcoord2 : TEXCOORD2;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
return o;
}
float4 frag(VertexOutput i, float facing : VFACE) : SV_Target {
float isFrontFace = ( facing >= 0 ? 1 : 0 );
float faceSign = ( facing >= 0 ? 1 : -1 );
UnityMetaInput o;
UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
float4 _EmissionMap_var = tex2D(_EmissionMap,TRANSFORM_TEX(i.uv0, _EmissionMap));
o.Emission = (_EmissionMap_var.rgb*_Emission);
float3 diffColor = float3(1,1,1);
o.Albedo = diffColor;
return UnityMetaFragment( o );
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}