-
-
Save KenneyNL/6639009d5448c4bd35956e4c4c36c42e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Made with Amplify Shader Editor | |
// Available at the Unity Asset Store - http://u3d.as/y3X | |
Shader "Custom/Water" | |
{ | |
Properties | |
{ | |
_Color("Color", Color) = (0.6196079,0.9176471,1,0) | |
_UnderwaterColor("Underwater Color", Color) = (0.3529412,0.7176471,0.8207547,0) | |
_Foamcolor("Foam color", Color) = (1,1,1,1) | |
_EdgeLength ( "Edge length", Range( 2, 50 ) ) = 15 | |
_Foam("Foam", Range( 0 , 1)) = 0.1 | |
_Depth("Depth", Range( 0 , 2)) = 0.75 | |
_Wavespeed("Wave speed", Range( 0 , 0.25)) = 0.1 | |
_Waves("Waves", Range( 0 , 2)) = 0.5 | |
[HideInInspector] __dirty( "", Int ) = 1 | |
} | |
SubShader | |
{ | |
Tags{ "RenderType" = "Opaque" "Queue" = "Overlay+0" "IsEmissive" = "true" } | |
Cull Back | |
CGPROGRAM | |
#include "UnityShaderVariables.cginc" | |
#include "UnityCG.cginc" | |
#include "Tessellation.cginc" | |
#pragma target 4.6 | |
#pragma surface surf Unlit keepalpha addshadow fullforwardshadows vertex:vertexDataFunc tessellate:tessFunction | |
struct Input | |
{ | |
float4 screenPos; | |
}; | |
uniform float _Wavespeed; | |
uniform float _Waves; | |
uniform float4 _UnderwaterColor; | |
uniform float4 _Color; | |
UNITY_DECLARE_DEPTH_TEXTURE( _CameraDepthTexture ); | |
uniform float4 _CameraDepthTexture_TexelSize; | |
uniform float _Depth; | |
uniform float4 _Foamcolor; | |
uniform float _Foam; | |
uniform float _EdgeLength; | |
float3 mod3D289( float3 x ) { return x - floor( x / 289.0 ) * 289.0; } | |
float4 mod3D289( float4 x ) { return x - floor( x / 289.0 ) * 289.0; } | |
float4 permute( float4 x ) { return mod3D289( ( x * 34.0 + 1.0 ) * x ); } | |
float4 taylorInvSqrt( float4 r ) { return 1.79284291400159 - r * 0.85373472095314; } | |
float snoise( float3 v ) | |
{ | |
const float2 C = float2( 1.0 / 6.0, 1.0 / 3.0 ); | |
float3 i = floor( v + dot( v, C.yyy ) ); | |
float3 x0 = v - i + dot( i, C.xxx ); | |
float3 g = step( x0.yzx, x0.xyz ); | |
float3 l = 1.0 - g; | |
float3 i1 = min( g.xyz, l.zxy ); | |
float3 i2 = max( g.xyz, l.zxy ); | |
float3 x1 = x0 - i1 + C.xxx; | |
float3 x2 = x0 - i2 + C.yyy; | |
float3 x3 = x0 - 0.5; | |
i = mod3D289( i); | |
float4 p = permute( permute( permute( i.z + float4( 0.0, i1.z, i2.z, 1.0 ) ) + i.y + float4( 0.0, i1.y, i2.y, 1.0 ) ) + i.x + float4( 0.0, i1.x, i2.x, 1.0 ) ); | |
float4 j = p - 49.0 * floor( p / 49.0 ); // mod(p,7*7) | |
float4 x_ = floor( j / 7.0 ); | |
float4 y_ = floor( j - 7.0 * x_ ); // mod(j,N) | |
float4 x = ( x_ * 2.0 + 0.5 ) / 7.0 - 1.0; | |
float4 y = ( y_ * 2.0 + 0.5 ) / 7.0 - 1.0; | |
float4 h = 1.0 - abs( x ) - abs( y ); | |
float4 b0 = float4( x.xy, y.xy ); | |
float4 b1 = float4( x.zw, y.zw ); | |
float4 s0 = floor( b0 ) * 2.0 + 1.0; | |
float4 s1 = floor( b1 ) * 2.0 + 1.0; | |
float4 sh = -step( h, 0.0 ); | |
float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; | |
float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; | |
float3 g0 = float3( a0.xy, h.x ); | |
float3 g1 = float3( a0.zw, h.y ); | |
float3 g2 = float3( a1.xy, h.z ); | |
float3 g3 = float3( a1.zw, h.w ); | |
float4 norm = taylorInvSqrt( float4( dot( g0, g0 ), dot( g1, g1 ), dot( g2, g2 ), dot( g3, g3 ) ) ); | |
g0 *= norm.x; | |
g1 *= norm.y; | |
g2 *= norm.z; | |
g3 *= norm.w; | |
float4 m = max( 0.6 - float4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 ); | |
m = m* m; | |
m = m* m; | |
float4 px = float4( dot( x0, g0 ), dot( x1, g1 ), dot( x2, g2 ), dot( x3, g3 ) ); | |
return 42.0 * dot( m, px); | |
} | |
float4 tessFunction( appdata_full v0, appdata_full v1, appdata_full v2 ) | |
{ | |
return UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, _EdgeLength); | |
} | |
void vertexDataFunc( inout appdata_full v ) | |
{ | |
float mulTime64 = _Time.y * _Wavespeed; | |
float2 temp_cast_0 = (mulTime64).xx; | |
float2 uv_TexCoord55 = v.texcoord.xy + temp_cast_0; | |
float simplePerlin3D54 = snoise( float3( uv_TexCoord55 , 0.0 )*10.0 ); | |
float mulTime67 = _Time.y * ( _Wavespeed * -1.0 ); | |
float2 temp_cast_2 = (mulTime67).xx; | |
float2 uv_TexCoord68 = v.texcoord.xy + temp_cast_2; | |
float simplePerlin3D66 = snoise( float3( uv_TexCoord68 , 0.0 )*5.0 ); | |
float3 temp_cast_4 = (( ( ( simplePerlin3D54 - simplePerlin3D66 ) / 20.0 ) * _Waves )).xxx; | |
v.vertex.xyz += temp_cast_4; | |
} | |
inline half4 LightingUnlit( SurfaceOutput s, half3 lightDir, half atten ) | |
{ | |
return half4 ( 0, 0, 0, s.Alpha ); | |
} | |
void surf( Input i , inout SurfaceOutput o ) | |
{ | |
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 screenDepth7 = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, ase_screenPosNorm.xy )); | |
float distanceDepth7 = saturate( ( screenDepth7 - LinearEyeDepth( ase_screenPosNorm.z ) ) / ( _Depth ) ); | |
float4 lerpResult12 = lerp( _UnderwaterColor , _Color , distanceDepth7); | |
float screenDepth13 = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, ase_screenPosNorm.xy )); | |
float distanceDepth13 = ( screenDepth13 - LinearEyeDepth( ase_screenPosNorm.z ) ) / ( _Foam ); | |
float clampResult18 = clamp( pow( distanceDepth13 , 20.0 ) , 0.0 , 1.0 ); | |
o.Emission = ( lerpResult12 + ( _Foamcolor * ( 1.0 - clampResult18 ) ) ).rgb; | |
o.Alpha = 1; | |
} | |
ENDCG | |
} | |
Fallback "Diffuse" | |
CustomEditor "ASEMaterialInspector" | |
} | |
/*ASEBEGIN | |
Version=17500 | |
51;362;1346;624;1347.153;282.9665;1;True;True | |
Node;AmplifyShaderEditor.RangedFloatNode;85;-1007.773,377.0398;Inherit;False;Property;_Wavespeed;Wave speed;11;0;Create;True;0;0;False;0;0.1;0.1;0;0.25;0;1;FLOAT;0 | |
Node;AmplifyShaderEditor.RangedFloatNode;88;-841.8737,99.31012;Inherit;False;Property;_Foam;Foam;9;0;Create;True;0;0;False;0;0.1;0;0;1;0;1;FLOAT;0 | |
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;87;-685.7665,462.2427;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;-1;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.SimpleTimeNode;67;-537.836,515.7151;Inherit;False;1;0;FLOAT;-0.1;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.DepthFade;13;-530.062,106.3652;Inherit;False;True;False;False;2;1;FLOAT3;0,0,0;False;0;FLOAT;0.1;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.SimpleTimeNode;64;-536.6288,387.0558;Inherit;False;1;0;FLOAT;0.1;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.TextureCoordinatesNode;55;-296.6288,371.0559;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.PowerNode;17;-221.6906,107.3126;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;20;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.TextureCoordinatesNode;68;-292.6359,501.1823;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;92;-952.1526,-63.96646;Inherit;False;Property;_Depth;Depth;10;0;Create;True;0;0;False;0;0.75;0;0;2;0;1;FLOAT;0 | |
Node;AmplifyShaderEditor.NoiseGeneratorNode;66;-2.692234,585.7044;Inherit;True;Simplex3D;False;False;2;0;FLOAT3;0,0,0;False;1;FLOAT;5;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.ClampOpNode;18;-24.5486,97.30966;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.NoiseGeneratorNode;54;-2.861191,355.9016;Inherit;True;Simplex3D;False;False;2;0;FLOAT3;0,0,0;False;1;FLOAT;10;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.SimpleSubtractOpNode;73;269.1815,457.9654;Inherit;True;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.OneMinusNode;19;125.1412,97.79512;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.DepthFade;7;-558.1898,-37.64202;Inherit;False;True;True;False;2;1;FLOAT3;0,0,0;False;0;FLOAT;0.75;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.ColorNode;81;115.0422,-238.2971;Inherit;False;Property;_Foamcolor;Foam color;2;0;Create;True;0;0;False;0;1,1,1,1;1,1,1,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 | |
Node;AmplifyShaderEditor.ColorNode;2;-536.7433,-388.9233;Inherit;False;Property;_UnderwaterColor;Underwater Color;1;0;Create;True;0;0;False;0;0.3529412,0.7176471,0.8207547,0;0.1084906,0.7471874,1,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 | |
Node;AmplifyShaderEditor.ColorNode;9;-538.3219,-216.7488;Inherit;False;Property;_Color;Color;0;0;Create;True;0;0;False;0;0.6196079,0.9176471,1,0;0.1084906,0.7471874,1,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 | |
Node;AmplifyShaderEditor.LerpOp;12;-184,-81.5;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.SimpleMultiplyOpNode;82;377.7489,-204.2954;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;1;COLOR;0 | |
Node;AmplifyShaderEditor.SimpleDivideOpNode;65;510.8622,459.027;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;20;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.RangedFloatNode;84;351.6333,295.8426;Inherit;False;Property;_Waves;Waves;12;0;Create;True;0;0;False;0;0.5;0;0;2;0;1;FLOAT;0 | |
Node;AmplifyShaderEditor.SimpleAddOpNode;21;610.3246,-81.82653;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 | |
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;83;789.6624,381.5458;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 | |
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;998.4252,-123.9971;Float;False;True;-1;6;ASEMaterialInspector;0;0;Unlit;Custom/Water;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Custom;0.5;True;True;0;True;Opaque;;Overlay;All;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;True;2;15;10;50;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;3;-1;-1;4;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;15;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;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;87;0;85;0 | |
WireConnection;67;0;87;0 | |
WireConnection;13;0;88;0 | |
WireConnection;64;0;85;0 | |
WireConnection;55;1;64;0 | |
WireConnection;17;0;13;0 | |
WireConnection;68;1;67;0 | |
WireConnection;66;0;68;0 | |
WireConnection;18;0;17;0 | |
WireConnection;54;0;55;0 | |
WireConnection;73;0;54;0 | |
WireConnection;73;1;66;0 | |
WireConnection;19;0;18;0 | |
WireConnection;7;0;92;0 | |
WireConnection;12;0;2;0 | |
WireConnection;12;1;9;0 | |
WireConnection;12;2;7;0 | |
WireConnection;82;0;81;0 | |
WireConnection;82;1;19;0 | |
WireConnection;65;0;73;0 | |
WireConnection;21;0;12;0 | |
WireConnection;21;1;82;0 | |
WireConnection;83;0;65;0 | |
WireConnection;83;1;84;0 | |
WireConnection;0;2;21;0 | |
WireConnection;0;11;83;0 | |
ASEEND*/ | |
//CHKSM=46404C84D301E6D115F386D95605FBD13F226D68 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment