You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
6.3 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/Translucency"
  4. {
  5. Properties
  6. {
  7. [HideInInspector] __dirty( "", Int ) = 1
  8. _Specular("Specular", Range( 0 , 1)) = 0
  9. [Header(Translucency)]
  10. _Color0("Color 0", Color) = (0,0,0,0)
  11. _Translucency("Strength", Range( 0 , 50)) = 1
  12. _TransNormalDistortion("Normal Distortion", Range( 0 , 1)) = 0.1
  13. _Albedo("Albedo", 2D) = "white" {}
  14. _TransScattering("Scaterring Falloff", Range( 1 , 50)) = 2
  15. _Normal("Normal", 2D) = "bump" {}
  16. _Depth("Depth", 2D) = "white" {}
  17. _TransDirect("Direct", Range( 0 , 1)) = 1
  18. _Tint("Tint", Color) = (0,0,0,0)
  19. _TransAmbient("Ambient", Range( 0 , 1)) = 0.2
  20. _TransShadow("Shadow", Range( 0 , 1)) = 0.9
  21. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  22. }
  23. SubShader
  24. {
  25. Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" }
  26. Cull Back
  27. ZTest LEqual
  28. CGPROGRAM
  29. #include "UnityPBSLighting.cginc"
  30. #pragma target 3.0
  31. #pragma surface surf StandardSpecularCustom keepalpha addshadow fullforwardshadows exclude_path:deferred
  32. struct Input
  33. {
  34. float2 uv_texcoord;
  35. };
  36. struct SurfaceOutputStandardSpecularCustom
  37. {
  38. fixed3 Albedo;
  39. fixed3 Normal;
  40. half3 Emission;
  41. fixed3 Specular;
  42. half Smoothness;
  43. half Occlusion;
  44. fixed Alpha;
  45. fixed3 Translucency;
  46. };
  47. uniform sampler2D _Normal;
  48. uniform sampler2D _Albedo;
  49. uniform float4 _Albedo_ST;
  50. uniform fixed4 _Tint;
  51. uniform fixed _Specular;
  52. uniform half _Translucency;
  53. uniform half _TransNormalDistortion;
  54. uniform half _TransScattering;
  55. uniform half _TransDirect;
  56. uniform half _TransAmbient;
  57. uniform half _TransShadow;
  58. uniform sampler2D _Depth;
  59. uniform float4 _Depth_ST;
  60. uniform fixed4 _Color0;
  61. inline half4 LightingStandardSpecularCustom(SurfaceOutputStandardSpecularCustom s, half3 viewDir, UnityGI gi )
  62. {
  63. #if !DIRECTIONAL
  64. float3 lightAtten = gi.light.color;
  65. #else
  66. float3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, _TransShadow );
  67. #endif
  68. half3 lightDir = gi.light.dir + s.Normal * _TransNormalDistortion;
  69. half transVdotL = pow( saturate( dot( viewDir, -lightDir ) ), _TransScattering );
  70. half3 translucency = lightAtten * (transVdotL * _TransDirect + gi.indirect.diffuse * _TransAmbient) * s.Translucency;
  71. half4 c = half4( s.Albedo * translucency * _Translucency, 0 );
  72. SurfaceOutputStandardSpecular r;
  73. r.Albedo = s.Albedo;
  74. r.Normal = s.Normal;
  75. r.Emission = s.Emission;
  76. r.Specular = s.Specular;
  77. r.Smoothness = s.Smoothness;
  78. r.Occlusion = s.Occlusion;
  79. r.Alpha = s.Alpha;
  80. return LightingStandardSpecular (r, viewDir, gi) + c;
  81. }
  82. inline void LightingStandardSpecularCustom_GI(SurfaceOutputStandardSpecularCustom s, UnityGIInput data, inout UnityGI gi )
  83. {
  84. UNITY_GI(gi, s, data);
  85. }
  86. void surf( Input i , inout SurfaceOutputStandardSpecularCustom o )
  87. {
  88. float2 uv_Albedo = i.uv_texcoord * _Albedo_ST.xy + _Albedo_ST.zw;
  89. o.Normal = UnpackNormal( tex2D( _Normal, uv_Albedo ) );
  90. o.Albedo = ( _Tint * tex2D( _Albedo, uv_Albedo ) ).rgb;
  91. fixed3 temp_cast_2 = (_Specular).xxx;
  92. o.Specular = temp_cast_2;
  93. float2 uv_Depth = i.uv_texcoord * _Depth_ST.xy + _Depth_ST.zw;
  94. o.Translucency = ( tex2D( _Depth, uv_Depth ) * _Color0 ).xyz;
  95. o.Alpha = 1;
  96. }
  97. ENDCG
  98. }
  99. Fallback "Diffuse"
  100. CustomEditor "ASEMaterialInspector"
  101. }
  102. /*ASEBEGIN
  103. Version=13201
  104. 352;92;1226;768;1143.113;510.184;1.4;False;False
  105. Node;AmplifyShaderEditor.TextureCoordinatesNode;17;-1016.736,-72.31985;Float;False;0;9;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT
  106. Node;AmplifyShaderEditor.ColorNode;10;-505.058,-441.5712;Float;False;Property;_Tint;Tint;4;0;0,0,0,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  107. Node;AmplifyShaderEditor.ColorNode;6;-528.7906,325.7297;Float;False;Property;_Color0;Color 0;-1;0;0,0,0,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  108. Node;AmplifyShaderEditor.SamplerNode;9;-560.7905,-261.6702;Float;True;Property;_Albedo;Albedo;1;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
  109. Node;AmplifyShaderEditor.SamplerNode;7;-567.9905,129.1298;Float;True;Property;_Depth;Depth;3;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
  110. Node;AmplifyShaderEditor.RangedFloatNode;16;-169.3906,29.62976;Float;False;Property;_Specular;Specular;-1;0;0;0;1;0;1;FLOAT
  111. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;11;-119.7905,-259.6702;Float;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT4;0.0,0,0,0;False;1;COLOR
  112. Node;AmplifyShaderEditor.SamplerNode;12;-566.9902,-73.27022;Float;True;Property;_Normal;Normal;2;0;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
  113. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;8;-93.79053,185.3298;Float;False;2;2;0;FLOAT4;0.0,0,0,0;False;1;COLOR;0,0,0,0;False;1;FLOAT4
  114. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;186.6,-73.70001;Fixed;False;True;2;Fixed;ASEMaterialInspector;0;0;StandardSpecular;ASESampleShaders/Translucency;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;3;False;0;0;Opaque;0.5;True;True;0;False;Opaque;Geometry;ForwardOnly;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;False;0;255;255;0;0;0;0;False;0;4;10;25;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;0,0,0,0;VertexOffset;False;Cylindrical;False;Relative;0;;-1;-1;-1;-1;0;0;0;15;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT3;0,0,0;False;4;FLOAT;0.0;False;5;FLOAT;0.0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0.0;False;9;FLOAT;0.0;False;10;OBJECT;0.0;False;11;FLOAT3;0.0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
  115. WireConnection;9;1;17;0
  116. WireConnection;11;0;10;0
  117. WireConnection;11;1;9;0
  118. WireConnection;12;1;17;0
  119. WireConnection;8;0;7;0
  120. WireConnection;8;1;6;0
  121. WireConnection;0;0;11;0
  122. WireConnection;0;1;12;0
  123. WireConnection;0;3;16;0
  124. WireConnection;0;7;8;0
  125. ASEEND*/
  126. //CHKSM=01B123CEEFE2B203DDAC13C4470869EF7D3DE74D