Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.29 KB | None | 0 0
  1. /*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:0,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,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:3138,x:33809,y:32864,varname:node_3138,prsc:2|custl-653-OUT,olwid-7608-OUT,olcol-3002-RGB;n:type:ShaderForge.SFN_Tex2d,id:3653,x:32843,y:32813,ptovrint:False,ptlb:MainTex,ptin:_MainTex,varname:node_3653,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:a79dc5b11061a2a45a7e4bd81636ecc1,ntxv:3,isnm:False;n:type:ShaderForge.SFN_ValueProperty,id:7608,x:33440,y:33182,ptovrint:False,ptlb:Outline Width,ptin:_OutlineWidth,varname:node_7608,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:0.01;n:type:ShaderForge.SFN_Multiply,id:653,x:33481,y:32876,varname:node_653,prsc:2|A-3653-RGB,B-6229-RGB;n:type:ShaderForge.SFN_Multiply,id:9877,x:33030,y:33280,varname:node_9877,prsc:2|A-7796-OUT,B-7673-T;n:type:ShaderForge.SFN_Time,id:7673,x:32843,y:33351,varname:node_7673,prsc:2;n:type:ShaderForge.SFN_TexCoord,id:7674,x:32843,y:33127,varname:node_7674,prsc:2,uv:0,uaff:False;n:type:ShaderForge.SFN_Add,id:2892,x:33223,y:33280,varname:node_2892,prsc:2|A-7674-UVOUT,B-9877-OUT;n:type:ShaderForge.SFN_ValueProperty,id:7796,x:32843,y:33291,ptovrint:False,ptlb:Speed,ptin:_Speed,varname:node_7796,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:0.05;n:type:ShaderForge.SFN_ComponentMask,id:9419,x:33105,y:33058,varname:node_9419,prsc:2,cc1:1,cc2:0,cc3:-1,cc4:-1|IN-7674-UVOUT;n:type:ShaderForge.SFN_Color,id:6229,x:32843,y:32992,ptovrint:False,ptlb:Tint,ptin:_Tint,varname:node_6229,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Hue,id:2707,x:33455,y:33465,varname:node_2707,prsc:2|IN-2892-OUT;n:type:ShaderForge.SFN_Tex2d,id:3002,x:33455,y:33280,ptovrint:False,ptlb:Outline Texture,ptin:_OutlineTexture,varname:node_3002,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:7af06849277e8ce4bae935afac2eba1c,ntxv:0,isnm:False|UVIN-2892-OUT;proporder:3653-7608-7796-6229-3002;pass:END;sub:END;*/
  2.  
  3.  
  4. Shader "Snail/PolyColorWaveTest" {
  5.  
  6. Properties
  7. {
  8. _MainTex ("Texture", 2D) = "white" {}
  9. _MainTex ("MainTex", 2D) = "bump" {}
  10. _Saturation ("Saturation", Range(0, 1)) = 1
  11. _Value ("Value", Range(0, 1)) = 1
  12. _OutlineWidth ("Outline Width", Float ) = 0.0001
  13. _Speed ("Speed", Float ) = 0.2
  14. _Tint ("Tint", Color) = (1,1,1,1)
  15. _OutlineTexture ("Outline Texture", 2D) = "white" {}
  16. }
  17. SubShader
  18. {
  19. Tags { "RenderType"="Opaque" "Queue"="Geometry+0" "RenderType"="Opaque" "LightMode" = "ForwardBase" }
  20. Cull Back
  21.  
  22. Pass {
  23. Name "Outline"
  24. Tags { }
  25. Cull Front
  26.  
  27. CGPROGRAM
  28. #pragma vertex vert
  29. #pragma fragment frag
  30. #include "UnityCG.cginc"
  31. #pragma fragmentoption ARB_precision_hint_fastest
  32. #pragma multi_compile_shadowcaster
  33. #pragma only_renderers d3d9 d3d11 glcore gles
  34. #pragma target 3.0
  35. uniform float _OutlineWidth;
  36. uniform float _Speed;
  37. uniform sampler2D _OutlineTexture; uniform float4 _OutlineTexture_ST;
  38. struct VertexInput {
  39. float4 vertex : POSITION;
  40. float3 normal : NORMAL;
  41. float2 texcoord0 : TEXCOORD0;
  42. };
  43. struct VertexOutput {
  44. float4 pos : SV_POSITION;
  45. float2 uv0 : TEXCOORD0;
  46. };
  47. VertexOutput vert (VertexInput v) {
  48. VertexOutput o = (VertexOutput)0;
  49. o.uv0 = v.texcoord0;
  50. o.pos = UnityObjectToClipPos( float4(v.vertex.xyz + v.normal*_OutlineWidth,1) );
  51. return o;
  52. }
  53. float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
  54. float isFrontFace = ( facing >= 0 ? 1 : 0 );
  55. float faceSign = ( facing >= 0 ? 1 : -1 );
  56. float4 node_7673 = _Time;
  57. float2 node_2892 = (i.uv0+(_Speed*node_7673.g));
  58. float4 _OutlineTexture_var = tex2D(_OutlineTexture,TRANSFORM_TEX(node_2892, _OutlineTexture));
  59. return fixed4(_OutlineTexture_var.rgb,0);
  60. }
  61. ENDCG
  62. }
  63. Pass {
  64. Name "FORWARD"
  65. Tags {
  66. "LightMode"="ForwardBase"
  67. }
  68. Cull Off
  69.  
  70.  
  71. CGPROGRAM
  72. #pragma vertex vert
  73. #pragma fragment frag
  74. #define UNITY_PASS_FORWARDBASE
  75. #include "UnityCG.cginc"
  76. #pragma multi_compile_fwdbase_fullshadows
  77. #pragma only_renderers d3d9 d3d11 glcore gles
  78. #pragma target 3.0
  79. uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
  80. uniform float4 _Tint;
  81. struct VertexInput {
  82. float4 vertex : POSITION;
  83. float2 texcoord0 : TEXCOORD0;
  84. };
  85. struct VertexOutput {
  86. float4 pos : SV_POSITION;
  87. float2 uv0 : TEXCOORD0;
  88. };
  89. VertexOutput vert (VertexInput v) {
  90. VertexOutput o = (VertexOutput)0;
  91. o.uv0 = v.texcoord0;
  92. o.pos = UnityObjectToClipPos( v.vertex );
  93. return o;
  94. }
  95. float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
  96. float isFrontFace = ( facing >= 0 ? 1 : 0 );
  97. float faceSign = ( facing >= 0 ? 1 : -1 );
  98. ////// Lighting:
  99. float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
  100. float3 finalColor = (_MainTex_var.rgb*_Tint.rgb);
  101. return fixed4(finalColor,1);
  102. }
  103. ENDCG
  104. }
  105. Pass {
  106. Name "ShadowCaster"
  107. Tags {
  108. "LightMode"="ShadowCaster"
  109. }
  110. Offset 1, 1
  111. Cull Off
  112.  
  113. CGPROGRAM
  114. #pragma vertex vert
  115. #pragma fragment frag
  116. #define UNITY_PASS_SHADOWCASTER
  117. #include "UnityCG.cginc"
  118. #include "Lighting.cginc"
  119. #pragma fragmentoption ARB_precision_hint_fastest
  120. #pragma multi_compile_shadowcaster
  121. #pragma only_renderers d3d9 d3d11 glcore gles
  122. #pragma target 3.0
  123. struct VertexInput {
  124. float4 vertex : POSITION;
  125. };
  126. struct VertexOutput {
  127. V2F_SHADOW_CASTER;
  128. };
  129. VertexOutput vert (VertexInput v) {
  130. VertexOutput o = (VertexOutput)0;
  131. o.pos = UnityObjectToClipPos( v.vertex );
  132. TRANSFER_SHADOW_CASTER(o)
  133. return o;
  134. }
  135. float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
  136. float isFrontFace = ( facing >= 0 ? 1 : 0 );
  137. float faceSign = ( facing >= 0 ? 1 : -1 );
  138. SHADOW_CASTER_FRAGMENT(i)
  139. }
  140. ENDCG
  141. }
  142.  
  143.  
  144.  
  145. Pass
  146. {
  147. CGPROGRAM
  148. #pragma vertex vert
  149. #pragma fragment frag
  150. #pragma geometry geom
  151. #pragma multi_compile_fwdbase
  152. #include "UnityCG.cginc"
  153.  
  154. uniform sampler2D _MainTex;
  155. uniform float4 _MainTex_ST;
  156. uniform float _Saturation;
  157. uniform float _Value;
  158.  
  159. float3 HSVToRGB( float3 c )
  160. {
  161. float4 K = float4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 );
  162. float3 p = abs( frac( c.xxx + K.xyz ) * 6.0 - K.www );
  163. return c.z * lerp( K.xxx, clamp( p - K.xxx, 0.0, 1.0 ), c.y );
  164. }
  165.  
  166. float3 getColor(float f) {
  167. return HSVToRGB(float3(f*1.618, _Saturation, _Value));
  168. }
  169.  
  170. float getTime(float phase, float step) {
  171. float t = (_Time.y + phase) * .2;
  172. return t - frac(t) * step;
  173. }
  174.  
  175.  
  176. float random (in float2 st) {
  177. return frac(
  178. cos(dot(st, float2(12.9898, 78.233)))
  179. * 43758.5453123
  180. );
  181. }
  182.  
  183. struct v2g
  184. {
  185. float4 vertex : POSITION;
  186. float3 normal : NORMAL;
  187. float2 uv : TEXCOORD0;
  188. };
  189.  
  190. struct g2f
  191. {
  192. float4 pos : SV_POSITION;
  193. float2 uv : TEXCOORD0;
  194. fixed4 col : COLOR;
  195. };
  196.  
  197.  
  198. v2g vert (appdata_base v)
  199. {
  200. v2g o;
  201. o.vertex = v.vertex;
  202. o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  203. o.normal = v.normal;
  204. return o;
  205. }
  206.  
  207. [maxvertexcount(3)]
  208. void geom(triangle v2g IN[3], inout TriangleStream<g2f> tristream)
  209. {
  210. float2 mid = (IN[0].uv + IN[1].uv + IN[2].uv)/3;
  211. float hash = random(mid);
  212. float3 pos = mul(unity_ObjectToWorld, mid);
  213. float freq = .1;
  214. float transitionSpeed = 2;
  215.  
  216.  
  217. float v = getTime(IN[0].uv.y * .9 + hash * .1, 0);
  218. float3 color = getColor(floor(v));
  219. float flash = 1-saturate(frac(v) * 30);
  220.  
  221. g2f o;
  222. for(int i = 0 ; i < 3 ; i ++) {
  223. o.pos = UnityObjectToClipPos(IN[i].vertex);
  224. o.uv = IN[i].uv;
  225. o.col.rgb = color;
  226. o.col.a = flash;
  227. tristream.Append(o);
  228. }
  229. tristream.RestartStrip();
  230. }
  231.  
  232. fixed4 frag (g2f i) : SV_Target
  233. {
  234. fixed4 col = tex2D(_MainTex, i.uv);
  235. col.rgb *= i.col.rgb;
  236. return lerp(col, fixed4(1,1,1,1) , i.col.a);
  237. }
  238.  
  239. ENDCG
  240. }
  241.  
  242. UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
  243. }
  244. FallBack "Diffuse"
  245. CustomEditor "ShaderForgeMaterialInspector"
  246. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement