This is the 25th day of my participation in the August Genwen Challenge.More challenges in August

👉 About the author

As we all know, life is a long process of constantly overcoming difficulties and reflecting on progress. In this process, there will be a lot of questions and thoughts about life, so I decided to share my thoughts, experiences and stories to find resonance!! Focus on Android/Unity and various game development tips, as well as various resource sharing (websites, tools, materials, source code, games, etc.)

👉 about to learn

Shader Graph creates a water reflection effect without writing code.

👉 effect preview

👉 background

In one weekend evening, Xiao Zhi suddenly found Xiao Kong.

🙎 Xiaozhi: Look, look, the sunset glow is particularly beautiful.

🙈 Xiao Kong: Yes, indeed.

🙎 Xiaozhi:… You’re not even paying attention. You’re just being weird. Think how happy it would be to be reflected on the beach.

🙈 Kono musing: Reflection, reflection, how does this make her get up in Unity?

🙎 Xiaozhi:… “, finished finished, and silence went in.

👉 Case Environment

Unity 2020.3 series F1

Package Manager Make sure Shader Graph is installed in the Package Manager

Ideas:

  1. Use another camera to capture the image, flip it over and place it below.
  2. Use Shader Graph to add a water wave effect to the image.

👉 Practice

Start by creating a WaterShadow folder where you will create all of the following.

Right-click inside and create a Render Texture called Water Render, size can be seen to change the effect accordingly.

Create a Camera in your scene and rename it WaterCamera. The Camera has the same properties as the Main Camera, except that the contents of the Camera are the ones you want to map. Adjust the position slightly by yourself.

Specify the WaterCamera’s Output Texture to the Water Render created earlier. Principle: Render the content taken in by the camera into Water Render, which can be displayed in the scene by other components.

Create a Square (right-click – Create – 2D-sprites) and drag it into the scene, rename it WaterSquare, and adjust the location to fit.

Create a Shader (right-click -shader-urp-sprite Unlit Shader), rename it WaterShader, and double-click to open it

The key

Right click here and we can create the Node Node (there are various types)

To be able to change the contents of the node externally at any time, we first create a Texture2D variable, then drag the variable to the stage, then create a Sample Texture2D node, and finally point the variable node to the node’s Texture

So what we want to do is preview the effect, create a Material in the WaterShadow folder, name it WaterMaterial, and assign Shader to this Material either by dragging the WaterShader directly onto the WaterMaterial, One is to select the right side of WaterMaterial and drag and assign the WaterMaterial to WaterSquare (drag and drop into the scene to assign the value), and then you will see the effect.

We are not satisfied with this effect, so we need to optimize further And flip the content, so we need to create the Tiling And Offset flip node.

Then run it and see what it looks like. But that’s not realistic enough. We need to simulate ripples on the surface of the water. Then we need to continue with Simple Noise, the node that adds the Noise.

This is not enough, this is still static, we need dynamic, so we need to use Time to move (create Time node)

After various connections, we create the following visual Shader.

Let’s take a look at the result after running:

Finally we attach the Shader of the code. At the end of the article would like to project source download address.

Shader "WaterShader"
{
    Properties
    {
        [NoScaleOffset]Texture2D_40d3e1ffef7f43f6b3648f291bb5974d("WaterTexture", 2D) = "white" {}
        Vector1_3b055a08b82546ffbbe80087a02fe9cb("Speed", Float) = 0.2
        Vector1_23db7fea7a93488a82f726fa778690e9("Strength", Float) = 0.02
        Color_cfca9819e86340599cd882083808e8c0("Color", Color) = (0.4185208, 0.8962264, 0.8486329, 0.5019608)
        [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
        [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
        [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
    }
    SubShader
    {
        Tags
        {
            "RenderPipeline"="UniversalPipeline"
            "RenderType"="Transparent"
            "UniversalMaterialType" = "Unlit"
            "Queue"="Transparent"
        }
        Pass
        {
            Name "Sprite Unlit"
            Tags
            {
                "LightMode" = "Universal2D"
            }
            // Render State
            Cull Off
        Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
        ZTest LEqual
        ZWrite Off
            // Debug
            // <None>
            // --------------------------------------------------
            // Pass
            HLSLPROGRAM
            // Pragmas
            #pragma target 2.0
        #pragma exclude_renderers d3d11_9x
        #pragma vertex vert
        #pragma fragment frag
            // DotsInstancingOptions: <None>
            // HybridV1InjectedBuiltinProperties: <None>
            // Keywords
            // PassKeywords: <None>
            // GraphKeywords: <None>
            // Defines
            #define _SURFACE_TYPE_TRANSPARENT 1
            #define ATTRIBUTES_NEED_NORMAL
            #define ATTRIBUTES_NEED_TANGENT
            #define ATTRIBUTES_NEED_TEXCOORD0
            #define ATTRIBUTES_NEED_COLOR
            #define VARYINGS_NEED_TEXCOORD0
            #define VARYINGS_NEED_COLOR
            #define FEATURES_GRAPH_VERTEX
            /* WARNING: $splice Could not find named fragment 'PassInstancing' */
            #define SHADERPASS SHADERPASS_SPRITEUNLIT
            /* WARNING: $splice Could not find named fragment 'DotsInstancingVars' */
            // Includes
            #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
        #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
        #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
            // --------------------------------------------------
            // Structs and Packing
            struct Attributes
        {
            float3 positionOS : POSITION;
            float3 normalOS : NORMAL;
            float4 tangentOS : TANGENT;
            float4 uv0 : TEXCOORD0;
            float4 color : COLOR;
            #if UNITY_ANY_INSTANCING_ENABLED
            uint instanceID : INSTANCEID_SEMANTIC;
            #endif
        };
        struct Varyings
        {
            float4 positionCS : SV_POSITION;
            float4 texCoord0;
            float4 color;
            #if UNITY_ANY_INSTANCING_ENABLED
            uint instanceID : CUSTOM_INSTANCE_ID;
            #endif
            #if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
            uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
            #endif
            #if (defined(UNITY_STEREO_INSTANCING_ENABLED))
            uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
            #endif
            #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
            FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
            #endif
        };
        struct SurfaceDescriptionInputs
        {
            float4 uv0;
            float3 TimeParameters;
        };
        struct VertexDescriptionInputs
        {
            float3 ObjectSpaceNormal;
            float3 ObjectSpaceTangent;
            float3 ObjectSpacePosition;
        };
        struct PackedVaryings
        {
            float4 positionCS : SV_POSITION;
            float4 interp0 : TEXCOORD0;
            float4 interp1 : TEXCOORD1;
            #if UNITY_ANY_INSTANCING_ENABLED
            uint instanceID : CUSTOM_INSTANCE_ID;
            #endif
            #if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
            uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
            #endif
            #if (defined(UNITY_STEREO_INSTANCING_ENABLED))
            uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
            #endif
            #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
            FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
            #endif
        };
            PackedVaryings PackVaryings (Varyings input)
        {
            PackedVaryings output;
            output.positionCS = input.positionCS;
            output.interp0.xyzw =  input.texCoord0;
            output.interp1.xyzw =  input.color;
            #if UNITY_ANY_INSTANCING_ENABLED
            output.instanceID = input.instanceID;
            #endif
            #if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
            output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
            #endif
            #if (defined(UNITY_STEREO_INSTANCING_ENABLED))
            output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
            #endif
            #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
            output.cullFace = input.cullFace;
            #endif
            return output;
        }
        Varyings UnpackVaryings (PackedVaryings input)
        {
            Varyings output;
            output.positionCS = input.positionCS;
            output.texCoord0 = input.interp0.xyzw;
            output.color = input.interp1.xyzw;
            #if UNITY_ANY_INSTANCING_ENABLED
            output.instanceID = input.instanceID;
            #endif
            #if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
            output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
            #endif
            #if (defined(UNITY_STEREO_INSTANCING_ENABLED))
            output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
            #endif
            #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
            output.cullFace = input.cullFace;
            #endif
            return output;
        }
            // --------------------------------------------------
            // Graph
            // Graph Properties
            CBUFFER_START(UnityPerMaterial)
        float4 Texture2D_40d3e1ffef7f43f6b3648f291bb5974d_TexelSize;
        float Vector1_3b055a08b82546ffbbe80087a02fe9cb;
        float Vector1_23db7fea7a93488a82f726fa778690e9;
        float4 Color_cfca9819e86340599cd882083808e8c0;
        CBUFFER_END
        // Object and Global properties
        SAMPLER(SamplerState_Linear_Repeat);
        TEXTURE2D(Texture2D_40d3e1ffef7f43f6b3648f291bb5974d);
        SAMPLER(samplerTexture2D_40d3e1ffef7f43f6b3648f291bb5974d);
            // Graph Functions
            
        float2 Unity_GradientNoise_Dir_float(float2 p)
        {
            // Permutation and hashing used in webgl-nosie goo.gl/pX7HtC
            p = p % 289;
            // need full precision, otherwise half overflows when p > 1
            float x = float(34 * p.x + 1) * p.x % 289 + p.y;
            x = (34 * x + 1) * x % 289;
            x = frac(x / 41) * 2 - 1;
            return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));
        }
        void Unity_GradientNoise_float(float2 UV, float Scale, out float Out)
        { 
            float2 p = UV * Scale;
            float2 ip = floor(p);
            float2 fp = frac(p);
            float d00 = dot(Unity_GradientNoise_Dir_float(ip), fp);
            float d01 = dot(Unity_GradientNoise_Dir_float(ip + float2(0, 1)), fp - float2(0, 1));
            float d10 = dot(Unity_GradientNoise_Dir_float(ip + float2(1, 0)), fp - float2(1, 0));
            float d11 = dot(Unity_GradientNoise_Dir_float(ip + float2(1, 1)), fp - float2(1, 1));
            fp = fp * fp * fp * (fp * (fp * 6 - 15) + 10);
            Out = lerp(lerp(d00, d01, fp.y), lerp(d10, d11, fp.y), fp.x) + 0.5;
        }
        void Unity_Multiply_float(float A, float B, out float Out)
        {
            Out = A * B;
        }
        void Unity_Add_float(float A, float B, out float Out)
        {
            Out = A + B;
        }

        inline float Unity_SimpleNoise_RandomValue_float (float2 uv)
        {
            return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453);
        }
        inline float Unity_SimpleNnoise_Interpolate_float (float a, float b, float t)
        {
            return (1.0-t)*a + (t*b);
        }

        inline float Unity_SimpleNoise_ValueNoise_float (float2 uv)
        {
            float2 i = floor(uv);
            float2 f = frac(uv);
            f = f * f * (3.0 - 2.0 * f);
            uv = abs(frac(uv) - 0.5);
            float2 c0 = i + float2(0.0, 0.0);
            float2 c1 = i + float2(1.0, 0.0);
            float2 c2 = i + float2(0.0, 1.0);
            float2 c3 = i + float2(1.0, 1.0);
            float r0 = Unity_SimpleNoise_RandomValue_float(c0);
            float r1 = Unity_SimpleNoise_RandomValue_float(c1);
            float r2 = Unity_SimpleNoise_RandomValue_float(c2);
            float r3 = Unity_SimpleNoise_RandomValue_float(c3);
            float bottomOfGrid = Unity_SimpleNnoise_Interpolate_float(r0, r1, f.x);
            float topOfGrid = Unity_SimpleNnoise_Interpolate_float(r2, r3, f.x);
            float t = Unity_SimpleNnoise_Interpolate_float(bottomOfGrid, topOfGrid, f.y);
            return t;
        }
        void Unity_SimpleNoise_float(float2 UV, float Scale, out float Out)
        {
            float t = 0.0;
            float freq = pow(2.0, float(0));
            float amp = pow(0.5, float(3-0));
            t += Unity_SimpleNoise_ValueNoise_float(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
            freq = pow(2.0, float(1));
            amp = pow(0.5, float(3-1));
            t += Unity_SimpleNoise_ValueNoise_float(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
            freq = pow(2.0, float(2));
            amp = pow(0.5, float(3-2));
            t += Unity_SimpleNoise_ValueNoise_float(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
            Out = t;
        }
        void Unity_TilingAndOffset_float(float2 UV, float2 Tiling, float2 Offset, out float2 Out)
        {
            Out = UV * Tiling + Offset;
        }
        void Unity_Multiply_float(float4 A, float4 B, out float4 Out)
        {
            Out = A * B;
        }
            // Graph Vertex
            struct VertexDescription
        {
            float3 Position;
            float3 Normal;
            float3 Tangent;
        };
        VertexDescription VertexDescriptionFunction(VertexDescriptionInputs IN)
        {
            VertexDescription description = (VertexDescription)0;
            description.Position = IN.ObjectSpacePosition;
            description.Normal = IN.ObjectSpaceNormal;
            description.Tangent = IN.ObjectSpaceTangent;
            return description;
        }
            // Graph Pixel
            struct SurfaceDescription
        {
            float3 BaseColor;
            float Alpha;
        };
        SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
        {
            SurfaceDescription surface = (SurfaceDescription)0;
            UnityTexture2D _Property_5f96fa6b31874c7c8f49a5ba4c802ea1_Out_0 = UnityBuildTexture2DStructNoScale(Texture2D_40d3e1ffef7f43f6b3648f291bb5974d);
            float _Property_e2b4dcb7085e4752ace7d623eaa848a5_Out_0 = Vector1_23db7fea7a93488a82f726fa778690e9;
            float _GradientNoise_0295ca2f6ca341b1ac796ec73bf2385e_Out_2;
            Unity_GradientNoise_float(IN.uv0.xy, 3, _GradientNoise_0295ca2f6ca341b1ac796ec73bf2385e_Out_2);
            float _Property_7166f06b49d84545891345939cacb632_Out_0 = Vector1_3b055a08b82546ffbbe80087a02fe9cb;
            float _Multiply_bbf027acfdbb41ccaa57e62650292da4_Out_2;
            Unity_Multiply_float(_Property_7166f06b49d84545891345939cacb632_Out_0, IN.TimeParameters.x, _Multiply_bbf027acfdbb41ccaa57e62650292da4_Out_2);
            float _Add_31381d66d83848d381412ee3af768cad_Out_2;
            Unity_Add_float(_GradientNoise_0295ca2f6ca341b1ac796ec73bf2385e_Out_2, _Multiply_bbf027acfdbb41ccaa57e62650292da4_Out_2, _Add_31381d66d83848d381412ee3af768cad_Out_2);
            float _SimpleNoise_634cb24c606344d28b5e7c670c09ba7a_Out_2;
            Unity_SimpleNoise_float((_Add_31381d66d83848d381412ee3af768cad_Out_2.xx), 50, _SimpleNoise_634cb24c606344d28b5e7c670c09ba7a_Out_2);
            float _Multiply_8c1af9eb25a14ad7910d7c5737106dba_Out_2;
            Unity_Multiply_float(_Property_e2b4dcb7085e4752ace7d623eaa848a5_Out_0, _SimpleNoise_634cb24c606344d28b5e7c670c09ba7a_Out_2, _Multiply_8c1af9eb25a14ad7910d7c5737106dba_Out_2);
            float2 _Vector2_6686572d44b148c3bd43ea00a7ee71d6_Out_0 = float2(_Multiply_8c1af9eb25a14ad7910d7c5737106dba_Out_2, 1);
            float2 _TilingAndOffset_80aee777cdc84f93b09a9f58f7cd8a21_Out_3;
            Unity_TilingAndOffset_float(IN.uv0.xy, float2 (1, -1), _Vector2_6686572d44b148c3bd43ea00a7ee71d6_Out_0, _TilingAndOffset_80aee777cdc84f93b09a9f58f7cd8a21_Out_3);
            float4 _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0 = SAMPLE_TEXTURE2D(_Property_5f96fa6b31874c7c8f49a5ba4c802ea1_Out_0.tex, _Property_5f96fa6b31874c7c8f49a5ba4c802ea1_Out_0.samplerstate, _TilingAndOffset_80aee777cdc84f93b09a9f58f7cd8a21_Out_3);
            float _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_R_4 = _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0.r;
            float _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_G_5 = _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0.g;
            float _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_B_6 = _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0.b;
            float _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_A_7 = _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0.a;
            float4 _Property_cc5ba6d85d044fb894405bde6f11b58c_Out_0 = Color_cfca9819e86340599cd882083808e8c0;
            float4 _Multiply_a29ff5ef4d7049d2bb4da2beabad978e_Out_2;
            Unity_Multiply_float(_SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0, _Property_cc5ba6d85d044fb894405bde6f11b58c_Out_0, _Multiply_a29ff5ef4d7049d2bb4da2beabad978e_Out_2);
            surface.BaseColor = (_Multiply_a29ff5ef4d7049d2bb4da2beabad978e_Out_2.xyz);
            surface.Alpha = 1;
            return surface;
        }
            // --------------------------------------------------
            // Build Graph Inputs
            VertexDescriptionInputs BuildVertexDescriptionInputs(Attributes input)
        {
            VertexDescriptionInputs output;
            ZERO_INITIALIZE(VertexDescriptionInputs, output);
            output.ObjectSpaceNormal =           input.normalOS;
            output.ObjectSpaceTangent =          input.tangentOS.xyz;
            output.ObjectSpacePosition =         input.positionOS;
            return output;
        }
            SurfaceDescriptionInputs BuildSurfaceDescriptionInputs(Varyings input)
        {
            SurfaceDescriptionInputs output;
            ZERO_INITIALIZE(SurfaceDescriptionInputs, output);


            output.uv0 =                         input.texCoord0;
            output.TimeParameters =              _TimeParameters.xyz; // This is mainly for LW as HD overwrite this value
        #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
        #define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN output.FaceSign =                    IS_FRONT_VFACE(input.cullFace, true, false);
        #else
        #define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN
        #endif
        #undef BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN
            return output;
        }
            // --------------------------------------------------
            // Main
            #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/Varyings.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/SpriteUnlitPass.hlsl"
            ENDHLSL
        }
        Pass
        {
            Name "Sprite Unlit"
            Tags
            {
                "LightMode" = "UniversalForward"
            }
            // Render State
            Cull Off
        Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
        ZTest LEqual
        ZWrite Off
            // Debug
            // <None>
            // --------------------------------------------------
            // Pass
            HLSLPROGRAM
            // Pragmas
            #pragma target 2.0
        #pragma exclude_renderers d3d11_9x
        #pragma vertex vert
        #pragma fragment frag
            // DotsInstancingOptions: <None>
            // HybridV1InjectedBuiltinProperties: <None>
            // Keywords
            // PassKeywords: <None>
            // GraphKeywords: <None>
            // Defines
            #define _SURFACE_TYPE_TRANSPARENT 1
            #define ATTRIBUTES_NEED_NORMAL
            #define ATTRIBUTES_NEED_TANGENT
            #define ATTRIBUTES_NEED_TEXCOORD0
            #define ATTRIBUTES_NEED_COLOR
            #define VARYINGS_NEED_TEXCOORD0
            #define VARYINGS_NEED_COLOR
            #define FEATURES_GRAPH_VERTEX
            /* WARNING: $splice Could not find named fragment 'PassInstancing' */
            #define SHADERPASS SHADERPASS_SPRITEFORWARD
            /* WARNING: $splice Could not find named fragment 'DotsInstancingVars' */
            // Includes
            #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
        #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
        #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
            // --------------------------------------------------
            // Structs and Packing
            struct Attributes
        {
            float3 positionOS : POSITION;
            float3 normalOS : NORMAL;
            float4 tangentOS : TANGENT;
            float4 uv0 : TEXCOORD0;
            float4 color : COLOR;
            #if UNITY_ANY_INSTANCING_ENABLED
            uint instanceID : INSTANCEID_SEMANTIC;
            #endif
        };
        struct Varyings
        {
            float4 positionCS : SV_POSITION;
            float4 texCoord0;
            float4 color;
            #if UNITY_ANY_INSTANCING_ENABLED
            uint instanceID : CUSTOM_INSTANCE_ID;
            #endif
            #if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
            uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
            #endif
            #if (defined(UNITY_STEREO_INSTANCING_ENABLED))
            uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
            #endif
            #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
            FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
            #endif
        };
        struct SurfaceDescriptionInputs
        {
            float4 uv0;
            float3 TimeParameters;
        };
        struct VertexDescriptionInputs
        {
            float3 ObjectSpaceNormal;
            float3 ObjectSpaceTangent;
            float3 ObjectSpacePosition;
        };
        struct PackedVaryings
        {
            float4 positionCS : SV_POSITION;
            float4 interp0 : TEXCOORD0;
            float4 interp1 : TEXCOORD1;
            #if UNITY_ANY_INSTANCING_ENABLED
            uint instanceID : CUSTOM_INSTANCE_ID;
            #endif
            #if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
            uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
            #endif
            #if (defined(UNITY_STEREO_INSTANCING_ENABLED))
            uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
            #endif
            #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
            FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
            #endif
        };
            PackedVaryings PackVaryings (Varyings input)
        {
            PackedVaryings output;
            output.positionCS = input.positionCS;
            output.interp0.xyzw =  input.texCoord0;
            output.interp1.xyzw =  input.color;
            #if UNITY_ANY_INSTANCING_ENABLED
            output.instanceID = input.instanceID;
            #endif
            #if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
            output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
            #endif
            #if (defined(UNITY_STEREO_INSTANCING_ENABLED))
            output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
            #endif
            #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
            output.cullFace = input.cullFace;
            #endif
            return output;
        }
        Varyings UnpackVaryings (PackedVaryings input)
        {
            Varyings output;
            output.positionCS = input.positionCS;
            output.texCoord0 = input.interp0.xyzw;
            output.color = input.interp1.xyzw;
            #if UNITY_ANY_INSTANCING_ENABLED
            output.instanceID = input.instanceID;
            #endif
            #if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
            output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
            #endif
            #if (defined(UNITY_STEREO_INSTANCING_ENABLED))
            output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
            #endif
            #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
            output.cullFace = input.cullFace;
            #endif
            return output;
        }
            // --------------------------------------------------
            // Graph
            // Graph Properties
            CBUFFER_START(UnityPerMaterial)
        float4 Texture2D_40d3e1ffef7f43f6b3648f291bb5974d_TexelSize;
        float Vector1_3b055a08b82546ffbbe80087a02fe9cb;
        float Vector1_23db7fea7a93488a82f726fa778690e9;
        float4 Color_cfca9819e86340599cd882083808e8c0;
        CBUFFER_END
        // Object and Global properties
        SAMPLER(SamplerState_Linear_Repeat);
        TEXTURE2D(Texture2D_40d3e1ffef7f43f6b3648f291bb5974d);
        SAMPLER(samplerTexture2D_40d3e1ffef7f43f6b3648f291bb5974d);
            // Graph Functions
            
        float2 Unity_GradientNoise_Dir_float(float2 p)
        {
            // Permutation and hashing used in webgl-nosie goo.gl/pX7HtC
            p = p % 289;
            // need full precision, otherwise half overflows when p > 1
            float x = float(34 * p.x + 1) * p.x % 289 + p.y;
            x = (34 * x + 1) * x % 289;
            x = frac(x / 41) * 2 - 1;
            return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));
        }
        void Unity_GradientNoise_float(float2 UV, float Scale, out float Out)
        { 
            float2 p = UV * Scale;
            float2 ip = floor(p);
            float2 fp = frac(p);
            float d00 = dot(Unity_GradientNoise_Dir_float(ip), fp);
            float d01 = dot(Unity_GradientNoise_Dir_float(ip + float2(0, 1)), fp - float2(0, 1));
            float d10 = dot(Unity_GradientNoise_Dir_float(ip + float2(1, 0)), fp - float2(1, 0));
            float d11 = dot(Unity_GradientNoise_Dir_float(ip + float2(1, 1)), fp - float2(1, 1));
            fp = fp * fp * fp * (fp * (fp * 6 - 15) + 10);
            Out = lerp(lerp(d00, d01, fp.y), lerp(d10, d11, fp.y), fp.x) + 0.5;
        }
        void Unity_Multiply_float(float A, float B, out float Out)
        {
            Out = A * B;
        }
        void Unity_Add_float(float A, float B, out float Out)
        {
            Out = A + B;
        }

        inline float Unity_SimpleNoise_RandomValue_float (float2 uv)
        {
            return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453);
        }
        inline float Unity_SimpleNnoise_Interpolate_float (float a, float b, float t)
        {
            return (1.0-t)*a + (t*b);
        }

        inline float Unity_SimpleNoise_ValueNoise_float (float2 uv)
        {
            float2 i = floor(uv);
            float2 f = frac(uv);
            f = f * f * (3.0 - 2.0 * f);
            uv = abs(frac(uv) - 0.5);
            float2 c0 = i + float2(0.0, 0.0);
            float2 c1 = i + float2(1.0, 0.0);
            float2 c2 = i + float2(0.0, 1.0);
            float2 c3 = i + float2(1.0, 1.0);
            float r0 = Unity_SimpleNoise_RandomValue_float(c0);
            float r1 = Unity_SimpleNoise_RandomValue_float(c1);
            float r2 = Unity_SimpleNoise_RandomValue_float(c2);
            float r3 = Unity_SimpleNoise_RandomValue_float(c3);
            float bottomOfGrid = Unity_SimpleNnoise_Interpolate_float(r0, r1, f.x);
            float topOfGrid = Unity_SimpleNnoise_Interpolate_float(r2, r3, f.x);
            float t = Unity_SimpleNnoise_Interpolate_float(bottomOfGrid, topOfGrid, f.y);
            return t;
        }
        void Unity_SimpleNoise_float(float2 UV, float Scale, out float Out)
        {
            float t = 0.0;
            float freq = pow(2.0, float(0));
            float amp = pow(0.5, float(3-0));
            t += Unity_SimpleNoise_ValueNoise_float(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
            freq = pow(2.0, float(1));
            amp = pow(0.5, float(3-1));
            t += Unity_SimpleNoise_ValueNoise_float(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
            freq = pow(2.0, float(2));
            amp = pow(0.5, float(3-2));
            t += Unity_SimpleNoise_ValueNoise_float(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
            Out = t;
        }
        void Unity_TilingAndOffset_float(float2 UV, float2 Tiling, float2 Offset, out float2 Out)
        {
            Out = UV * Tiling + Offset;
        }
        void Unity_Multiply_float(float4 A, float4 B, out float4 Out)
        {
            Out = A * B;
        }
            // Graph Vertex
            struct VertexDescription
        {
            float3 Position;
            float3 Normal;
            float3 Tangent;
        };
        VertexDescription VertexDescriptionFunction(VertexDescriptionInputs IN)
        {
            VertexDescription description = (VertexDescription)0;
            description.Position = IN.ObjectSpacePosition;
            description.Normal = IN.ObjectSpaceNormal;
            description.Tangent = IN.ObjectSpaceTangent;
            return description;
        }
            // Graph Pixel
            struct SurfaceDescription
        {
            float3 BaseColor;
            float Alpha;
        };
        SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
        {
            SurfaceDescription surface = (SurfaceDescription)0;
            UnityTexture2D _Property_5f96fa6b31874c7c8f49a5ba4c802ea1_Out_0 = UnityBuildTexture2DStructNoScale(Texture2D_40d3e1ffef7f43f6b3648f291bb5974d);
            float _Property_e2b4dcb7085e4752ace7d623eaa848a5_Out_0 = Vector1_23db7fea7a93488a82f726fa778690e9;
            float _GradientNoise_0295ca2f6ca341b1ac796ec73bf2385e_Out_2;
            Unity_GradientNoise_float(IN.uv0.xy, 3, _GradientNoise_0295ca2f6ca341b1ac796ec73bf2385e_Out_2);
            float _Property_7166f06b49d84545891345939cacb632_Out_0 = Vector1_3b055a08b82546ffbbe80087a02fe9cb;
            float _Multiply_bbf027acfdbb41ccaa57e62650292da4_Out_2;
            Unity_Multiply_float(_Property_7166f06b49d84545891345939cacb632_Out_0, IN.TimeParameters.x, _Multiply_bbf027acfdbb41ccaa57e62650292da4_Out_2);
            float _Add_31381d66d83848d381412ee3af768cad_Out_2;
            Unity_Add_float(_GradientNoise_0295ca2f6ca341b1ac796ec73bf2385e_Out_2, _Multiply_bbf027acfdbb41ccaa57e62650292da4_Out_2, _Add_31381d66d83848d381412ee3af768cad_Out_2);
            float _SimpleNoise_634cb24c606344d28b5e7c670c09ba7a_Out_2;
            Unity_SimpleNoise_float((_Add_31381d66d83848d381412ee3af768cad_Out_2.xx), 50, _SimpleNoise_634cb24c606344d28b5e7c670c09ba7a_Out_2);
            float _Multiply_8c1af9eb25a14ad7910d7c5737106dba_Out_2;
            Unity_Multiply_float(_Property_e2b4dcb7085e4752ace7d623eaa848a5_Out_0, _SimpleNoise_634cb24c606344d28b5e7c670c09ba7a_Out_2, _Multiply_8c1af9eb25a14ad7910d7c5737106dba_Out_2);
            float2 _Vector2_6686572d44b148c3bd43ea00a7ee71d6_Out_0 = float2(_Multiply_8c1af9eb25a14ad7910d7c5737106dba_Out_2, 1);
            float2 _TilingAndOffset_80aee777cdc84f93b09a9f58f7cd8a21_Out_3;
            Unity_TilingAndOffset_float(IN.uv0.xy, float2 (1, -1), _Vector2_6686572d44b148c3bd43ea00a7ee71d6_Out_0, _TilingAndOffset_80aee777cdc84f93b09a9f58f7cd8a21_Out_3);
            float4 _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0 = SAMPLE_TEXTURE2D(_Property_5f96fa6b31874c7c8f49a5ba4c802ea1_Out_0.tex, _Property_5f96fa6b31874c7c8f49a5ba4c802ea1_Out_0.samplerstate, _TilingAndOffset_80aee777cdc84f93b09a9f58f7cd8a21_Out_3);
            float _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_R_4 = _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0.r;
            float _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_G_5 = _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0.g;
            float _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_B_6 = _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0.b;
            float _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_A_7 = _SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0.a;
            float4 _Property_cc5ba6d85d044fb894405bde6f11b58c_Out_0 = Color_cfca9819e86340599cd882083808e8c0;
            float4 _Multiply_a29ff5ef4d7049d2bb4da2beabad978e_Out_2;
            Unity_Multiply_float(_SampleTexture2D_a940191ef9bb4c11a83d593387dc04f9_RGBA_0, _Property_cc5ba6d85d044fb894405bde6f11b58c_Out_0, _Multiply_a29ff5ef4d7049d2bb4da2beabad978e_Out_2);
            surface.BaseColor = (_Multiply_a29ff5ef4d7049d2bb4da2beabad978e_Out_2.xyz);
            surface.Alpha = 1;
            return surface;
        }
            // --------------------------------------------------
            // Build Graph Inputs
            VertexDescriptionInputs BuildVertexDescriptionInputs(Attributes input)
        {
            VertexDescriptionInputs output;
            ZERO_INITIALIZE(VertexDescriptionInputs, output);
            output.ObjectSpaceNormal =           input.normalOS;
            output.ObjectSpaceTangent =          input.tangentOS.xyz;
            output.ObjectSpacePosition =         input.positionOS;
            return output;
        }
            SurfaceDescriptionInputs BuildSurfaceDescriptionInputs(Varyings input)
        {
            SurfaceDescriptionInputs output;
            ZERO_INITIALIZE(SurfaceDescriptionInputs, output);


            output.uv0 =                         input.texCoord0;
            output.TimeParameters =              _TimeParameters.xyz; // This is mainly for LW as HD overwrite this value
        #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
        #define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN output.FaceSign =                    IS_FRONT_VFACE(input.cullFace, true, false);
        #else
        #define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN
        #endif
        #undef BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN
            return output;
        }
            // --------------------------------------------------
            // Main
            #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/Varyings.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/SpriteUnlitPass.hlsl"
            ENDHLSL
        }
    }
    FallBack "Hidden/Shader Graph/FallbackError"
}
Copy the code

Unity technology -ShaderGraph- Water Reflection Shader.zip-Unity3D -CSDN download

📢 author: small empty and small zhi in small empty!! Focus on sharing Android/Unity and their own control of resources (211/985 courses, Unity/Android courses, Taoke rebate source code, etc.). Looking forward to communicating with you. Mutual benefit.

📢 reproduced description: Sesame Seed’s personal home page (juejin. Cn).

📢 welcome to like 👍 collect 🌟 message 📝