Quadratic.shader 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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:Legacy Shaders/Diffuse,iptp:0,cusa:False,bamd:0,cgin:,cpap:True,lico:0,lgpr:1,limd:0,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,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: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:0,x:35652,y:33101,varname:node_0,prsc:2|custl-7908-OUT,olwid-5886-OUT,olcol-4533-OUT;n:type:ShaderForge.SFN_Dot,id:40,x:33494,y:33097,varname:node_40,prsc:2,dt:1|A-42-OUT,B-41-OUT;n:type:ShaderForge.SFN_NormalVector,id:41,x:33203,y:33135,prsc:2,pt:True;n:type:ShaderForge.SFN_LightVector,id:42,x:33203,y:33016,varname:node_42,prsc:2;n:type:ShaderForge.SFN_Tex2d,id:9233,x:33203,y:33549,varname:_node_9643_copy,prsc:2,ntxv:0,isnm:False|TEX-9167-TEX;n:type:ShaderForge.SFN_Tex2d,id:9120,x:33203,y:33322,varname:_node_9643_copy_copy,prsc:2,ntxv:0,isnm:False|TEX-9167-TEX;n:type:ShaderForge.SFN_Vector1,id:7888,x:33203,y:33274,varname:node_7888,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Subtract,id:9664,x:33493,y:33308,varname:node_9664,prsc:2|A-7888-OUT,B-9120-G;n:type:ShaderForge.SFN_Subtract,id:2990,x:33709,y:33107,varname:node_2990,prsc:2|A-40-OUT,B-9664-OUT;n:type:ShaderForge.SFN_If,id:3046,x:33922,y:33199,varname:node_3046,prsc:2|A-2990-OUT,B-2817-OUT,GT-6943-OUT,EQ-1346-OUT,LT-1346-OUT;n:type:ShaderForge.SFN_Slider,id:2817,x:33415,y:33251,ptovrint:False,ptlb:ShadowRange,ptin:_ShadowRange,varname:node_2817,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Vector1,id:6943,x:33625,y:33360,varname:node_6943,prsc:2,v1:1;n:type:ShaderForge.SFN_Vector1,id:1346,x:33625,y:33405,varname:node_1346,prsc:2,v1:0;n:type:ShaderForge.SFN_ViewVector,id:5884,x:33203,y:33438,varname:node_5884,prsc:2;n:type:ShaderForge.SFN_Dot,id:8748,x:33387,y:33405,varname:node_8748,prsc:2,dt:1|A-5884-OUT,B-41-OUT;n:type:ShaderForge.SFN_Power,id:8417,x:33560,y:33489,varname:node_8417,prsc:2|VAL-8748-OUT,EXP-9233-R;n:type:ShaderForge.SFN_Clamp01,id:3305,x:33738,y:33489,varname:node_3305,prsc:2|IN-8417-OUT;n:type:ShaderForge.SFN_Slider,id:6765,x:33581,y:33619,ptovrint:False,ptlb:SpecularRange,ptin:_SpecularRange,varname:node_6765,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0.9,cur:0.9820514,max:1;n:type:ShaderForge.SFN_If,id:526,x:33926,y:33488,varname:node_526,prsc:2|A-3305-OUT,B-6765-OUT,GT-8750-OUT,EQ-4786-OUT,LT-4786-OUT;n:type:ShaderForge.SFN_Vector1,id:8750,x:33738,y:33681,varname:node_8750,prsc:2,v1:1;n:type:ShaderForge.SFN_Vector1,id:4786,x:33738,y:33723,varname:node_4786,prsc:2,v1:0;n:type:ShaderForge.SFN_Multiply,id:6065,x:34095,y:33488,varname:node_6065,prsc:2|A-526-OUT,B-9233-B;n:type:ShaderForge.SFN_If,id:8645,x:34300,y:33542,varname:node_8645,prsc:2|A-6065-OUT,B-5365-OUT,GT-3087-OUT,EQ-10-OUT,LT-10-OUT;n:type:ShaderForge.SFN_Vector1,id:5365,x:34094,y:33608,varname:node_5365,prsc:2,v1:0.1;n:type:ShaderForge.SFN_Vector1,id:3087,x:34094,y:33658,varname:node_3087,prsc:2,v1:1;n:type:ShaderForge.SFN_Vector1,id:10,x:34094,y:33704,varname:node_10,prsc:2,v1:0;n:type:ShaderForge.SFN_Blend,id:1398,x:33895,y:32823,varname:node_1398,prsc:2,blmd:10,clmp:True|SRC-7076-G,DST-6629-RGB;n:type:ShaderForge.SFN_Tex2d,id:7076,x:33239,y:32753,varname:_node_9643_copy_copy_copy,prsc:2,ntxv:0,isnm:False|TEX-9167-TEX;n:type:ShaderForge.SFN_Tex2d,id:6629,x:33690,y:32869,ptovrint:False,ptlb:MainTex,ptin:_MainTex,varname:_Diffuse_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Slider,id:6970,x:34113,y:33174,ptovrint:False,ptlb:ShadowIntensity,ptin:_ShadowIntensity,varname:_DiffuseLightness_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.7956449,max:1;n:type:ShaderForge.SFN_Multiply,id:8078,x:34502,y:32824,cmnt:Diffuse,varname:node_8078,prsc:2|A-1398-OUT,B-9458-OUT;n:type:ShaderForge.SFN_OneMinus,id:4552,x:34660,y:33149,varname:node_4552,prsc:2|IN-9597-OUT;n:type:ShaderForge.SFN_Multiply,id:7944,x:34857,y:33128,cmnt:Shadow,varname:node_7944,prsc:2|A-2807-OUT,B-4552-OUT;n:type:ShaderForge.SFN_Add,id:2201,x:35061,y:33097,varname:node_2201,prsc:2|A-9930-OUT,B-7944-OUT;n:type:ShaderForge.SFN_Slider,id:2573,x:34105,y:33423,ptovrint:False,ptlb:SpecularMult,ptin:_SpecularMult,varname:node_2573,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:1;n:type:ShaderForge.SFN_Multiply,id:8854,x:34437,y:33396,varname:node_8854,prsc:2|A-2344-OUT,B-2573-OUT;n:type:ShaderForge.SFN_Multiply,id:3419,x:34623,y:33496,varname:node_3419,prsc:2|A-8854-OUT,B-8645-OUT;n:type:ShaderForge.SFN_Multiply,id:6858,x:34817,y:33460,cmnt:Specular,varname:node_6858,prsc:2|A-1762-OUT,B-3419-OUT;n:type:ShaderForge.SFN_Add,id:3357,x:35290,y:33157,varname:node_3357,prsc:2|A-2201-OUT,B-6858-OUT;n:type:ShaderForge.SFN_Tex2dAsset,id:9167,x:32870,y:33120,ptovrint:False,ptlb:SpeShaTex,ptin:_SpeShaTex,varname:node_9167,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:9989,x:35079,y:33354,ptovrint:False,ptlb:ShadowColorTex,ptin:_ShadowColorTex,varname:_MainTex_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Multiply,id:4533,x:35290,y:33400,varname:node_4533,prsc:2|A-9989-RGB,B-8823-OUT;n:type:ShaderForge.SFN_Slider,id:8823,x:34922,y:33519,ptovrint:False,ptlb:OutlineLightness,ptin:_OutlineLightness,varname:node_8823,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:1;n:type:ShaderForge.SFN_Slider,id:5886,x:34922,y:33604,ptovrint:False,ptlb:OutlineWidth,ptin:_OutlineWidth,varname:node_5886,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.01581197,max:0.05;n:type:ShaderForge.SFN_Color,id:3561,x:34228,y:33027,ptovrint:False,ptlb:ShadowColor,ptin:_ShadowColor,varname:node_3561,prsc:2,glob:False,taghide:False,taghdr:True,tagprd:False,tagnsco:False,tagnrm:False,c1:0.6663285,c2:0.6544118,c3:1,c4:1;n:type:ShaderForge.SFN_Multiply,id:2807,x:34486,y:33017,varname:node_2807,prsc:2|A-1398-OUT,B-3561-RGB,C-6970-OUT;n:type:ShaderForge.SFN_Set,id:780,x:34667,y:32824,varname:Diffuse,prsc:2|IN-8078-OUT;n:type:ShaderForge.SFN_Get,id:2344,x:34241,y:33364,varname:node_2344,prsc:2|IN-780-OUT;n:type:ShaderForge.SFN_Get,id:9930,x:34836,y:33052,varname:node_9930,prsc:2|IN-780-OUT;n:type:ShaderForge.SFN_Get,id:9597,x:34465,y:33149,varname:node_9597,prsc:2|IN-2937-OUT;n:type:ShaderForge.SFN_Set,id:2937,x:34105,y:33263,varname:DiffuseIf,prsc:2|IN-3046-OUT;n:type:ShaderForge.SFN_Get,id:9458,x:34275,y:32860,varname:node_9458,prsc:2|IN-2937-OUT;n:type:ShaderForge.SFN_Get,id:1762,x:34602,y:33453,varname:node_1762,prsc:2|IN-2937-OUT;n:type:ShaderForge.SFN_Multiply,id:7908,x:35432,y:32993,varname:node_7908,prsc:2|A-4235-RGB,B-3357-OUT;n:type:ShaderForge.SFN_Color,id:4235,x:35108,y:32885,ptovrint:False,ptlb:tex_color,ptin:_tex_color,varname:node_4235,prsc:2,glob:False,taghide:False,taghdr:True,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;proporder:4235-6629-9167-9989-3561-2817-6970-6765-2573-5886-8823;pass:END;sub:END;*/
  5. Shader "Quadratic/Quadratic element" {
  6. Properties {
  7. [HDR]_tex_color ("tex_color", Color) = (1,1,1,1)
  8. _MainTex ("MainTex", 2D) = "white" {}
  9. _SpeShaTex ("SpeShaTex", 2D) = "white" {}
  10. _ShadowColorTex ("ShadowColorTex", 2D) = "white" {}
  11. [HDR]_ShadowColor ("ShadowColor", Color) = (0.6663285,0.6544118,1,1)
  12. _ShadowRange ("ShadowRange", Range(0, 1)) = 0
  13. _ShadowIntensity ("ShadowIntensity", Range(0, 1)) = 0.7956449
  14. _SpecularRange ("SpecularRange", Range(0.9, 1)) = 0.9820514
  15. _SpecularMult ("SpecularMult", Range(0, 1)) = 1
  16. _OutlineWidth ("OutlineWidth", Range(0, 0.05)) = 0.01581197
  17. _OutlineLightness ("OutlineLightness", Range(0, 1)) = 1
  18. }
  19. SubShader {
  20. Tags {
  21. "RenderType"="Opaque"
  22. }
  23. Pass {
  24. Name "Outline"
  25. Tags {
  26. }
  27. Cull Front
  28. CGPROGRAM
  29. #pragma vertex vert
  30. #pragma fragment frag
  31. #pragma multi_compile_instancing
  32. #include "UnityCG.cginc"
  33. #pragma fragmentoption ARB_precision_hint_fastest
  34. #pragma multi_compile_shadowcaster
  35. #pragma target 3.0
  36. uniform sampler2D _ShadowColorTex; uniform float4 _ShadowColorTex_ST;
  37. UNITY_INSTANCING_BUFFER_START( Props )
  38. UNITY_DEFINE_INSTANCED_PROP( float, _OutlineLightness)
  39. UNITY_DEFINE_INSTANCED_PROP( float, _OutlineWidth)
  40. UNITY_INSTANCING_BUFFER_END( Props )
  41. struct VertexInput {
  42. float4 vertex : POSITION;
  43. float3 normal : NORMAL;
  44. float2 texcoord0 : TEXCOORD0;
  45. };
  46. struct VertexOutput {
  47. float4 pos : SV_POSITION;
  48. UNITY_VERTEX_INPUT_INSTANCE_ID
  49. float2 uv0 : TEXCOORD0;
  50. };
  51. VertexOutput vert (VertexInput v) {
  52. VertexOutput o = (VertexOutput)0;
  53. UNITY_SETUP_INSTANCE_ID( v );
  54. UNITY_TRANSFER_INSTANCE_ID( v, o );
  55. o.uv0 = v.texcoord0;
  56. float _OutlineWidth_var = UNITY_ACCESS_INSTANCED_PROP( Props, _OutlineWidth );
  57. o.pos = UnityObjectToClipPos( float4(v.vertex.xyz + v.normal*_OutlineWidth_var,1) );
  58. return o;
  59. }
  60. float4 frag(VertexOutput i) : COLOR {
  61. UNITY_SETUP_INSTANCE_ID( i );
  62. float4 _ShadowColorTex_var = tex2D(_ShadowColorTex,TRANSFORM_TEX(i.uv0, _ShadowColorTex));
  63. float _OutlineLightness_var = UNITY_ACCESS_INSTANCED_PROP( Props, _OutlineLightness );
  64. return fixed4((_ShadowColorTex_var.rgb*_OutlineLightness_var),0);
  65. }
  66. ENDCG
  67. }
  68. Pass {
  69. Name "FORWARD"
  70. Tags {
  71. "LightMode"="ForwardBase"
  72. }
  73. CGPROGRAM
  74. #pragma vertex vert
  75. #pragma fragment frag
  76. #pragma multi_compile_instancing
  77. #include "UnityCG.cginc"
  78. #include "AutoLight.cginc"
  79. #pragma multi_compile_fwdbase_fullshadows
  80. #pragma target 3.0
  81. uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
  82. uniform sampler2D _SpeShaTex; uniform float4 _SpeShaTex_ST;
  83. UNITY_INSTANCING_BUFFER_START( Props )
  84. UNITY_DEFINE_INSTANCED_PROP( float, _ShadowRange)
  85. UNITY_DEFINE_INSTANCED_PROP( float, _SpecularRange)
  86. UNITY_DEFINE_INSTANCED_PROP( float, _ShadowIntensity)
  87. UNITY_DEFINE_INSTANCED_PROP( float, _SpecularMult)
  88. UNITY_DEFINE_INSTANCED_PROP( float4, _ShadowColor)
  89. UNITY_DEFINE_INSTANCED_PROP( float4, _tex_color)
  90. UNITY_INSTANCING_BUFFER_END( Props )
  91. struct VertexInput {
  92. float4 vertex : POSITION;
  93. float3 normal : NORMAL;
  94. float2 texcoord0 : TEXCOORD0;
  95. };
  96. struct VertexOutput {
  97. float4 pos : SV_POSITION;
  98. UNITY_VERTEX_INPUT_INSTANCE_ID
  99. float2 uv0 : TEXCOORD0;
  100. float4 posWorld : TEXCOORD1;
  101. float3 normalDir : TEXCOORD2;
  102. LIGHTING_COORDS(3,4)
  103. };
  104. VertexOutput vert (VertexInput v) {
  105. VertexOutput o = (VertexOutput)0;
  106. UNITY_SETUP_INSTANCE_ID( v );
  107. UNITY_TRANSFER_INSTANCE_ID( v, o );
  108. o.uv0 = v.texcoord0;
  109. o.normalDir = UnityObjectToWorldNormal(v.normal);
  110. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  111. o.pos = UnityObjectToClipPos( v.vertex );
  112. TRANSFER_VERTEX_TO_FRAGMENT(o)
  113. return o;
  114. }
  115. float4 frag(VertexOutput i) : COLOR {
  116. UNITY_SETUP_INSTANCE_ID( i );
  117. i.normalDir = normalize(i.normalDir);
  118. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  119. float3 normalDirection = i.normalDir;
  120. float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
  121. ////// Lighting:
  122. float4 _tex_color_var = UNITY_ACCESS_INSTANCED_PROP( Props, _tex_color );
  123. float4 _node_9643_copy_copy_copy = tex2D(_SpeShaTex,TRANSFORM_TEX(i.uv0, _SpeShaTex));
  124. float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
  125. float3 node_1398 = saturate(( _MainTex_var.rgb > 0.5 ? (1.0-(1.0-2.0*(_MainTex_var.rgb-0.5))*(1.0-_node_9643_copy_copy_copy.g)) : (2.0*_MainTex_var.rgb*_node_9643_copy_copy_copy.g) ));
  126. float4 _node_9643_copy_copy = tex2D(_SpeShaTex,TRANSFORM_TEX(i.uv0, _SpeShaTex));
  127. float _ShadowRange_var = UNITY_ACCESS_INSTANCED_PROP( Props, _ShadowRange );
  128. float node_3046_if_leA = step((max(0,dot(lightDirection,normalDirection))-(0.5-_node_9643_copy_copy.g)),_ShadowRange_var);
  129. float node_3046_if_leB = step(_ShadowRange_var,(max(0,dot(lightDirection,normalDirection))-(0.5-_node_9643_copy_copy.g)));
  130. float node_1346 = 0.0;
  131. float DiffuseIf = lerp((node_3046_if_leA*node_1346)+(node_3046_if_leB*1.0),node_1346,node_3046_if_leA*node_3046_if_leB);
  132. float3 Diffuse = (node_1398*DiffuseIf);
  133. float4 _ShadowColor_var = UNITY_ACCESS_INSTANCED_PROP( Props, _ShadowColor );
  134. float _ShadowIntensity_var = UNITY_ACCESS_INSTANCED_PROP( Props, _ShadowIntensity );
  135. float _SpecularMult_var = UNITY_ACCESS_INSTANCED_PROP( Props, _SpecularMult );
  136. float4 _node_9643_copy = tex2D(_SpeShaTex,TRANSFORM_TEX(i.uv0, _SpeShaTex));
  137. float _SpecularRange_var = UNITY_ACCESS_INSTANCED_PROP( Props, _SpecularRange );
  138. float node_526_if_leA = step(saturate(pow(max(0,dot(viewDirection,normalDirection)),_node_9643_copy.r)),_SpecularRange_var);
  139. float node_526_if_leB = step(_SpecularRange_var,saturate(pow(max(0,dot(viewDirection,normalDirection)),_node_9643_copy.r)));
  140. float node_4786 = 0.0;
  141. float node_8645_if_leA = step((lerp((node_526_if_leA*node_4786)+(node_526_if_leB*1.0),node_4786,node_526_if_leA*node_526_if_leB)*_node_9643_copy.b),0.1);
  142. float node_8645_if_leB = step(0.1,(lerp((node_526_if_leA*node_4786)+(node_526_if_leB*1.0),node_4786,node_526_if_leA*node_526_if_leB)*_node_9643_copy.b));
  143. float node_10 = 0.0;
  144. float3 finalColor = (_tex_color_var.rgb*((Diffuse+((node_1398*_ShadowColor_var.rgb*_ShadowIntensity_var)*(1.0 - DiffuseIf)))+(DiffuseIf*((Diffuse*_SpecularMult_var)*lerp((node_8645_if_leA*node_10)+(node_8645_if_leB*1.0),node_10,node_8645_if_leA*node_8645_if_leB)))));
  145. return fixed4(finalColor,1);
  146. }
  147. ENDCG
  148. }
  149. }
  150. FallBack "Legacy Shaders/Diffuse"
  151. CustomEditor "ShaderForgeMaterialInspector"
  152. }