TwoUv_ZoGlow.shader 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // Shader created with Shader Forge v1.40
  2. // Shader Forge (c) Freya Holmer - http://www.acegikmo.com/shaderforge/
  3. // Note: Manually altering this data may prevent you from opening it in Shader Forge
  4. /*SF_DATA;ver:1.40;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,cpap:True,lico:1,lgpr:1,limd:1,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:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,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:4013,x:33505,y:32828,varname:node_4013,prsc:2|diff-6444-OUT,emission-7753-OUT;n:type:ShaderForge.SFN_TexCoord,id:5685,x:31678,y:32822,varname:node_5685,prsc:2,uv:0,uaff:False;n:type:ShaderForge.SFN_Panner,id:783,x:31904,y:32822,varname:node_783,prsc:2,spu:-0.2,spv:0|UVIN-5685-UVOUT;n:type:ShaderForge.SFN_Tex2d,id:3520,x:32095,y:32833,ptovrint:False,ptlb:Glow,ptin:_Glow,varname:node_3520,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False|UVIN-783-UVOUT;n:type:ShaderForge.SFN_Multiply,id:6900,x:32396,y:32862,varname:node_6900,prsc:2|A-3520-RGB,B-3995-RGB;n:type:ShaderForge.SFN_Color,id:3995,x:32136,y:33066,ptovrint:False,ptlb:node_3995,ptin:_node_3995,varname:node_3995,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_TexCoord,id:3441,x:32396,y:32569,varname:node_3441,prsc:2,uv:1,uaff:False;n:type:ShaderForge.SFN_Tex2d,id:118,x:32669,y:32453,ptovrint:False,ptlb:diffuse,ptin:_diffuse,varname:node_118,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False|UVIN-3441-UVOUT;n:type:ShaderForge.SFN_Multiply,id:6444,x:32928,y:32570,varname:node_6444,prsc:2|A-118-RGB,B-4245-RGB;n:type:ShaderForge.SFN_Color,id:4245,x:32669,y:32658,ptovrint:False,ptlb:diffuse_color,ptin:_diffuse_color,varname:node_4245,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_Power,id:7085,x:32658,y:32867,varname:node_7085,prsc:2|VAL-6900-OUT,EXP-3159-OUT;n:type:ShaderForge.SFN_Slider,id:3159,x:32396,y:33079,ptovrint:False,ptlb:power,ptin:_power,varname:node_3159,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.1709402,max:1;n:type:ShaderForge.SFN_Multiply,id:1216,x:32929,y:32888,varname:node_1216,prsc:2|A-7085-OUT,B-9456-OUT;n:type:ShaderForge.SFN_Slider,id:9456,x:32559,y:33194,ptovrint:False,ptlb:lianggang,ptin:_lianggang,varname:node_9456,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Multiply,id:4536,x:33150,y:33080,varname:node_4536,prsc:2|A-3520-RGB,B-4929-RGB;n:type:ShaderForge.SFN_Color,id:4929,x:32933,y:33232,ptovrint:False,ptlb:node_4929,ptin:_node_4929,varname:node_4929,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.5,c2:0.5,c3:0.5,c4:1;n:type:ShaderForge.SFN_Add,id:7753,x:33256,y:32931,varname:node_7753,prsc:2|A-1216-OUT,B-4536-OUT;proporder:118-4245-3520-3995-3159-9456-4929;pass:END;sub:END;*/
  5. Shader "My Shader Forge/TwoUv_ZoGlow" {
  6. Properties {
  7. _diffuse ("diffuse", 2D) = "white" {}
  8. _diffuse_color ("diffuse_color", Color) = (1,1,1,1)
  9. _Glow ("Glow", 2D) = "white" {}
  10. _node_3995 ("node_3995", Color) = (1,1,1,1)
  11. _power ("power", Range(0, 1)) = 0.1709402
  12. _lianggang ("lianggang", Range(0, 1)) = 0
  13. _node_4929 ("node_4929", Color) = (0.5,0.5,0.5,1)
  14. }
  15. SubShader {
  16. Tags {
  17. "RenderType"="Opaque"
  18. }
  19. Pass {
  20. Name "FORWARD"
  21. Tags {
  22. "LightMode"="ForwardBase"
  23. }
  24. CGPROGRAM
  25. #pragma vertex vert
  26. #pragma fragment frag
  27. #pragma multi_compile_instancing
  28. #include "UnityCG.cginc"
  29. #include "AutoLight.cginc"
  30. #pragma multi_compile_fwdbase_fullshadows
  31. #pragma multi_compile_fog
  32. #pragma target 3.0
  33. uniform float4 _LightColor0;
  34. uniform sampler2D _Glow; uniform float4 _Glow_ST;
  35. uniform sampler2D _diffuse; uniform float4 _diffuse_ST;
  36. UNITY_INSTANCING_BUFFER_START( Props )
  37. UNITY_DEFINE_INSTANCED_PROP( float4, _node_3995)
  38. UNITY_DEFINE_INSTANCED_PROP( float4, _diffuse_color)
  39. UNITY_DEFINE_INSTANCED_PROP( float, _power)
  40. UNITY_DEFINE_INSTANCED_PROP( float, _lianggang)
  41. UNITY_DEFINE_INSTANCED_PROP( float4, _node_4929)
  42. UNITY_INSTANCING_BUFFER_END( Props )
  43. struct VertexInput {
  44. UNITY_VERTEX_INPUT_INSTANCE_ID
  45. float4 vertex : POSITION;
  46. float3 normal : NORMAL;
  47. float2 texcoord0 : TEXCOORD0;
  48. float2 texcoord1 : TEXCOORD1;
  49. };
  50. struct VertexOutput {
  51. float4 pos : SV_POSITION;
  52. UNITY_VERTEX_INPUT_INSTANCE_ID
  53. float2 uv0 : TEXCOORD0;
  54. float2 uv1 : TEXCOORD1;
  55. float4 posWorld : TEXCOORD2;
  56. float3 normalDir : TEXCOORD3;
  57. LIGHTING_COORDS(4,5)
  58. UNITY_FOG_COORDS(6)
  59. };
  60. VertexOutput vert (VertexInput v) {
  61. VertexOutput o = (VertexOutput)0;
  62. UNITY_SETUP_INSTANCE_ID( v );
  63. UNITY_TRANSFER_INSTANCE_ID( v, o );
  64. o.uv0 = v.texcoord0;
  65. o.uv1 = v.texcoord1;
  66. o.normalDir = UnityObjectToWorldNormal(v.normal);
  67. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  68. float3 lightColor = _LightColor0.rgb;
  69. o.pos = UnityObjectToClipPos( v.vertex );
  70. UNITY_TRANSFER_FOG(o,o.pos);
  71. TRANSFER_VERTEX_TO_FRAGMENT(o)
  72. return o;
  73. }
  74. float4 frag(VertexOutput i) : COLOR {
  75. UNITY_SETUP_INSTANCE_ID( i );
  76. i.normalDir = normalize(i.normalDir);
  77. float3 normalDirection = i.normalDir;
  78. float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
  79. float3 lightColor = _LightColor0.rgb;
  80. ////// Lighting:
  81. float attenuation = LIGHT_ATTENUATION(i);
  82. float3 attenColor = attenuation * _LightColor0.xyz;
  83. /////// Diffuse:
  84. float NdotL = max(0.0,dot( normalDirection, lightDirection ));
  85. float3 directDiffuse = max( 0.0, NdotL) * attenColor;
  86. float3 indirectDiffuse = float3(0,0,0);
  87. indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light
  88. float4 _diffuse_var = tex2D(_diffuse,TRANSFORM_TEX(i.uv1, _diffuse));
  89. float4 _diffuse_color_var = UNITY_ACCESS_INSTANCED_PROP( Props, _diffuse_color );
  90. float3 diffuseColor = (_diffuse_var.rgb*_diffuse_color_var.rgb);
  91. float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
  92. ////// Emissive:
  93. float4 node_8010 = _Time;
  94. float2 node_783 = (i.uv0+node_8010.g*float2(-0.2,0));
  95. float4 _Glow_var = tex2D(_Glow,TRANSFORM_TEX(node_783, _Glow));
  96. float4 _node_3995_var = UNITY_ACCESS_INSTANCED_PROP( Props, _node_3995 );
  97. float _power_var = UNITY_ACCESS_INSTANCED_PROP( Props, _power );
  98. float _lianggang_var = UNITY_ACCESS_INSTANCED_PROP( Props, _lianggang );
  99. float4 _node_4929_var = UNITY_ACCESS_INSTANCED_PROP( Props, _node_4929 );
  100. float3 emissive = ((pow((_Glow_var.rgb*_node_3995_var.rgb),_power_var)*_lianggang_var)+(_Glow_var.rgb*_node_4929_var.rgb));
  101. /// Final Color:
  102. float3 finalColor = diffuse + emissive;
  103. fixed4 finalRGBA = fixed4(finalColor,1);
  104. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  105. return finalRGBA;
  106. }
  107. ENDCG
  108. }
  109. Pass {
  110. Name "FORWARD_DELTA"
  111. Tags {
  112. "LightMode"="ForwardAdd"
  113. }
  114. Blend One One
  115. CGPROGRAM
  116. #pragma vertex vert
  117. #pragma fragment frag
  118. #pragma multi_compile_instancing
  119. #include "UnityCG.cginc"
  120. #include "AutoLight.cginc"
  121. #pragma multi_compile_fwdadd_fullshadows
  122. #pragma multi_compile_fog
  123. #pragma target 3.0
  124. uniform float4 _LightColor0;
  125. uniform sampler2D _Glow; uniform float4 _Glow_ST;
  126. uniform sampler2D _diffuse; uniform float4 _diffuse_ST;
  127. UNITY_INSTANCING_BUFFER_START( Props )
  128. UNITY_DEFINE_INSTANCED_PROP( float4, _node_3995)
  129. UNITY_DEFINE_INSTANCED_PROP( float4, _diffuse_color)
  130. UNITY_DEFINE_INSTANCED_PROP( float, _power)
  131. UNITY_DEFINE_INSTANCED_PROP( float, _lianggang)
  132. UNITY_DEFINE_INSTANCED_PROP( float4, _node_4929)
  133. UNITY_INSTANCING_BUFFER_END( Props )
  134. struct VertexInput {
  135. UNITY_VERTEX_INPUT_INSTANCE_ID
  136. float4 vertex : POSITION;
  137. float3 normal : NORMAL;
  138. float2 texcoord0 : TEXCOORD0;
  139. float2 texcoord1 : TEXCOORD1;
  140. };
  141. struct VertexOutput {
  142. float4 pos : SV_POSITION;
  143. UNITY_VERTEX_INPUT_INSTANCE_ID
  144. float2 uv0 : TEXCOORD0;
  145. float2 uv1 : TEXCOORD1;
  146. float4 posWorld : TEXCOORD2;
  147. float3 normalDir : TEXCOORD3;
  148. LIGHTING_COORDS(4,5)
  149. UNITY_FOG_COORDS(6)
  150. };
  151. VertexOutput vert (VertexInput v) {
  152. VertexOutput o = (VertexOutput)0;
  153. UNITY_SETUP_INSTANCE_ID( v );
  154. UNITY_TRANSFER_INSTANCE_ID( v, o );
  155. o.uv0 = v.texcoord0;
  156. o.uv1 = v.texcoord1;
  157. o.normalDir = UnityObjectToWorldNormal(v.normal);
  158. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  159. float3 lightColor = _LightColor0.rgb;
  160. o.pos = UnityObjectToClipPos( v.vertex );
  161. UNITY_TRANSFER_FOG(o,o.pos);
  162. TRANSFER_VERTEX_TO_FRAGMENT(o)
  163. return o;
  164. }
  165. float4 frag(VertexOutput i) : COLOR {
  166. UNITY_SETUP_INSTANCE_ID( i );
  167. i.normalDir = normalize(i.normalDir);
  168. float3 normalDirection = i.normalDir;
  169. float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
  170. float3 lightColor = _LightColor0.rgb;
  171. ////// Lighting:
  172. float attenuation = LIGHT_ATTENUATION(i);
  173. float3 attenColor = attenuation * _LightColor0.xyz;
  174. /////// Diffuse:
  175. float NdotL = max(0.0,dot( normalDirection, lightDirection ));
  176. float3 directDiffuse = max( 0.0, NdotL) * attenColor;
  177. float4 _diffuse_var = tex2D(_diffuse,TRANSFORM_TEX(i.uv1, _diffuse));
  178. float4 _diffuse_color_var = UNITY_ACCESS_INSTANCED_PROP( Props, _diffuse_color );
  179. float3 diffuseColor = (_diffuse_var.rgb*_diffuse_color_var.rgb);
  180. float3 diffuse = directDiffuse * diffuseColor;
  181. /// Final Color:
  182. float3 finalColor = diffuse;
  183. fixed4 finalRGBA = fixed4(finalColor * 1,0);
  184. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  185. return finalRGBA;
  186. }
  187. ENDCG
  188. }
  189. }
  190. FallBack "Diffuse"
  191. CustomEditor "ShaderForgeMaterialInspector"
  192. }