// Made with Amplify Shader Editor v1.9.2.2 // Available at the Unity Asset Store - http://u3d.as/y3X Shader "Glass" { Properties { _Color1("Color 1", Color) = (0.3411765,0.4117647,0.4627451,1) _Color2("Color 2", Color) = (0.1882353,0.2196079,0.2431373,1) _Smoothness("Smoothness", Range( 0 , 1)) = 1 _Metallic("Metallic", Range( 0 , 1)) = 0 _DepthFade("Depth Fade", Float) = 0.1 _ReflectionScale("Reflection Scale", Float) = 8 _ReflectionStr("Reflection Str", Float) = 0.1 _FresnelScale("Fresnel Scale", Float) = 4 _FresnelPower("Fresnel Power", Float) = 2 [HideInInspector] _texcoord( "", 2D ) = "white" {} [HideInInspector] __dirty( "", Int ) = 1 } SubShader { Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" "IgnoreProjector" = "True" } Cull Back CGINCLUDE #include "UnityCG.cginc" #include "UnityShaderVariables.cginc" #include "UnityPBSLighting.cginc" #include "Lighting.cginc" #pragma target 3.0 #ifdef UNITY_PASS_SHADOWCASTER #undef INTERNAL_DATA #undef WorldReflectionVector #undef WorldNormalVector #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) #define WorldNormalVector(data,normal) half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) #endif struct Input { float3 worldPos; float3 worldNormal; INTERNAL_DATA float2 uv_texcoord; float4 screenPos; float eyeDepth; }; uniform float _ReflectionScale; uniform float _ReflectionStr; uniform float4 _Color1; uniform float4 _Color2; UNITY_DECLARE_DEPTH_TEXTURE( _CameraDepthTexture ); uniform float4 _CameraDepthTexture_TexelSize; uniform float _DepthFade; uniform float _FresnelScale; uniform float _FresnelPower; uniform float _Metallic; uniform float _Smoothness; //https://www.shadertoy.com/view/XdXGW8 float2 GradientNoiseDir( float2 x ) { const float2 k = float2( 0.3183099, 0.3678794 ); x = x * k + k.yx; return -1.0 + 2.0 * frac( 16.0 * k * frac( x.x * x.y * ( x.x + x.y ) ) ); } float GradientNoise( float2 UV, float Scale ) { float2 p = UV * Scale; float2 i = floor( p ); float2 f = frac( p ); float2 u = f * f * ( 3.0 - 2.0 * f ); return lerp( lerp( dot( GradientNoiseDir( i + float2( 0.0, 0.0 ) ), f - float2( 0.0, 0.0 ) ), dot( GradientNoiseDir( i + float2( 1.0, 0.0 ) ), f - float2( 1.0, 0.0 ) ), u.x ), lerp( dot( GradientNoiseDir( i + float2( 0.0, 1.0 ) ), f - float2( 0.0, 1.0 ) ), dot( GradientNoiseDir( i + float2( 1.0, 1.0 ) ), f - float2( 1.0, 1.0 ) ), u.x ), u.y ); } float3 PerturbNormal107_g2( float3 surf_pos, float3 surf_norm, float height, float scale ) { // "Bump Mapping Unparametrized Surfaces on the GPU" by Morten S. Mikkelsen float3 vSigmaS = ddx( surf_pos ); float3 vSigmaT = ddy( surf_pos ); float3 vN = surf_norm; float3 vR1 = cross( vSigmaT , vN ); float3 vR2 = cross( vN , vSigmaS ); float fDet = dot( vSigmaS , vR1 ); float dBs = ddx( height ); float dBt = ddy( height ); float3 vSurfGrad = scale * 0.05 * sign( fDet ) * ( dBs * vR1 + dBt * vR2 ); return normalize ( abs( fDet ) * vN - vSurfGrad ); } void vertexDataFunc( inout appdata_full v, out Input o ) { UNITY_INITIALIZE_OUTPUT( Input, o ); o.eyeDepth = -UnityObjectToViewPos( v.vertex.xyz ).z; } void surf( Input i , inout SurfaceOutputStandard o ) { float3 ase_worldPos = i.worldPos; float3 surf_pos107_g2 = ase_worldPos; float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) ); float3 surf_norm107_g2 = ase_worldNormal; float gradientNoise20 = GradientNoise(i.uv_texcoord,_ReflectionScale); gradientNoise20 = gradientNoise20*0.5 + 0.5; float height107_g2 = gradientNoise20; float scale107_g2 = _ReflectionStr; float3 localPerturbNormal107_g2 = PerturbNormal107_g2( surf_pos107_g2 , surf_norm107_g2 , height107_g2 , scale107_g2 ); float3 ase_worldTangent = WorldNormalVector( i, float3( 1, 0, 0 ) ); float3 ase_worldBitangent = WorldNormalVector( i, float3( 0, 1, 0 ) ); float3x3 ase_worldToTangent = float3x3( ase_worldTangent, ase_worldBitangent, ase_worldNormal ); float3 worldToTangentDir42_g2 = mul( ase_worldToTangent, localPerturbNormal107_g2); float3 temp_output_18_40 = worldToTangentDir42_g2; o.Normal = temp_output_18_40; float4 ase_screenPos = float4( i.screenPos.xyz , i.screenPos.w + 0.00000000001 ); float4 ase_screenPosNorm = ase_screenPos / ase_screenPos.w; ase_screenPosNorm.z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? ase_screenPosNorm.z : ase_screenPosNorm.z * 0.5 + 0.5; float screenDepth4 = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, ase_screenPosNorm.xy )); float distanceDepth4 = saturate( abs( ( screenDepth4 - LinearEyeDepth( ase_screenPosNorm.z ) ) / ( _DepthFade ) ) ); float4 lerpResult7 = lerp( _Color1 , _Color2 , distanceDepth4); float3 ase_worldViewDir = normalize( UnityWorldSpaceViewDir( ase_worldPos ) ); float3x3 ase_tangentToWorldFast = float3x3(ase_worldTangent.x,ase_worldBitangent.x,ase_worldNormal.x,ase_worldTangent.y,ase_worldBitangent.y,ase_worldNormal.y,ase_worldTangent.z,ase_worldBitangent.z,ase_worldNormal.z); float fresnelNdotV23 = dot( mul(ase_tangentToWorldFast,temp_output_18_40), ase_worldViewDir ); float fresnelNode23 = ( 0.0 + _FresnelScale * pow( 1.0 - fresnelNdotV23, _FresnelPower ) ); float2 _Vector0 = float2(0,0); float cameraDepthFade21 = (( i.eyeDepth -_ProjectionParams.y - _Vector0.y ) / _Vector0.x); float clampResult35 = clamp( cameraDepthFade21 , 0.0 , 2.0 ); float4 lerpResult36 = lerp( lerpResult7 , _Color1 , ( fresnelNode23 * clampResult35 )); o.Albedo = lerpResult36.rgb; o.Metallic = _Metallic; o.Smoothness = _Smoothness; o.Alpha = 1; } ENDCG CGPROGRAM #pragma surface surf Standard alpha:fade keepalpha fullforwardshadows vertex:vertexDataFunc ENDCG Pass { Name "ShadowCaster" Tags{ "LightMode" = "ShadowCaster" } ZWrite On CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 3.0 #pragma multi_compile_shadowcaster #pragma multi_compile UNITY_PASS_SHADOWCASTER #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 #include "HLSLSupport.cginc" #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN ) #define CAN_SKIP_VPOS #endif #include "UnityCG.cginc" #include "Lighting.cginc" #include "UnityPBSLighting.cginc" struct v2f { V2F_SHADOW_CASTER; float3 customPack1 : TEXCOORD1; float4 screenPos : TEXCOORD2; float4 tSpace0 : TEXCOORD3; float4 tSpace1 : TEXCOORD4; float4 tSpace2 : TEXCOORD5; UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; v2f vert( appdata_full v ) { v2f o; UNITY_SETUP_INSTANCE_ID( v ); UNITY_INITIALIZE_OUTPUT( v2f, o ); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o ); UNITY_TRANSFER_INSTANCE_ID( v, o ); Input customInputData; vertexDataFunc( v, customInputData ); float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz; half3 worldNormal = UnityObjectToWorldNormal( v.normal ); half3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz ); half tangentSign = v.tangent.w * unity_WorldTransformParams.w; half3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign; o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x ); o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y ); o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z ); o.customPack1.xy = customInputData.uv_texcoord; o.customPack1.xy = v.texcoord; o.customPack1.z = customInputData.eyeDepth; TRANSFER_SHADOW_CASTER_NORMALOFFSET( o ) o.screenPos = ComputeScreenPos( o.pos ); return o; } half4 frag( v2f IN #if !defined( CAN_SKIP_VPOS ) , UNITY_VPOS_TYPE vpos : VPOS #endif ) : SV_Target { UNITY_SETUP_INSTANCE_ID( IN ); Input surfIN; UNITY_INITIALIZE_OUTPUT( Input, surfIN ); surfIN.uv_texcoord = IN.customPack1.xy; surfIN.eyeDepth = IN.customPack1.z; float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w ); half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) ); surfIN.worldPos = worldPos; surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z ); surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz; surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz; surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz; surfIN.screenPos = IN.screenPos; SurfaceOutputStandard o; UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o ) surf( surfIN, o ); #if defined( CAN_SKIP_VPOS ) float2 vpos = IN.pos; #endif SHADOW_CASTER_FRAGMENT( IN ) } ENDCG } } Fallback "Diffuse" CustomEditor "ASEMaterialInspector" } /*ASEBEGIN Version=19202 Node;AmplifyShaderEditor.TextureCoordinatesNode;14;-310.5953,-454.2664;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.NoiseGeneratorNode;20;149.1352,-406.9106;Inherit;True;Gradient;True;False;2;0;FLOAT2;0,0;False;1;FLOAT;1;False;1;FLOAT;0 Node;AmplifyShaderEditor.FunctionNode;18;440.4083,-496.5573;Inherit;False;Normal From Height;-1;;2;1942fe2c5f1a1f94881a33d532e4afeb;0;2;20;FLOAT;0;False;110;FLOAT;1;False;2;FLOAT3;40;FLOAT3;0 Node;AmplifyShaderEditor.RangedFloatNode;15;-109.9097,-289.8945;Inherit;False;Property;_ReflectionScale;Reflection Scale;5;0;Create;True;0;0;0;False;0;False;8;8;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;19;192.963,-518.3289;Inherit;False;Property;_ReflectionStr;Reflection Str;6;0;Create;True;0;0;0;False;0;False;0.1;0.1;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;1785.792,-523.1074;Float;False;True;-1;2;ASEMaterialInspector;0;0;Standard;Glass;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;False;False;False;False;False;False;Back;0;False;;0;False;;False;0;False;;0;False;;False;0;Transparent;0.5;True;True;0;False;Transparent;;Transparent;All;12;all;True;True;True;True;0;False;;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;2;15;10;25;False;0.5;True;2;5;False;;10;False;;0;0;False;;0;False;;0;False;;0;False;;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;True;Relative;0;;-1;-1;-1;-1;0;False;0;0;False;;-1;0;False;;0;0;0;False;0.1;False;;0;False;;False;17;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;16;FLOAT4;0,0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 Node;AmplifyShaderEditor.RangedFloatNode;8;1434.029,-345.222;Inherit;False;Property;_Smoothness;Smoothness;2;0;Create;True;0;0;0;False;0;False;1;1;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;9;1434.029,-429.2219;Inherit;False;Property;_Metallic;Metallic;3;0;Create;True;0;0;0;False;0;False;0;0;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.CameraDepthFade;21;791.4205,-372.1212;Inherit;False;3;2;FLOAT3;0,0,0;False;0;FLOAT;1;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.Vector2Node;22;574.684,-358.2556;Inherit;False;Constant;_Vector0;Vector 0;7;0;Create;True;0;0;0;False;0;False;0,0;0.26,1.8;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 Node;AmplifyShaderEditor.ClampOpNode;35;1067.605,-374.355;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;2;False;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;39;744.7726,-557.9752;Inherit;False;Property;_FresnelPower;Fresnel Power;8;0;Create;True;0;0;0;False;0;False;2;2;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;38;748.2095,-650.1935;Inherit;False;Property;_FresnelScale;Fresnel Scale;7;0;Create;True;0;0;0;False;0;False;4;4;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.FresnelNode;23;970.1049,-693.7438;Inherit;False;Standard;TangentNormal;ViewDir;False;False;5;0;FLOAT3;0,0,1;False;4;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT;1;False;3;FLOAT;5;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;33;1283.213,-666.5261;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;5;180.1668,-622.51;Inherit;False;Property;_DepthFade;Depth Fade;4;0;Create;True;0;0;0;False;0;False;0.1;0.1;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.ColorNode;6;420.8615,-854.1184;Inherit;False;Property;_Color2;Color 2;1;0;Create;True;0;0;0;False;0;False;0.1882353,0.2196079,0.2431373,1;0.1882352,0.2196077,0.2431372,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.ColorNode;2;417.2489,-1072.927;Inherit;False;Property;_Color1;Color 1;0;0;Create;True;0;0;0;False;0;False;0.3411765,0.4117647,0.4627451,1;0.3411764,0.4117646,0.4627449,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.LerpOp;7;742.1226,-877.3754;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0 Node;AmplifyShaderEditor.LerpOp;36;1587.249,-868.3034;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0 Node;AmplifyShaderEditor.DepthFade;4;391.1348,-650.6521;Inherit;False;True;True;True;2;1;FLOAT3;0,0,0;False;0;FLOAT;1;False;1;FLOAT;0 WireConnection;20;0;14;0 WireConnection;20;1;15;0 WireConnection;18;20;20;0 WireConnection;18;110;19;0 WireConnection;0;0;36;0 WireConnection;0;1;18;40 WireConnection;0;3;9;0 WireConnection;0;4;8;0 WireConnection;21;0;22;1 WireConnection;21;1;22;2 WireConnection;35;0;21;0 WireConnection;23;0;18;40 WireConnection;23;2;38;0 WireConnection;23;3;39;0 WireConnection;33;0;23;0 WireConnection;33;1;35;0 WireConnection;7;0;2;0 WireConnection;7;1;6;0 WireConnection;7;2;4;0 WireConnection;36;0;7;0 WireConnection;36;1;2;0 WireConnection;36;2;33;0 WireConnection;4;0;5;0 ASEEND*/ //CHKSM=FD5E1F9A767570911AC81CE54DAE8AEA306F8CB7