220 lines
11 KiB
GLSL
220 lines
11 KiB
GLSL
// Made with Amplify Shader Editor
|
|
// Available at the Unity Asset Store - http://u3d.as/y3X
|
|
Shader "ASESampleShaders/Transmission"
|
|
{
|
|
Properties
|
|
{
|
|
_Tint("Tint", Color) = (1,1,1,0)
|
|
_Albedo("Albedo", 2D) = "white" {}
|
|
_Roughness("Roughness", Range( 0 , 1)) = 0.3294118
|
|
_Metallic("Metallic", Range( 0 , 1)) = 0
|
|
_Cutoff( "Mask Clip Value", Float ) = 0.44
|
|
_Normals("Normals", 2D) = "bump" {}
|
|
_Occlusion("Occlusion", 2D) = "white" {}
|
|
_Transmission("Transmission", Color) = (0.4506271,0.509434,0.3676575,0)
|
|
_WindFrequency("Wind Frequency", Float) = 1.34
|
|
_NoiseScale("Noise Scale", Float) = 1.41
|
|
_MovementMultiplier("Movement Multiplier", Float) = 0.07
|
|
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
|
[HideInInspector] __dirty( "", Int ) = 1
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags{ "RenderType" = "Opaque" "Queue" = "AlphaTest+0" }
|
|
Cull Back
|
|
ZWrite On
|
|
ZTest LEqual
|
|
CGPROGRAM
|
|
#include "UnityShaderVariables.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#pragma target 3.0
|
|
#pragma surface surf StandardCustom keepalpha addshadow fullforwardshadows exclude_path:deferred vertex:vertexDataFunc
|
|
struct Input
|
|
{
|
|
float2 uv_texcoord;
|
|
};
|
|
|
|
struct SurfaceOutputStandardCustom
|
|
{
|
|
half3 Albedo;
|
|
half3 Normal;
|
|
half3 Emission;
|
|
half Metallic;
|
|
half Smoothness;
|
|
half Occlusion;
|
|
half Alpha;
|
|
half3 Transmission;
|
|
};
|
|
|
|
uniform float _WindFrequency;
|
|
uniform float _NoiseScale;
|
|
uniform float _MovementMultiplier;
|
|
uniform sampler2D _Normals;
|
|
uniform float4 _Normals_ST;
|
|
uniform sampler2D _Albedo;
|
|
uniform float4 _Albedo_ST;
|
|
uniform float4 _Tint;
|
|
uniform float _Metallic;
|
|
uniform float _Roughness;
|
|
uniform sampler2D _Occlusion;
|
|
uniform float4 _Occlusion_ST;
|
|
uniform float4 _Transmission;
|
|
uniform float _Cutoff = 0.44;
|
|
|
|
|
|
float3 mod2D289( float3 x ) { return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0; }
|
|
|
|
float2 mod2D289( float2 x ) { return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0; }
|
|
|
|
float3 permute( float3 x ) { return mod2D289( ( ( x * 34.0 ) + 1.0 ) * x ); }
|
|
|
|
float snoise( float2 v )
|
|
{
|
|
const float4 C = float4( 0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439 );
|
|
float2 i = floor( v + dot( v, C.yy ) );
|
|
float2 x0 = v - i + dot( i, C.xx );
|
|
float2 i1;
|
|
i1 = ( x0.x > x0.y ) ? float2( 1.0, 0.0 ) : float2( 0.0, 1.0 );
|
|
float4 x12 = x0.xyxy + C.xxzz;
|
|
x12.xy -= i1;
|
|
i = mod2D289( i );
|
|
float3 p = permute( permute( i.y + float3( 0.0, i1.y, 1.0 ) ) + i.x + float3( 0.0, i1.x, 1.0 ) );
|
|
float3 m = max( 0.5 - float3( dot( x0, x0 ), dot( x12.xy, x12.xy ), dot( x12.zw, x12.zw ) ), 0.0 );
|
|
m = m * m;
|
|
m = m * m;
|
|
float3 x = 2.0 * frac( p * C.www ) - 1.0;
|
|
float3 h = abs( x ) - 0.5;
|
|
float3 ox = floor( x + 0.5 );
|
|
float3 a0 = x - ox;
|
|
m *= 1.79284291400159 - 0.85373472095314 * ( a0 * a0 + h * h );
|
|
float3 g;
|
|
g.x = a0.x * x0.x + h.x * x0.y;
|
|
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
|
return 130.0 * dot( m, g );
|
|
}
|
|
|
|
|
|
void vertexDataFunc( inout appdata_full v, out Input o )
|
|
{
|
|
UNITY_INITIALIZE_OUTPUT( Input, o );
|
|
float mulTime19 = _Time.y * _WindFrequency;
|
|
float2 temp_cast_0 = (mulTime19).xx;
|
|
float2 uv_TexCoord20 = v.texcoord.xy + temp_cast_0;
|
|
float simplePerlin2D22 = snoise( uv_TexCoord20*_NoiseScale );
|
|
simplePerlin2D22 = simplePerlin2D22*0.5 + 0.5;
|
|
float temp_output_12_0 = ( ( simplePerlin2D22 + -0.5 ) * _MovementMultiplier );
|
|
float simplePerlin2D23 = snoise( uv_TexCoord20*_NoiseScale );
|
|
simplePerlin2D23 = simplePerlin2D23*0.5 + 0.5;
|
|
float temp_output_13_0 = ( _MovementMultiplier * ( simplePerlin2D23 + -0.5 ) );
|
|
float3 appendResult9 = (float3(temp_output_12_0 , temp_output_13_0 , ( ( temp_output_12_0 + temp_output_13_0 ) * 0.4 )));
|
|
v.vertex.xyz += ( v.texcoord1.xy.y * appendResult9 );
|
|
}
|
|
|
|
inline half4 LightingStandardCustom(SurfaceOutputStandardCustom s, half3 viewDir, UnityGI gi )
|
|
{
|
|
half3 transmission = max(0 , -dot(s.Normal, gi.light.dir)) * gi.light.color * s.Transmission;
|
|
half4 d = half4(s.Albedo * transmission , 0);
|
|
|
|
SurfaceOutputStandard r;
|
|
r.Albedo = s.Albedo;
|
|
r.Normal = s.Normal;
|
|
r.Emission = s.Emission;
|
|
r.Metallic = s.Metallic;
|
|
r.Smoothness = s.Smoothness;
|
|
r.Occlusion = s.Occlusion;
|
|
r.Alpha = s.Alpha;
|
|
return LightingStandard (r, viewDir, gi) + d;
|
|
}
|
|
|
|
inline void LightingStandardCustom_GI(SurfaceOutputStandardCustom s, UnityGIInput data, inout UnityGI gi )
|
|
{
|
|
#if defined(UNITY_PASS_DEFERRED) && UNITY_ENABLE_REFLECTION_BUFFERS
|
|
gi = UnityGlobalIllumination(data, s.Occlusion, s.Normal);
|
|
#else
|
|
UNITY_GLOSSY_ENV_FROM_SURFACE( g, s, data );
|
|
gi = UnityGlobalIllumination( data, s.Occlusion, s.Normal, g );
|
|
#endif
|
|
}
|
|
|
|
void surf( Input i , inout SurfaceOutputStandardCustom o )
|
|
{
|
|
float2 uv_Normals = i.uv_texcoord * _Normals_ST.xy + _Normals_ST.zw;
|
|
o.Normal = UnpackNormal( tex2D( _Normals, uv_Normals ) );
|
|
float2 uv_Albedo = i.uv_texcoord * _Albedo_ST.xy + _Albedo_ST.zw;
|
|
float4 tex2DNode1 = tex2D( _Albedo, uv_Albedo );
|
|
o.Albedo = ( tex2DNode1 * _Tint ).rgb;
|
|
o.Metallic = _Metallic;
|
|
o.Smoothness = _Roughness;
|
|
float2 uv_Occlusion = i.uv_texcoord * _Occlusion_ST.xy + _Occlusion_ST.zw;
|
|
o.Occlusion = tex2D( _Occlusion, uv_Occlusion ).r;
|
|
o.Transmission = _Transmission.rgb;
|
|
o.Alpha = 1;
|
|
clip( tex2DNode1.a - _Cutoff );
|
|
}
|
|
|
|
ENDCG
|
|
}
|
|
Fallback "Diffuse"
|
|
CustomEditor "ASEMaterialInspector"
|
|
}
|
|
/*ASEBEGIN
|
|
Version=17900
|
|
248;142;1546;726;1933.968;266.8002;1.9;True;True
|
|
Node;AmplifyShaderEditor.RangedFloatNode;18;-2243.115,797.4344;Inherit;False;Property;_WindFrequency;Wind Frequency;8;0;Create;True;0;0;False;0;1.34;0;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleTimeNode;19;-2010.155,798.7966;Inherit;False;1;0;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.TextureCoordinatesNode;20;-1737.689,723.8681;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.RangedFloatNode;21;-1719.977,913.2319;Inherit;False;Property;_NoiseScale;Noise Scale;9;0;Create;True;0;0;False;0;1.41;0;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.NoiseGeneratorNode;23;-1408.761,973.0441;Inherit;False;Simplex2D;True;False;2;0;FLOAT2;0,0;False;1;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.NoiseGeneratorNode;22;-1423.94,661.0446;Inherit;False;Simplex2D;True;False;2;0;FLOAT2;0,0;False;1;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;24;-1168.099,858.6262;Inherit;False;Property;_MovementMultiplier;Movement Multiplier;10;0;Create;True;0;0;False;0;0.07;0.07;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;16;-1101.913,1008.548;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;-0.5;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;17;-1157.768,654.3428;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;-0.5;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;12;-871.7939,658.7897;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;13;-873.7939,866.7897;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;15;-657.7939,925.7897;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;14;-528.7939,961.7897;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0.4;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.TexCoordVertexDataNode;10;-587.794,556.7897;Inherit;False;1;2;0;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.DynamicAppendNode;9;-364.3213,802.1301;Inherit;False;FLOAT3;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.SamplerNode;1;-668.787,-341.3418;Inherit;True;Property;_Albedo;Albedo;1;0;Create;True;0;0;False;0;-1;None;5d93f9a7872434d419a703ec94e2b61b;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;1,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.ColorNode;2;-712.8047,-141.1236;Float;False;Property;_Tint;Tint;0;0;Create;True;0;0;False;0;1,1,1,0;0,1,0.02261806,1;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;8;-196.0677,600.6999;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;5;-192.1002,-416.6436;Float;False;Property;_Roughness;Roughness;2;0;Create;True;0;0;False;0;0.3294118;0.158;0;1;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;4;-260.6375,-337.3971;Float;False;Property;_Metallic;Metallic;3;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;3;-314.7557,-239.3297;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.SamplerNode;25;-512.1041,-36.2216;Inherit;True;Property;_Occlusion;Occlusion;6;0;Create;True;0;0;False;0;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.ColorNode;7;-763.0252,117.8813;Float;False;Property;_Transmission;Transmission;7;0;Create;True;0;0;False;0;0.4506271,0.509434,0.3676575,0;0.5938581,0.6320754,0.4919454,0;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SamplerNode;6;-509.2011,198.7879;Inherit;True;Property;_Normals;Normals;5;0;Create;True;0;0;False;0;-1;None;164b81533617247499e86da8845bbcc4;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;1,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;23.71907,-15.26125;Float;False;True;-1;2;ASEMaterialInspector;0;0;Standard;ASESampleShaders/Transmission;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;1;False;-1;3;False;-1;False;0;False;-1;0;False;-1;False;0;Custom;0.44;True;True;0;True;Opaque;;AlphaTest;ForwardOnly;14;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;0;4;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;1;False;-1;1;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;4;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
|
|
WireConnection;19;0;18;0
|
|
WireConnection;20;1;19;0
|
|
WireConnection;23;0;20;0
|
|
WireConnection;23;1;21;0
|
|
WireConnection;22;0;20;0
|
|
WireConnection;22;1;21;0
|
|
WireConnection;16;0;23;0
|
|
WireConnection;17;0;22;0
|
|
WireConnection;12;0;17;0
|
|
WireConnection;12;1;24;0
|
|
WireConnection;13;0;24;0
|
|
WireConnection;13;1;16;0
|
|
WireConnection;15;0;12;0
|
|
WireConnection;15;1;13;0
|
|
WireConnection;14;0;15;0
|
|
WireConnection;9;0;12;0
|
|
WireConnection;9;1;13;0
|
|
WireConnection;9;2;14;0
|
|
WireConnection;8;0;10;2
|
|
WireConnection;8;1;9;0
|
|
WireConnection;3;0;1;0
|
|
WireConnection;3;1;2;0
|
|
WireConnection;0;0;3;0
|
|
WireConnection;0;1;6;0
|
|
WireConnection;0;3;4;0
|
|
WireConnection;0;4;5;0
|
|
WireConnection;0;5;25;1
|
|
WireConnection;0;6;7;0
|
|
WireConnection;0;10;1;4
|
|
WireConnection;0;11;8;0
|
|
ASEEND*/
|
|
//CHKSM=FA25BDCBEA047D3AD6F879D88FDFEAFA9BE6AFD6 |